找到你要的答案

Q:Modifying a video stream in real time

Q:实时修改视频流

I need to access the pixel data from a video camera attached to my Windows PC in real time. Once accessed, I will modify it and output it as part of the video stream. In other words, I need to find the easiest way to modify a video stream in real time. I know about OpenCV and Matlab functionality, but I am wondering if anyone has found a simpler way to do this.

我需要访问连接到我的Windows PC的视频摄像头的像素数据实时。一旦访问,我会修改它,并输出它作为视频流的一部分。换句话说,我需要找到最简单的方法来实时修改视频流。我知道关于OpenCV和Matlab的功能,但我想知道如果有人发现了一个更简单的方式来做这件事。

answer1: 回答1:

If you want to do this with C++, OpenCV, as long as it works with your camera, is one of the simplest ways there is. The code below is from the OpenCV documentation VideoCapture. The only trick is instantiating the VideoCapture instance. How much simpler can it be?

#include "opencv2/opencv.hpp"

using namespace cv;
int main(int, char**)
{
    VideoCapture cap(0); // open the default camera
    if(!cap.isOpened())  // check if we succeeded
        return -1;

    Mat edges;
    namedWindow("edges",1);
    for(;;)
    {
        Mat frame;
        cap >> frame; // get a new frame from camera
        cvtColor(frame, edges, COLOR_BGR2GRAY);
        GaussianBlur(edges, edges, Size(7,7), 1.5, 1.5);
        Canny(edges, edges, 0, 30, 3);
        imshow("edges", edges);
        if(waitKey(30) >= 0) break;
    }
    // the camera will be deinitialized automatically in VideoCapture destructor
    return 0;
}

There is even a python version at Capture Video from Camera that looks very similar to the C++ version above.

如果你想做这个C++,OpenCV,只要它与你的相机,是一种最简单的方式有。下面的代码是从OpenCV的视频文件。唯一的诀窍是实例化的视频采集实例。可以简单得多吗?

#include "opencv2/opencv.hpp"

using namespace cv;
int main(int, char**)
{
    VideoCapture cap(0); // open the default camera
    if(!cap.isOpened())  // check if we succeeded
        return -1;

    Mat edges;
    namedWindow("edges",1);
    for(;;)
    {
        Mat frame;
        cap >> frame; // get a new frame from camera
        cvtColor(frame, edges, COLOR_BGR2GRAY);
        GaussianBlur(edges, edges, Size(7,7), 1.5, 1.5);
        Canny(edges, edges, 0, 30, 3);
        imshow("edges", edges);
        if(waitKey(30) >= 0) break;
    }
    // the camera will be deinitialized automatically in VideoCapture destructor
    return 0;
}

甚至在捕获视频从摄像机看起来对C++版以上的Python版本非常相似。

c++