Archivo de la categoría: Computer Vision

Compiling and Installing HandVu on Linux

HandVu

On this tutorial we will cover the compilation from sources of HandVu beta 3 and its compilation and installation on Ubuntu 10.04 LTS (Lucid Lynx).

1. Download the package

$ wget http://www.movesinstitute.org/~kolsch/HandVu/handvu-beta3.tar.gz

2. Uncompress the package

$ gunzip -c handvu-beta3.tar.gz | tar xopf -

3. Enter the directory

$ cd handvu-beta3

4. Configure for make

$ ./configure

5. Make

If we execute make command some errors will appear. These errors could be:


error: 'ULONG_LONG_MAX' was not declared in this scope
error: 'INT_MAX' was not declared in this scope

error: 'alloca' was not declared in this scope
error: 'strlen' was not declared in this scope
error: 'strcpy' was not declared in this scope
error: 'strtok' was not declared in this scope
error: 'strrchr' was not declared in this scope

error: 'atof' was not declared in this scope

error: 'memset' was not declared in this scope

So let’s add some lines of code

to cubicles/IntegralFeatures.cpp

#include <alloca.h>
#include <limits.h>

to cubicles/IntegralFeaturesSame.cpp

#include <alloca.h>

to cubicles/CascadeFileParser.yy

#include <string.h>

to cubicles/Scanner.h

#include <limits.h>

to cubicles/IntegralImage.cxx

#include <string.h>

to handvu/Mask.cpp

#include <alloca.h>
#include <stdlib.h>
#include <string.h>

to handvu/FileHandling.cpp

#include <string.h>

on this last file we also need to change a pair of lines, otherwise the following error will appear:


error: invalid conversion from 'const char*' to 'char*'

on handvu/FileHandling.cpp change from this:

char* slashpos = strrchr(path, '/');
char* dotpos = strrchr(path, '.');

to this:

const char* slashpos = strrchr(path, '/');
const char* dotpos = strrchr(path, '.');

Now we can execute make

$ make

6. Intall

$ sudo make install

We are done!

Blessings!

Anuncios

OpenCV 2.1 on NetBeans on Windows

OpenCV

NetBeans

First of all, try no to use Windows.

1. Make sure you got the following installed

  • C:\OpenCV2.1
  • C:\MinGW
  • C:\msys

2. Right click on your project and click in Properties and complete the following:

Build » C++ Compiler
   » Include Directories » C:/OpenCV2.1/include/opencv

Build » C++ Compiler » Include Directories » C:/OpenCV2.1/include/openc

   » Linker
      » Additional Library Directories » C:/OpenCV2.1/lib
      » Libraries » cv210.dll, cvaux210.dll,
                    cxcore210.dll, highgui210.dll

Build » Linker

3. Build your project.

Executable (*.exe) file will be generated and located in your project directory on the following path: dist/Debug/MinGW-Windows/

Use this simple code to test your recently set environment:

#include "highgui.h"

int main(int argc, char** argv){
   IplImage* img = cvLoadImage(argv[1]);
   cvNamedWindow("ImgViewer", CV_WINDOW_AUTOSIZE);
   cvShowImage("ImgViewer", img);
   cvWaitKey(0);
   cvReleaseImage(&img);
   cvDestroyWindow("ImgViewer");
}

OpenCV » Update the Slider Position

OpenCV: Open Computer Vision Library

I am currently making some research on OpenCV to accomplish some knowledge necessary for working on Computer Vision and lately on Gesture Recognition.

The book i am reading now is Learning OpenCV (Computer Vision with the OpenCV Library) by Gary Bradski & Adrian Kaehler

On Chapter 2: Introduction to OpenCV there are some samples. Second Program is about Playing AVI Video with OpenCV. And Third Program is about move around quickly within the video. We can read these on page 21:

* This code does not update the slider position as the video plays; we leave that as an exercise for the reader.
Also note that some mpeg encodings do not allow you to move backward in the video.

That exercise is relative simple so this is the code i propose:

#include "cv.h"
#include "highgui.h"

int			g_slider_position = 0;
CvCapture*	g_capture			= NULL;

void onTrackbarSlide(int pos) {
   cvSetCaptureProperty(
      g_capture,
      CV_CAP_PROP_POS_FRAMES,
      pos
   );
}

int main (int argc, char** argv) {
   cvNamedWindow("AviPlayer", CV_WINDOW_AUTOSIZE);
   g_capture = cvCreateFileCapture(argv[1]);
   int frames = (int) cvGetCaptureProperty(
      g_capture,
      CV_CAP_PROP_FRAME_COUNT
   );
   if(frames!=0){
      cvCreateTrackbar(
         "Position",
         "AviPlayer",
         &g_slider_position,
         frames,
         onTrackbarSlide
      );
   }
   IplImage* frame;
   while(1){
      frame = cvQueryFrame(g_capture);
      if(!frame) break;
      
		double newpos = cvGetCaptureProperty(g_capture, CV_CAP_PROP_POS_FRAMES);
      cvSetTrackbarPos("Position", "AviPlayer", newpos);
      
      cvShowImage("AviPlayer", frame);
      char c = cvWaitKey(33);
      if ( c == 27 ) break;
   }
   cvReleaseCapture(&g_capture);
   cvDestroyWindow("AviPlayer");
   return(0);
}

References:
cvGetCaptureProperty: Gets video capturing properties