0

I am working on an OpenCV project that relies on finger detection. Currently I have an OpenCVFrameGrabber that grabs a frame and places it in an IplImage. I then draw that image onto my GUI.

This all works, but the image that is drawn seems to be in black and white even though I have a color camera. There are noticeable vertical lines in the image and when there is some color, it seems to be split into components along these lines.

Does anyone know of a way to get the original webcam image?

NGLN
  • 43,011
  • 8
  • 105
  • 200

1 Answers1

1

I recently started playing with JavaCV and I'm always trying to avoid this new classes and stick with the "original" OpenCV methods.

I suggest you try the following code and make sure that the most simple capture procedure works:

public static void main(String[] args) 
{
    CvCapture capture = cvCreateCameraCapture(0);
    if (capture == null)
    {
        System.out.println("!!! Failed cvCreateCameraCapture");
        return;
    }

    cvNamedWindow("camera_demo");

    IplImage grabbed_image = null;

    while (true)
    {
        grabbed_image = cvQueryFrame(capture);
        if (grabbed_image == null)
        {
            System.out.println("!!! Failed cvQueryFrame");
            break;
        }                    

        cvShowImage("camera_demo", grabbed_image);
        int key = cvWaitKey(33);
        if (key == 27)
        {
            break;
        }
    }

    cvReleaseCapture(capture);
}

If this works, your problem might be related to OpenCVFrameGrabber. If it doesn't, you might want to experiment your code with another camera.

karlphillip
  • 92,053
  • 36
  • 243
  • 426
  • Thanks! That worked fine. I guess the class either does not work straight of the box or there are additional parameters that I am missing. – user1172354 Nov 28 '12 at 08:09
  • It actually was a problem with the gui I created to display the result. It seems to be a problem with the IplImage.copyTo method. – user1172354 Nov 28 '12 at 08:13