Skip to content

Instantly share code, notes, and snippets.

#include <errno.h>
#include <fcntl.h>
#include <linux/videodev2.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <unistd.h>
#include <opencv2/core/core.hpp>
[h264 @ 0x4731c00] non-existing PPS referenced
[h264 @ 0x4731c00] non-existing PPS 0 referenced
[h264 @ 0x4731c00] decode_slice_header error
[h264 @ 0x4731c00] no frame!
[h264 @ 0x4731c00] non-existing PPS referenced
[h264 @ 0x4731c00] non-existing PPS 0 referenced
[h264 @ 0x4731c00] decode_slice_header error
[h264 @ 0x4731c00] no frame!
[h264 @ 0x4731c00] non-existing PPS referenced
[h264 @ 0x4731c00] non-existing PPS 0 referenced
/*
* 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>
@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++)
{
@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 / 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 / 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)
/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 / 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
########
# 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()