Ask Your Question
0

is there a way to read an image directly from a directory (not passing arguments)?

asked 2020-03-11 18:45:26 -0600

fabianc20 gravatar image

updated 2020-03-11 21:32:32 -0600

supra56 gravatar image

HI all I have been trying ro read an image: see theses 2 lines. But I just don get it. If I use arguments then I can, but, what I need is to get it directly from the folder. Please your adivise Thanks.

#include <opencv2/core.hpp>
using namespace cv;

#include <iostream>
using namespace std;

int main()
{
    //Mat left = imread("C:\\Users\\Fcastro\\source\\repos\\pose\\cbimages\\0_degrees.pgm");
    Mat left = imread("C:/Users/Fcastro/source/repos/pose/cbimages/0_degrees.pgm");
    imshow("Left Image View", left);
    getchar();
}
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2020-03-13 18:45:50 -0600

fabianc20 gravatar image

updated 2020-03-13 21:35:54 -0600

supra56 gravatar image

Wierd and creepy, all I did, change getchar() for waitKey() and it worrks!. So main goes this way...

int main()
{
    Mat left = imread("C:\\Users\\Fcastro\\source\\repos\\pose\\cbimages\\0_degrees.pgm");
    imshow("Left Image View", left);
    waitKey();
}
edit flag offensive delete link more

Comments

2

It is good that it works, but this has nothing to do with reading the file... You could (and should) verify the result of imread without viewing the image. (As for the title of the question... arguments are clearly passed...)

mvuori gravatar imagemvuori ( 2020-03-14 04:06:28 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2020-03-11 18:45:26 -0600

Seen: 227 times

Last updated: Mar 13 '20