Skip to content

Instantly share code, notes, and snippets.

@jayrambhia
jayrambhia / git patches
Created April 22, 2013 17:02
git patches
[22:27] <@xamox> If you have changes you want to keep, then I suggest formatting a patch
[22:27] <@xamox> git checkout develop
[22:27] <vighnesh> Okay, So ill reclone, put in my additions, and resend pull request ?
[22:28] <@xamox> git format patch develop mypersonal/develop > mychanges.patch
[22:28] <@xamox> You can always edit out of that patch file what you want to delete or keep
[22:28] <@xamox> then reclone
[22:28] <@xamox> then you can
[22:28] <@xamox> git apply patch mychanges.patch
└─[$] <git:(Image/cvmat_con)> nosetests tests.py
...........................................................................................OpenCV Error: Assertion failed (src.depth() == dst.depth() && src.size == dst.size) in cvCopy, file /home/jay/Downloads/OpenCV-2.4.4/modules/core/src/copy.cpp, line 557
E............................................................................................../home/jay/Git/SimpleCV/SimpleCV/ImageClass.py:12889: RuntimeWarning: invalid value encountered in divide
harmonic_mean = detA / traceA
..WARNING: stepic library required
WARNING: stepic library required
.........................../home/jay/Git/SimpleCV/SimpleCV/ImageClass.py:13431: UserWarning: 0 intensity means no blurring
warnings.warn("0 intensity means no blurring")
....
======================================================================
########
# This code creates 2 sub-processes: one that continually polls a webcam and labels each resulting image with a timestamp, and another that saves these images to file. The process that saves the images to file doesn't save all the images, but instead listens to the main process for time windows that it should save. This permits one to save only certain time windows (toss images that fall outside this time window) and avoids the capture start up lag that occurs if you simply try to poll the webcam during the time window of interest (this lag can be several tenths of a second!). Converting the images to string then pickling before queueing them was necessary because opencv's iplimage format doesn't like to be put in a queue directly.
########
import multiprocessing
import cv
import cPickle
import time
queue_to_cam_writer = multiprocessing.Queue()
@jayrambhia
jayrambhia / setup_me.sh
Created May 18, 2013 08:02
basic setup script
sudo apt-get install -y wget
sudo apt-get install -y git
wget https://raw.github.com/jayrambhia/Install-OpenCV/master/Ubuntu/2.4/opencv2_4_5.sh
sh opencv_2_4_5.sh
sudo apt-get install -y python-scipy ipython ipython-notebook
sudo apt-get install -y python-setuptools
cd ~
git clone [email protected]:jayrambhia/SimpleCV.git
cd SimpleCV
sudo python setup.py develop
/var/lib/gems/1.8/gems/nestful-1.0.3/lib/nestful/endpoint.rb:39:in `request': /var/lib/gems/1.8/gems/nestful-1.0.3/lib/nestful/request.rb:99: syntax error, unexpected '.', expecting kEND (SyntaxError)
.merge(content_type_headers)
^
/var/lib/gems/1.8/gems/nestful-1.0.3/lib/nestful/request.rb:100: syntax error, unexpected '.', expecting kEND
.merge(headers)
^
from /var/lib/gems/1.8/gems/nestful-1.0.3/lib/nestful/endpoint.rb:23:in `get'
from /var/lib/gems/1.8/gems/nestful-1.0.3/lib/nestful.rb:16:in `get'
from /var/lib/gems/1.8/gems/HNsearch-1.0/lib/HNsearch/HNsearch_api.rb:16:in `query_items'
from /var/lib/gems/1.8/gems/HNsearch-1.0/lib/HNsearch.rb:11:in `items'
@jayrambhia
jayrambhia / Makefile
Created May 30, 2013 11:37
Basic sample code for freenect support for OpenCV.
CXXFLAGS = -O2 -g -Wall -fmessage-length=0 `pkg-config opencv --cflags ` -I /usr/include/libusb-1.0
OBJS = freenectopencv.o
LIBS = `pkg-config opencv --libs` -lfreenect
TARGET = kinectopencv
$(TARGET):$(OBJS)
$(CXX) -o $(TARGET) $(OBJS) $(LIBS)
all:$(TARGET)
clean:
rm -f $(OBJS) $(TARGET)
@jayrambhia
jayrambhia / Makefile
Created May 30, 2013 12:53
Using Kinect with Freenect and OpenCV (C++ version)
CXXFLAGS = -O2 -g -Wall -fmessage-length=0 `pkg-config opencv --cflags ` -I /usr/include/libusb-1.0
OBJS = freenectopencvmat.o
LIBS = `pkg-config opencv --libs` -lfreenect
TARGET = kinectopencv
$(TARGET):$(OBJS)
$(CXX) -o $(TARGET) $(OBJS) $(LIBS)
all:$(TARGET)
clean:
rm -f $(OBJS) $(TARGET)
@jayrambhia
jayrambhia / numpttricks.py
Last active December 18, 2015 12:59
Numpy Tricks
import numpy as np
# Get the numpy array
import cv2
img = cv2.imread("Lenna.png")
# Get 3 layers
layer1 = img[:,:,0]
layer2 = img[:,:,1]
layer3 = img[:,:,2]
@jayrambhia
jayrambhia / contours.cpp
Last active December 18, 2015 13:18
Fingertips detection using Kinect
Canny(img_thresh, img_canny, 60, 110);
vector< vector<Point> > contours;
vector< vector<Point> >hull;
vector< vector<int> >hullI;
findContours(img_canny, contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_SIMPLE);
for(i = 0; i < contours.size(); i++)
{
/*
* V4L2 video capture example
*
* This program can be used and distributed without restrictions.
*
* This program is provided with the V4L2 API
* see http://linuxtv.org/docs.php for more information
*/
#include <stdio.h>