Ask Your Question
0

im a beginner of opencv. plz help me

asked 2017-09-12 08:22:23 -0600

i've just installed opencv 3.3 ver and visual studio 17

whenever i run this code

include "cv.hpp"

include "iostream"

using namespace std; using namespace cv;

int main() {

Mat img;

img = imread("lena.png", 1);
if (img.empty())
    return -1;

imshow("img", img);


waitKey();
return 0;

}

a gary window advent but disappear without displaying lena.png.

i read others' code. some write namedWindow. others don't

but their results are same.

what is problem?? code ?? or settings?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2017-09-12 08:40:09 -0600

berak gravatar image

updated 2017-09-12 08:49:36 -0600

"what is problem?? " -- your image was not loaded (path problem ?) , and the program returned -1.

(your code assumes, the image is in the same folder, where your program starts. if you started your prog from the ide, it will start from the debug (or release) folder, NOT from your project folder)

edit flag offensive delete link more

Comments

thanks for replying. i placed lena.png on right forder where the project is. so if i add namedWindow statement it works right

small_but_strong gravatar imagesmall_but_strong ( 2017-09-12 08:53:34 -0600 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2017-09-12 08:22:23 -0600

Seen: 71 times

Last updated: Sep 12