Freewind
Freewind

Reputation: 198318

VC++ 2010 express: How to make a image file output to the Debug directory when compiling?

I'm creating a simple "hello world" vc++/opencv project.

In my code, I want to read and display an image called "opencv.png":

int _tmain(int argc, _TCHAR* argv[])
{
    namedWindow( "show_image", WINDOW_AUTOSIZE );
    Mat src = imread( "opencv.png" );
    imshow( "show_image", src );
    char c = waitKey(0);
    return 0;
}

Then I put the "opencv.png" under the project root path. But I found when I compiling the project, the "opencv.png" won't be displayed.

In the "helloworld/Debug" directory, there are only 3 files:

helloworld.exe
helloworld.ilk
helloworld.pdb

I have to copy the "opencv.png" manually to "Debug". How to configure the project to let it copy the "opencv.png" to output dir when compiling?


Per James' answer, I think it's a little complicated. Is there any easier way, e.g. embed the "opencv.png" in the final exe file?

Upvotes: 0

Views: 360

Answers (1)

James McNellis
James McNellis

Reputation: 355177

You can create a Custom Build Step to perform the copy.

Alternatively, consider placing the image in some known location so that it does not need to be copied (e.g. in a TestData directory), or pass the path to the image via the command line (you can add arguments to the command line in the Debugging page of the project properties).

Upvotes: 1

Related Questions