views:

46

answers:

1

How I can filter video stream from camera in MacOS X. I write quicktime sequence grabber channel component, but it`s work only if app used SG API. If app used QTKit Capture the component is not worked.

Somebody know how I can implement it?

A: 

You could use OpenCV for video processing, it's a cross platform image/video processing library: http://opencv.willowgarage.com

Your code would look something like this:

CvCapture* capture = NULL;
if ((capture = cvCaptureFromCAM(-1)) == NULL)
{
    std::cerr << "!!! ERROR: vCaptureFromCAM No camera found\n";
    return -1;
}

cvNamedWindow("webcam", CV_WINDOW_AUTOSIZE);
cvMoveWindow("webcam", 50, 50);

cvQueryFrame(capture);

IplImage* src = NULL;
for (;;)
{
    if ((src = cvQueryFrame(capture)) == NULL)
    {
            std::cerr << "!!! ERROR: vQueryFrame\n";
        break;
    }

    // perform processing on src->imageData 

    cvShowImage("webcam", &src);

    char key_pressed = cvWaitKey(2);

    if (key_pressed == 27) 
       break;
}

cvReleaseCapture(&camera);

I had success using OpenCV on Mac OS X using cvCaptureFromCAM(0) instead of passing it -1. On linux, -1 seems to do Ok.

karlphillip