c++ - Unable to play video in opencv3? -




here code. unable play video file in opencv3.3. beginner opencv. please me.

int main(void) { cv::videocapture capvideo;  cv::mat imgframe;  capvideo.open("c:\\users\\sbv\\documents\\myvideo.avi");  if (!capvideo.isopened())  {                                                      std::cout << "\nerror reading video file" << std::endl << std::endl;           _getch();                        return(0);          }  if (capvideo.get(cv_cap_prop_frame_count) < 1) {     std::cout << "\nerror: video file must have @ least 1 frame";     _getch();     return(0); }  capvideo.read(imgframe);  char chcheckforesckey = 0;  while (capvideo.isopened() && chcheckforesckey != 27) {      cv::imshow("imgframe", imgframe);      if ((capvideo.get(cv_cap_prop_pos_frames) + 1) < capvideo.get(cv_cap_prop_frame_count))              {             capvideo.read(imgframe);                               }     else              {              std::cout << "end of video\n";              break;                                                   }      chcheckforesckey = cv::waitkey(1);               }  if (chcheckforesckey != 27) {                    cv::waitkey(0);                                  }     return(0); } 

error coming :

error reading video file.

please solve issue.

the problem quite clear capvideo.open("c:\users\sbv\documents\myvideo.avi");

you try open myvideo.avi in path:

c:\\users\\sbv\\documents\\myvideo.avi 

but file not exist @ path.

quick fix: work in cygwin

capvideo.open("c:/users/sbv/documents/myvideo.avi"); 

or put myvideo.avi in same directory program.





wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -