我有一个覆盆子pi b用mjpeg-streamer上传视频流 .

在树莓派上

/usr/local/bin/mjpg_streamer -i "/usr/local/lib/input_uvc.so -y -r 340x240 -f 10 -d /dev/video0" -o "/usr/local/lib/output_http.so -w /usr/local/www"

这会创建一个可访问的视频流

http://10.1.111.150:8080/?action=stream

制作jpeg图像 - > Live stream on the firefox browser

现在,我想要做的是在Visual Studio 2013中使用OpenCV 3.0.0打开此流 .

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <iostream>

using namespace cv;
using namespace std;

int main(int argc, char* argv[])
{
    int q;
    VideoCapture cap; 

//cap.open(0) for internal camera
//
cap.open("http://10.1.111.150:8080/?action=stream");


if (!cap.isOpened())  // if not success, exit program
{
    cout << "Cannot open the video cam" << endl << "Press q to continue:";
    cin >> q;
    return -1;
}

double dWidth = cap.get(CV_CAP_PROP_FRAME_WIDTH); //get the width of frames of the video
double dHeight = cap.get(CV_CAP_PROP_FRAME_HEIGHT); //get the height of frames of the video

cout << "Frame size : " << dWidth << " x " << dHeight << endl;

namedWindow("MyVideo", CV_WINDOW_AUTOSIZE); //create a window called "MyVideo"
namedWindow("MyNegativeVideo", CV_WINDOW_AUTOSIZE);

while (1)
{
    Mat frame;
    Mat contours;

    bool bSuccess = cap.read(frame); // read a new frame from video

    if (!bSuccess) //if not success, break loop
    {
        cout << "Cannot read a frame from video stream" << endl;
        break;
    }

    flip(frame, frame, 1);
    imshow("MyVideo", frame); //show the frame in "MyVideo" window

    Canny(frame, contours, 500, 1000, 5, true);
    imshow("MyNegativeVideo", contours);

    if (waitKey(30) == 27) //wait for 'esc' key press for 30ms. If 'esc' key is pressed, break loop
    {
        cout << "esc key is pressed by user" << endl;
        break;
    }
}
return 0;}

这是一个示例代码,用于在我使用_1258053时在我的笔记本电脑上打开内部网络摄像头但是尝试从其地址 cap.open("http://10.1.111.150:8080/?action=stream"); 打开ip camera无法正常工作 .

UPDATE 我通过运行对RPi进行了一些更改

/usr/local/bin/mjpg_streamer -i "/usr/local/lib/input_uvc.so -y -r 340x240 -f 10 -d /dev/video0" -o "/usr/local/lib/output_rtsp.so -p /usr/local/www"

不同的是 output_rtsp.so -p

通过看起来网络摄像头(活动指示灯亮起)和在树莓派终端中运行的程序,我可以假设流正在工作 . 我无法通过浏览器确认这一点 .

运行

cap.open("rtsp://10.1.111.150:8080/?action=stream");

在openCV代码中不打开流 .

谁能告诉我哪里出错了?