Use OpenCV to obtain PiCar MJPG-streamer video

asked 2017-08-23 14:04:22 -0600

Loyd gravatar image

updated 2017-08-23 14:06:25 -0600

I have built a SunFounder PiCar-V (Raspberry Pi 3 running Raspbian) which uses a Python server "running a software written for the MJPG-streamer project". I wish to capture the video stream with OpenCV 3.30 x64 in C++. Below is my test program which shows the result occurring.

// ============================================================================
// PiCarVideoTest - Testing how to use OpenCV to open PiCar video stream.
// Debug x64 version with property sheet: 
//    C++ - Additional Include Directories: $(OPENCV_BUILD)\include
//    Linker - Additional Library Directories: $(OPENCV_BUILD)\x64\vc14\lib
//    Linker - Additional Dependencies: opencv_world330d.lib;...
// Result of program - vcap.open fails:
//   warning: Error opening file(/build/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp:792)
//   warning: http://192.168.0.81:8080/?action=stream;dummy=param.mjpg (/build/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp:793)
// ============================================================================

#include <opencv2\opencv.hpp>
#include <opencv2\highgui.hpp>

using namespace cv;

int main(int, char**) {
    VideoCapture vcap;
    Mat image;

    // Setup video stream location per internet research results.
    const std::string videoStreamAddress = "http://192.168.0.81:8080/?action=stream;dummy=param.mjpg";

    // Open the video stream and check that open was successful.
    if (!vcap.open(videoStreamAddress)) {
        std::cout << "Error opening video stream or file" << std::endl;
        return -1;
    }
...

It appears OpenCV is attempting to treat the internet address as a file name. I have fought this problem for two days and have not been successful at solving it. Any help would be greatly appreciated!!

edit retag flag offensive close merge delete

Comments

Dumb, dumb, dumb me!!! Can you believe it was a typo!! The IP address should have been 192.168.1.81:8080 not 192,168.0.81:8080. I must have looked at that line a hundred times and never saw the error!! As a newbie, I can't answer my own question for another 23 hrs but thought I should do something to not waste people's time. Thanks all for your time.

Loyd gravatar imageLoyd ( 2017-08-24 14:13:30 -0600 )edit