Ask Your Question

YKC's profile - activity

2016-10-18 05:27:00 -0600 commented question How to open a video stream

hi Thanks for your reply. I still can't open the video using openCV. I just can view it in web browser.

Actually, can openCV open MPEG1 format video? since the video is encoded to MPEG1. Thanks

2016-10-17 23:32:49 -0600 asked a question How to open a video stream

I am trying to open the video being streamed from Intel Edison which is written in node.js. ffmpeg is used to encode video to MPEG1 whereas jsmpeg is used to decode the video. The video is rendered onto canvas element in the web browser.

The coding as follow. I can't view the video in openCV.

int main()  
{  
  VideoCapture vcap1;

   Mat stream1;
   Mat grains(480,640,CV_8UC3,Scalar::all(0));
   const string videoStreamAddress1 = "http://192.168.8.100:8082";
vcap1.set(CV_CAP_PROP_FOURCC, CV_FOURCC('P','I','M','1'));

 if(!vcap1.open(videoStreamAddress1)) {
    cout << "Error opening video stream1" << endl;
    }  
   if(!vcap2.open(videoStreamAddress2)) {
    cout << "Error opening video stream2 " << endl;
    }

   for(;;){   
     if(!vcap1.read(stream1)) {
         putText(grains, std::string("Stream  not avilable....."), cv::Point(150,200),  cv::FONT_HERSHEY_COMPLEX_SMALL, 1, cv::Scalar(0,255,0,255));
         imshow("Stream 1", grains);
     }
     else
      imshow("Stream 1", stream1);

if(waitKey(33) >= 0) break;
     }  
    return 0;
}