问题
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