OpenCV's FrameGrabber's Output Image is Incorrect

一曲冷凌霜 提交于 2019-12-10 11:54:53

问题


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?


回答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.



来源:https://stackoverflow.com/questions/13383802/opencvs-framegrabbers-output-image-is-incorrect

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!