OpenCV video address and picture address notes
The map's address
These four lines of code all represent the path of 5 picture 52.jpg
Mat srcImage = imread("52.jpg");
Mat srcImage = imread("G:/Program/o_practice/o_practice/52.jpg");
Mat srcImage = imread("G:\\Program\\o_practice\\o_practice\\52.jpg");
Mat srcImage = imread("G://Program//o_practice//o_practice//52.jpg");
When the picture is at the same level as the project .cpp file, the picture name can be written directly in the brackets and quotation marks;
otherwise, the full address path must be written
As shown in the figure, the current project name is o_practice, and its .cpp file name is o_practice.cpp, which is the same as the picture 52.jpg in the o_practice folder directory
You can directly use Mat srcImage = imread("52.jpg");
(This is a normal practice project, so there are many files in the directory
and it is messy)
Video address
图片地址同样适用
These four lines of code all represent the path of the 2.mp4 file
//VideoCapture capture("2.mp4");
//VideoCapture capture("G:/Program/o_practice/o_practice/2.mp4");
//VideoCapture capture( "G:\Program\o_practice\o_practice\2.mp4");
VideoCapture capture("G://Program//o_practice//o_practice//2.mp4");
When the video is in the same level directory as the project .cpp file, the name of the video file can be written directly in the brackets and quotation marks;
otherwise, the full address path must be written
As shown in the figure, the current project name is o_practice, and its .cpp file name is o_practice.cpp, which is the same as the video file 2.mp4 in the o_practice folder directory
You can directly use VideoCapture capture("2.mp4");
(This is a normal practice project, so there are many files in the directory
and messy)
How to quickly open the catalog
In the VS programming interface, right-click the .cpp file and click "Open the folder where the file is located" in the drop-down menu to
quickly open the file
directory . At this point, you can copy the directory address by clicking the directory box with the mouse.
The difference between `` and'/' in the address
It should be noted that in this directory, the dividing character is ``, and it must be changed to'/' or'\' in the program;
Otherwise, the file cannot be read in "G:\Program\o_practice\o_practice"
Because the backslash \ is an escape leading character in C/C++/C#, for example, \n represents a newline.
In order to avoid ambiguity, the \ in the path must be //.
Regarding the difference between ``'/' and'', please refer to .
[https://blog.csdn.net/weixin_41937876/article/details/101101106;]