segunda-feira, 18 de janeiro de 2010

Related Work

In the last months I have been exploring the OpenCV library. It is a great library with several general purpose algorithms for computer vision. One of the problems is that it has become somewhat outdated. New discoveries and new projects and libraries have risen and should be explored.

Today I went exploring the web for further computer vision projects.

OpenVis3D is a library that takes advantage of stereo vision to create a 3D representation of the scene

http://code.google.com/p/openvis3d/

 

List of software and code for computer vision:

http://www.cs.cmu.edu/~cil/v-source.html

 

Real time dense stereo:

http://people.csail.mit.edu/demirdji/download/index.html

 

Panoramic and photo stiching tools

http://www.all-in-one.ee/~dersch/

 

Image stiching

http://sharpstitch.sourceforge.net/

sexta-feira, 15 de janeiro de 2010

Panoramic vision with a webcam

panoramic

Yesterday I’ve continued my experiments with openCV, this is a small demo that creates a panoramic vision using a simple webcam. It works best if the camera if the camera is attach to some support and moved using only rotation.

This demo takes advantage of the functions explained in the previous post but presents the new camera frames in an approximated position using the average displacement of the common points of the current and previous frames.

 

An interesting blog with useful function for OpenCV is this one: http://blog.weisu.org/search/label/OpenCV

quinta-feira, 14 de janeiro de 2010

Finding common points in two consecutive frames or stereo vision.

image

This was a little test program to understand how to work with the flow functions from OpenCV.

This example is based on the lkdemo demo from OpenCV.

In the first image I detect the most important points from the image such as corners using the cvGoodFeaturesToTrack function.

In the second image the same points were tracked using the cvCalcOpticalFlowPyrLK function.

terça-feira, 5 de janeiro de 2010

OpenCV and OpenFrameworks integration

Everyone that has used OpenFramewoks knows that there is an add-on that implements some functions from the OpenCV library. Most of these functions include basic image processing, blob tracking and face recognition. But what about the rest of the library? What if I want to use a Corner Detection function from OpenCv and still display the result in OpenFrameworks?

Bellow there is a simple code to use ofImage, ofxCvGrayscaleImage and ofxCvColorImage from OpenFrameworks and use them with OpenCV functions such as cvPreCornerDetect or cvDilate.

Using the OpenCV example in OpenFrameworks, extra declarations in testApp.h:

ofImage                    loader;
ofxCvGrayscaleImage cornersImg;
ofxCvColorImage colorImg;

in testApp.cpp these are the setup and draw functions.

void testApp::setup(){
loader.loadImage("t01-esq.png"); //load image
colorImg.allocate( loader.width,loader.height);
cornersImg.allocate( loader.width,loader.height);
colorImg.setFromPixels(loader.getPixels(), loader.width,loader.height);
//one channel 8bits values between 0 and 255
IplImage *gray = cvCreateImage(cvSize(loader.width,loader.height), IPL_DEPTH_8U, 1);
//one channel 32bits values between 0.0 and 1.0
IplImage *corners = cvCreateImage(cvSize(loader.width,loader.height), IPL_DEPTH_32F, 1);
IplImage *dilatedCorners = cvCreateImage(cvSize(loader.width,loader.height), IPL_DEPTH_8U, 1);
//convert to grayScale
cvCvtColor(colorImg.getCvImage(), gray, CV_BGR2GRAY);
cvPreCornerDetect( gray, corners, 7 );
cvDilate(corners,corners,0,1);

//convert from float do unsigned int by multiplying every falue by 255
cvConvertScale( corners, dilatedCorners, 255 );
cornersImg = dilatedCorners;
}

void testApp::draw(){
colorImg.draw(20,20);
cornersImg.draw( colorImg.width + 40, 20 );
}

the final result is the following application:

corners

Note that to convert an ofxCvColorImage to IPLImage we use setFromPixels, to convert an IPLImage to grayscale or color we use cvCvtColor, and to convert the type of the image from IPL_DEPTH_8U to IPL_DEPTH_32F and vice-versa we use cvConvertScale. To convert from IPLImage to ofxCvColorImage the image must be in the IPL_DEPTH_8U format with 3 channels, and just use “=”.

Some OpenCv functions require that the image to be in 32 bit float format. For further information read the OpenCV reference. There is no need to include additional files, OpenFrameworks already includes the OpenCV headers.