English 中文(简体)
开放式录像机和录像机在窗户上不打开正确的照相机。
原标题:OpenCV and Qt VideoCapture does not open the correct camera on windows

我正在使用开放式和Qt来制定申请。 在申请中,我正在制作一个记录视像的小工具。 由于这一原因,并且不阻止主要活动,我设立了单独方言,其中包括一个记录线。 在对开车者来说,我只想看到相机产出(我尚未采用记录法)。 因此,以下功能为:

void VideoRecordThread::run(){
    cv::VideoCapture capture;
    cv::Mat frame;
    QImage img;

    qDebug() << "Opening camera" << cameraIndex ;
    capture.open(cameraIndex);

    if(!capture.isOpened()){
        qDebug() << "Could not open camera" << cameraIndex;
        emit threadReturned();
        return;
    }

    while(!stopFlag){
        capture >> frame;
        qDebug() << "Frame Width = " << frame.cols << "Frame Height = " << frame.rows;
        if(frame.cols ==0 || frame.rows==0){
            qDebug() << "Invalid frame skipping";
            continue;
        }
        img = cvMatToQImage(frame); //Custom function
        emit imageCaptured(img);
    }
    capture.release();
    emit threadReturned(); //Custom signal
    qDebug() << "Thread returning";
}

问题在于,当线开始时,我会获得新的方言,要求我在选择一个相联的照相机时选择照相机,有时会奏效,有时甚至没有。 下面是我听到的辩词:

“entergraph

对我能做些什么帮助?

问题回答

我注意到,当某些职能没有从主线上执行时,开放式中心就存在问题。

将捕捉程序的最初化到你申请的主线,留待您的二读。 初始化部分似乎是:

cv::VideoCapture capture;

qDebug() << "Opening camera" << cameraIndex ;
capture.open(cameraIndex);

if(!capture.isOpened())
{
    qDebug() << "Could not open camera" << cameraIndex;
    emit threadReturned();
    return;
}




相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?

热门标签