OPENCV read camera without reading frame rate

Source: Internet
Author: User

Today in the camera read Video lab found that the original read the file based on directly modified Veidocapture capture ("string") for Vediocapture capture (0) Although the compilation can be successful, but the video can not read normally (card at the first frame , or cannot be opened).

Videocapture Capture (0);//Note here the    //Verify that the video is turned on successfully    if(!capture.isopened ()) {return 1; }//Get frame rate    //double fps = capture.get (cv_cap_prop_fps);    BOOLStopfalse); Mat frame;//Current video frameNamedwindow ("Show");//The delay time for each frame is the same as the frame rate    //int delay = 1000/fps;    //Iterate through each frame     while(!stop) {if(Capture.read (frame)) {//medianblur (frame, frame, 3);Imshow ("Show", frame);//waitkey (+);}Else             Break;if(Waitkey ( -) >=0) {stop =true; }    }//Close fileCapture.release ();

After consulting the data found that the problem in the Waikey () function of the delay parameter, when reading the file delay is the video file frame interval, which can be obtained from the video file information (through the Get function). However, when using the camera, this information is not available (or can not be obtained in time), so the program does not work properly, we only need to give delay to an empirical constant, as shown in the code above.

In this statement: I am also a beginner, this is only one of my experience, if there is not right, look at the great God advice, thank you!

OPENCV read camera without reading frame rate

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.