Can't access image (.jpeg) folder in main() using OpenCV
-
Hi it seems like in main() I can't access the image folder using OpenCV functions even though OpenCV libraries are linked correctly and the folder path is right. How can I fix it?
int main(int argc, char *argv[]) { vector<cv::String> fn; cv::glob("/home/csimage/project/images/*", fn, false); vector<cv::Mat> imagesResized; size_t count = fn.size(); for (size_t i=0; i<count; i++) { //resize images to the same size cv::Mat dst; cv::Mat src =cv::imread(fn[i]); cv::resize(src,dst,cv::Size(20,20)); imagesResized.push_back(dst); } //I GET THE FIRST ERROR HERE WHEN IT TRIES TO READ THE IMAGES cv::Mat inputImage=cv::imread("/home/csimage/project/church.JPEG"); vector<cv::Mat> imageTiles= split(inputImage,40,40); cv::Mat matchingImage; vector<cv::Mat> final; for ( int i=0;i<imageTiles.size();i++) { matchingImage=comparer(imageTiles[i],imagesResized); final.push_back(matchingImage);} cv::Mat image_collage= imageCollage(final,40,40); imshow("Image collage",image_collage); cv::waitKey(0); return 0; }4
-
Hi
Are you sure the file extension is JPEG with big letters ?Also you dont mention what error you get?
-
@mrjj Just the c++ file with the program which is supposed to be a photo collage , not the qt part. I fixed the .pro file for one library name was spelled wrong sorry about that, and now it works but I only get an empty MainWindow
and the result should be this ( it's the same code)
-
@georgiav said in Can't access image (.jpeg) folder in main() using OpenCV:
I had the problem with linking the libraries before and it's been solved,
What "has been solved"?
I don't have errors like 'Mat object undefined'
No, instead you have "undefined reference" at link time on some cv functions.
and the paths should be fine as the same program works fine when run from a shell
What program? The errors show that you cannot link the executable. So no "program" is being generated in this build. If you have something you linked before, you have some other (successfully-linked, maybe library search path was different, or other difference) executable elsewhere, not the one not-generated from this link.
-
Isn't there a forum for OpenCV out there? Or what is the relation to Qt here?
-
@Christian-Ehrlicher since the program works fine using just OpenCV and it doesn't work when trying to run it in QT I thought it's more likely to be a Qt problem rather than an Opencv one. Maybe there are specific things to add in the .pro file or other settings I'm not aware of since I'm new to Qt.
-
@mrjj Hi, I think those were the mainwindow.cpp and mainwindow.h files that were already there when I created the project but I didn't add anything in them so I just removed them and tried to run again and now I get this :
but unfortunately I don't understand where those errors come from
-
@georgiav said in Can't access image (.jpeg) folder in main() using OpenCV:
Since the program works fine using just OpenCV and it doesn't work when trying to run it in QT I thought it's more likely to be a Qt problem rather than an Opencv
Your code does not use any Qt class at all...
-
@Christian-Ehrlicher I'm trying to create a GUI for my program but first the c++ program should run fine , right?
-
Hi
I wonder if you need to link additional libs
besides opencv_core
like opencv_imgcodecs