Ubuntu compiler error: Unable to open 'raise.c'

Creative Commons License Copyright: Attribution, allow others to create paper-based, and must distribute paper (based on the original license agreement with the same license Creative Commons )


Summary: File Path File not found error caused


I. Description of the problem:

Document:

1.jpg and Try.cpp in HelloOpencv directory.
Here Insert Picture Description

Try.cpp

#include<opencv2/opencv.hpp>
using namespace cv;
int main()
{
    Mat srcImage=imread("1.jpg");
    imshow("Origin",srcImage);
    waitKey(0);
    return 0;
}

1.jpg

Here Insert Picture Description

Compilation failed

Here Insert Picture Description

the reason:

It can not find 1.jpg. The current path prefix is ​​the outermost directory, the directory that is under the Main, but also in 1.jpg into a layer that HelloOpenCV in.

Second, the solution

1. moved out of the picture 1.jpg

Here Insert Picture Description

2. Use an absolute path

Right picture, copy absolute path (Copy Path)
Here Insert Picture Description

Guess you like

Origin blog.csdn.net/sandalphon4869/article/details/94414412