OpenCV的FrameGrabber的输出图像不正确 [英] OpenCV's FrameGrabber's Output Image is Incorrect

查看:906
本文介绍了OpenCV的FrameGrabber的输出图像不正确的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个依赖于手指检测的OpenCV项目。目前我有一个 OpenCVFrameGrabber ,它抓取一个帧并将其放在 IplImage 中。然后我将该图像绘制到我的GUI上。

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?

推荐答案

我最近开始玩JavaCV,我总是试图避免这些新课程并坚持使用原始OpenCV方法。

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);
}

如果这样可行,您的问题可能与有关OpenCVFrameGrabber 。如果没有,您可能想用另一台相机试验您的代码。

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

这篇关于OpenCV的FrameGrabber的输出图像不正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆