Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/154.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 哪个OpenCV';s功能是否支持模拟摄像机进行直播?_C++_Opencv - Fatal编程技术网

C++ 哪个OpenCV';s功能是否支持模拟摄像机进行直播?

C++ 哪个OpenCV';s功能是否支持模拟摄像机进行直播?,c++,opencv,C++,Opencv,哪个OpenCV的功能支持模拟摄像机进行直播 请给我答案 我尝试了OpenCV的CvCapture和VideoCapture功能。 它适用于USB摄像头,但不适用于模拟摄像头 我试过视频输入功能。它与模拟摄像机配合得很好,但我想要opencv内置功能。 所以请帮帮我。 谢谢你抽出时间 这是我使用的cvcapture函数的代码。 #include "stdafx.h" #include "cv.h" #include "cxcore.h" #include "highgui.h" #include

哪个OpenCV的功能支持模拟摄像机进行直播

请给我答案

我尝试了OpenCV的CvCapture和VideoCapture功能。 它适用于USB摄像头,但不适用于模拟摄像头

我试过视频输入功能。它与模拟摄像机配合得很好,但我想要opencv内置功能。 所以请帮帮我。 谢谢你抽出时间

这是我使用的cvcapture函数的代码。

#include "stdafx.h"
#include "cv.h"
#include "cxcore.h"
#include "highgui.h"
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
#include "videoInput.h"
#include <opencv2/imgproc/imgproc.hpp>

using namespace cv;
using namespace std;

char key;
int main()
{
    cvNamedWindow("Camera_Output", 1);    //Create window
    CvCapture* capture = cvCaptureFromCAM(CV_CAP_ANY);  //Capture using any camera              connected to your system
    while(1){ //Create infinte loop for live streaming

        IplImage* frame = cvQueryFrame(capture); //Create image frames from capture
        cvShowImage("Camera_Output", frame);   //Show image frames on created window
        key = cvWaitKey(10);     //Capture Keyboard stroke
        if (char(key) == 27){
            break;      //If you hit ESC key loop will break.
        }
    }
    cvReleaseCapture(&capture); //Release capture.
    cvDestroyWindow("Camera_Output"); //Destroy Window
    return 0;
}
#包括“stdafx.h”
#包括“cv.h”
#包括“cxcore.h”
#包括“highgui.h”
#包括
#包括
#包括
#包括“videoInput.h”
#包括
使用名称空间cv;
使用名称空间std;
字符键;
int main()
{
cvNamedWindow(“摄像机输出”,1);//创建窗口
CvCapture*capture=cvCaptureFromCAM(CV_CAP_ANY);//使用连接到系统的任何摄像头进行捕获
而(1){//为实时流媒体创建infinte循环
IplImage*frame=cvQueryFrame(捕获);//从捕获创建图像帧
cvShowImage(“相机输出”,帧);//在创建的窗口上显示图像帧
key=cvWaitKey(10);//捕捉键盘笔划
如果(字符(键)==27){
break;//如果按ESC键,循环将中断。
}
}
cvReleaseCapture(&capture);//发布捕获。
cvDestroyWindow(“摄像头_输出”);//销毁窗口
返回0;
}
代码结束

下一个代码正在使用视频输入功能。

#include "stdafx.h"
#include "cv.h"
#include "cxcore.h"
#include "highgui.h"
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
#include "videoInput.h"
#include <opencv2/imgproc/imgproc.hpp>

using namespace cv;
using namespace std;

char key;
int main()
{
    cvNamedWindow("Camera_Output", 1);    //Create window
    CvCapture* capture = cvCaptureFromCAM(CV_CAP_ANY);  //Capture using any camera              connected to your system
    while(1){ //Create infinte loop for live streaming

        IplImage* frame = cvQueryFrame(capture); //Create image frames from capture
        cvShowImage("Camera_Output", frame);   //Show image frames on created window
        key = cvWaitKey(10);     //Capture Keyboard stroke
        if (char(key) == 27){
            break;      //If you hit ESC key loop will break.
        }
    }
    cvReleaseCapture(&capture); //Release capture.
    cvDestroyWindow("Camera_Output"); //Destroy Window
    return 0;
}
代码为

#include "stdafx.h"
#include "cv.h"
#include "cxcore.h"
#include "highgui.h"
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
#include "videoInput.h"
#include <opencv2/imgproc/imgproc.hpp>

using namespace cv;
using namespace std;

int main(int, char**)
{
   videoInput VI;
    int numDevices = VI.listDevices();
    //int device1= 0;
    VI.setup(0);

    unsigned char* yourBuffer = new unsigned char[VI.getSize(0)];

    IplImage* colourImage = cvCreateImage(cvSize(320,240),8,3);

    while(1)
    {
        VI.grabFrame(0, yourBuffer);
        colourImage->imageData = (char*)yourBuffer;
        cvConvertImage(colourImage, colourImage, 3);

        cvShowImage("test",colourImage);

        if( cvWaitKey(10) == 27) 
            break;
    }
    return 0;
}
#include "stdafx.h"
#include "cv.h"
#include "cxcore.h"
#include "highgui.h"
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
#include "videoInput.h"
#include <opencv2/imgproc/imgproc.hpp>

using namespace cv;
using namespace std;

int main() {
VideoCapture stream1(-1);   //0 is the id of video device.0 if you have only one camera.

    if (!stream1.isOpened()) { //check if video device has been initialised
        cout << "cannot open camera";
        return 0;
    }

//unconditional loop
    while (true) {
        Mat cameraFrame;
        stream1.read(cameraFrame);
        imshow("cam", cameraFrame);
        if (waitKey(30) >= 0)
        break;
    }
    return 0;
}
#包括“stdafx.h”
#包括“cv.h”
#包括“cxcore.h”
#包括“highgui.h”
#包括
#包括
#包括
#包括“videoInput.h”
#包括
使用名称空间cv;
使用名称空间std;
int main(int,char**)
{
视频输入VI;
int numDevices=VI.listDevices();
//int device1=0;
六、 设置(0);
unsigned char*yourBuffer=新的unsigned char[VI.getSize(0)];
IplImage*colorImage=cvCreateImage(cvSize(320240),8,3);
而(1)
{
六、 抓取帧(0,缓冲区);
colorImage->imageData=(char*)缓冲区;
彩色图像(彩色图像,彩色图像,3);
cvShowImage(“测试”,彩色图像);
如果(cvWaitKey(10)==27)
打破
}
返回0;
}
代码结束

最后一个代码正在使用视频捕获功能

代码为

#include "stdafx.h"
#include "cv.h"
#include "cxcore.h"
#include "highgui.h"
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
#include "videoInput.h"
#include <opencv2/imgproc/imgproc.hpp>

using namespace cv;
using namespace std;

int main(int, char**)
{
   videoInput VI;
    int numDevices = VI.listDevices();
    //int device1= 0;
    VI.setup(0);

    unsigned char* yourBuffer = new unsigned char[VI.getSize(0)];

    IplImage* colourImage = cvCreateImage(cvSize(320,240),8,3);

    while(1)
    {
        VI.grabFrame(0, yourBuffer);
        colourImage->imageData = (char*)yourBuffer;
        cvConvertImage(colourImage, colourImage, 3);

        cvShowImage("test",colourImage);

        if( cvWaitKey(10) == 27) 
            break;
    }
    return 0;
}
#include "stdafx.h"
#include "cv.h"
#include "cxcore.h"
#include "highgui.h"
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
#include "videoInput.h"
#include <opencv2/imgproc/imgproc.hpp>

using namespace cv;
using namespace std;

int main() {
VideoCapture stream1(-1);   //0 is the id of video device.0 if you have only one camera.

    if (!stream1.isOpened()) { //check if video device has been initialised
        cout << "cannot open camera";
        return 0;
    }

//unconditional loop
    while (true) {
        Mat cameraFrame;
        stream1.read(cameraFrame);
        imshow("cam", cameraFrame);
        if (waitKey(30) >= 0)
        break;
    }
    return 0;
}
#包括“stdafx.h”
#包括“cv.h”
#包括“cxcore.h”
#包括“highgui.h”
#包括
#包括
#包括
#包括“videoInput.h”
#包括
使用名称空间cv;
使用名称空间std;
int main(){
VideoCapture stream1(-1);//0是视频设备的id。如果只有一个摄像头,则为0。
如果(!stream1.isOpened()){//检查视频设备是否已初始化
cout=0)
打破
}
返回0;
}
代码结束


请帮助我。< /P>请分享1)你的模拟相机输出是如何进入你的计算机2)的视频输入代码,3)你尝试用OpenCV尝试你想要的东西的例子。实际上视频输入与模拟相机很好地配合,但是我想用C++来实现GUI的目的,所以我得到了错误。在我的qt项目中包含videoInput.lib文件,这就是我搜索OpenCV内置函数的原因。谢谢你的回复。很好的更新。我在python中使用opencv,因此没有尝试过您的代码。请解释在这两个OpenCV示例中不起作用的地方。谢谢您的回复。事实上,我想做一个应用程序,将能够记录实时流模拟摄像机与GUI。为GUI的目的,我使用QtCreator。所以videoInput库与模拟摄像机配合良好,opencv的内置功能不支持模拟摄像机,所以我必须使用videoInput库,videoInput库是第三方库,它不是opencv的内置库,所以我必须将其包含在我的项目中。我已成功地将其包含在我的visual studio项目中,并且它正在工作很好。但是现在为了GUI的目的,我必须在我的QtCreator项目中包括videoInput库。我已经尝试了很多,但无法成功运行我的Qt creator项目。在包含videoInput库的过程中,它给了我不同的错误。这就是为什么我要搜索支持模拟摄像机的opencv内置库。