Project/Framework/OpenCV

OpenCV

Operating System Mac OS X v10.5.7

Installation

  1. First of all, install  macports
  2. Next, install the following packages...
    • opencv
    • cmake
    • isightcapture
    • playerstage-stage
    • playerstage-player
  3. Test the camera...
    % isightcapture /tmp/test.png
    

Camera/OpenCV Integration

// Take from...
//   Gray Bradski and Adrian Kaelher, "Learning OpenCV: Computer Vision
//   with the OpenCV Library", O'Reilly Media Inc., 2008.
//   ISBN: 978-0-596-51613-0
//   Example 2-9, p. 27

#include <opencv/highgui.h>
#include <cvblob.h>

int main(int argc, char** argv) {
  IplImage *frame; 
  
  CvBlobs blobs;
  
  cvNamedWindow("BenderCam", CV_WINDOW_AUTOSIZE);
  CvCapture *capture;
  if (argc == 1) capture = cvCreateCameraCapture(0);
  else capture = cvCreateFileCapture(argv[1]);
  assert(capture != NULL);
  
  while(1) {
    frame = cvQueryFrame(capture);
    
    if( !frame ) break;
    cvShowImage("BenderCam", frame);
    char c = cvWaitKey(10);
    if(c == 27) break;
  } 
  cvReleaseCapture(&capture);
  cvDestroyWindow("BenderCam");
  
  return 0;
} 

Proof-of-Concept Code

Blob Detection and Tracking



References