OPENCV absolute path input format when opening an image or video

Source: Internet
Author: User

There are several ways to open an image or video in OpenCV, the most commonly used1, just enter the file name and suffix name when you need to open the files stored in the project file under the Test folder, just enter the file name and suffix name, bloggers in this reminds beginners, must pay attention to the suffix problem, I have eaten a lot of losses, an effective way is to add a verification process, as shown in the following code: Mat Image = Imread ("Pp.jpg", 0);
if (Image.empty ())
 {                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
cout << "Error";
return-1;
}
cout << "image size:" << image.rows << "<< image.cols << Endl; 2, absolute path when the need to open files in their own designated folder (preferably without Chinese path, you know) will use the absolute path, here need to pay attention to the absolute path of the format problem. cannot be used when pasting directly from the address bar. such as: Videocapture Capture ("E:\zipai.wmv");.the correct format is: Videocapture Capture ("e:\\zipai.wmv"); I don't know if you see the difference. When your files are stored in the test folder, you want to use absolute path open in two ways, the first is the full path mentioned above, the second is a simple path: /zipai.wmv. Note the direction of the previous two point and slash.
using an absolute path should also add a validation project to avoid errors 

OpenCV Absolute path input format when opening an image or video

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.