Reputation: 1547
I am trying to create a simple image processor in opencv. I so far have experimented to open a set image from file with this code.
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
using namespace cv;
using namespace std;
int main()
{
Mat im = imread("c:/image.jpg");
if (im.empty())
{
cout << "Cannot load image!" << endl;
return -1;
}
imshow("Image", im);
waitKey(0);
}
As this only allows a set image file to be open, how could i modify it so it allows the user to select an image?
Is this possible or can i only load a set image from file?
Thanks.
Upvotes: 1
Views: 9174
Reputation: 3767
If you want your program to run in console only, let the user to input the path of the image file ( or may be using command line arguments).
If you want to make it GUI application, (some fancy window will show up when you click a "Open File" button ) then you have to learn some GUI programming. Choose some GUI programming tool depending on your platform ( Windows, Linux etc) or go for cross platform ( Give a try to Qt )
Upvotes: 5