is there any way to enable user to select file manually using GUI in my cpp console application with OpenCV? I've made some research but found no solution for such trivial task so far...
Thanks in advance, JP
For this, you have to add any available gui library and handle the gui part with that keeping the image processing part to opnecv. ( For example, you can try Qt )
If you want to a simple file open dialog in Ubuntu, you can do this:
FILE *in;
if (!(in = popen(
"zenity --title=\"Select an image\" --file-selection",
"r"))) {
return 1;
}
char buff[512];
string selectFile = "";
while (fgets(buff, sizeof(buff), in) != NULL) {
selectFile += buff;
}
pclose(in);
//remove the "\n"
selectFile.erase(std::remove(selectFile.begin(), selectFile.end(), '\n'),
selectFile.end());
// path + filename + format
Mat image = imread(selectFile);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With