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