open window to choose images c++ - c++

I am using c++ in ubuntu 12.04 using gcc. Am trying to perform few image processing tasks using opencv. For this, I want the user to select an image. Is it possible to open the directory explorer through c++, and let user choose the image, by selecting folders or drives, etc.? I actually did not know how to google this question exactly, my apologies if this is pretty rudimentary. Your help is much appreciated. Thanks in advance

You will want to use a GUI toolkit like Qt. They ususally have some sort of function for what you want. In the case of Qt the QFileDialog would be good.
For learning Qt: There are official tutorials or maybe this question.
If you want to go down this route you can also use a completely separate program just for getting a file name. Something like zenity maybe. Which platform do you want to do this on?

Related

Connecting C++ and Node JS

I have been working on a project where I am interacting with a 3D camera(on a single machine) through its SDK written in C++. The extent of my knowledge in that language is just as good as what a basic crash course could teach. I need to provide an interface(web) which shows the camera preview from the SDK and when the capture image is clicked, I need to capture an Image using the SDK with a specified filename and path.
The approaches I thought of are:
Using NodeJS exec to capture images the compiled version(exe) of my program in C++. I am communicating the filepath and using json.
I could learn and use C++ CGI to simply control C++ SDK stuff.
Any help/suggestions would be greatly appreciated. Thanks in advance.
You can use one of the C++ CGI libraries out there but, as easy as they are to use, just calling an executable seems easier and cleaner. I think the scanner should come with a bundled tool to drive it, doesn’t it?

How do you open a windows application as a source for OpenCV?

I would like to recognize objects of windows applications, mainly computer games. I would like to accomplish this by opening the window in OpenCV and applying all kinds of effects to the game application under execution and recognize objects such as UI elements, messages and even characters that are on the screen.
Since OpenCV only allows video and webcam as input, is there a way to open a running application as a source for OpenCV?
There maybe some testing applications used in game development that use similar methods for testing, but I couldn't find any.
I also don't know the right terms that that are used when discussing the recognition of virtual objects of a computer program or computer game, but that is exactly what I would like to do.
I tried to look up forums, articles or anything written about this, but found nothing. Any help would be appreciated.
I used OpenCV for a year and I am not sure if you can pass the running application to it.
As an alternative, you might like to have a function which gives you the current screenshot of the desktop. So you can get it and pass to OpenCV.
This way you can periodically do screenshots and use your recognition.
If you are working under Windows you might need this discussion.
Hope this will somehow help you.
I've been trying all method using desktop as source in opencv few months ago as my experiment project and i success, but there's a trail inside the windows, as maybe the speed or processor depends on it. It using your own function to use desktop as source not from opencv libraries. And from there i continued custom things and got stuck in some bug that has something from memory, as it use lots of memory. I did post on stackoverflow. Hope this information helps.

Using c++ how to show overlay icon in finder mac osx

Recently we developed a MAC installer(.dmg). This is developed in c++ and QT. We had a hard requirement to show overlay icons on the files in the finder like how CVS/Dropbox shows sync status on files.
My question is exactly similar to below post. I understand that, if we try to show overlay icons in finder, MAC app store doesn't allow my app to be there. I am fine with this, my users will download the app from the website.
How can i add icon overlay in finder?
Am pretty much new to MAC and c++ also, Can you please provide me suggestion or solution in c++ in detailed.
I know this answer is somewhat late, but better than no answer, isn't it?!
Dropbox uses an open source framework called mach_inject. Originally developed by Jonathan Rentzsch, and known as Mach_Star, it allows code injection into applications.
Dropbox use this to inject into the OSX Finder application. If you Google for "Dropbox mach_inject" you'll find various references to this. Although it's not exactly what you want, there's also a project here which also injects into Finder, but to add menu items. You should be able to use that as reference.

Help Integration in Qt/C++ Application

I am using Qt 4.6 so do C++.
I have a User Manual (.chm) for my application which has the help required for the users to run the application. Now I want this help to be integrated into my application, so that when the user selects for help from the application, the user manual will be opened with the corresponding help page displayed. In this way I can make use of the already available manual and users will find easy to probe through the document. (since it is familiar)
The user manual file is in the .chm format which has corresponding search keywords, which can be used to display the corresponding page when selected from the application. Just similar to F1 help in any of the windows application.
Is it possible to do this in Qt or C++? Or
What are the other ways through which the help can be integrated in the application?
Any pointers regarding this are welcome..
Yes, it's possible. The help system infrastructure was designed to integrate with normal Win32 development in Visual Studio, but this is not technically necessary. Basically you just call HtmlHelp(GetDesktopWindow(), "Yourhelp.chm", HH_HELP_CONTEXT, IDYourCurrentContext);.
The more Qt way of Help Integration can also be done which is as follows.
The chm files are always opened by the hh.exe
So,
QProcess::execute("hh.exe D:/Manual.chm");
can be used to open the Manual.chm file from the application.
The command
QProcess::execute("hh.exe D:/Manual.chm::page1.htm");
will open the chm file with the page1.htm loaded. This will be helpful to load a specific help page in the chm file.
The only thing we must be aware in this approach is that we must have known the file name of the web pages (here page1.htm) previously..
Hope this one also helps... :)
QDesktopServices::openUrl() would be even more Qt way. Then you do not need to specify hh.exe but rely instead on the system file associations to use proper application. Hence - portability, the key thing behind Qt stuff.
try using libCHMxx or CHM lib along with Qt help system (see this sample)

How do I open a Open File dialog in OS X using C++?

I'm working on an application using OpenGL and C++ that parses some structured input from a file and displays it graphically. I'd like to start an Open File dialog when the application loads to allow the user to choose the file they want to have displayed. I haven't been able to find what I need on the web. Is there a way to achieve this in C++? If so, how? Thank you in advance.
You have two choices, a quick one, and a good one:
Quick and pretty simple, use the Navigation Services framework from Carbon and NavCreateGetFileDialog(). You'll be done quick, and you'll have to learn almost nothing new, but your code won't run in 64-bit (which Apple is pushing everyone towards) and you'll have to link the Carbon framework. Navigation Services is officially removed in 64-bit, and is generally deprecated going forward (though I expect it to linger in 32-bit for quite a while).
A little more work the first time you do it (because you need to learn some Objective-C), but much more powerful and fully supported, wrap up NSOpenPanel in an Objective-C++ class and expose that to your C++. This is my Wrapping C++ pattern, just backwards. If you go this way and have trouble, drop a note and I'll try to speed up posting a blog entry on it.
To add to what Rob wrote:
Unfortunately, there's no simple equivalent to Windows's GetOpenFileName.
If you use Carbon: I don't really think NavCreatGetFileDialog is easy to use... you can use this code in the CarbonDev to see how to use it. The code there returns CFURLRef. To get the POSIX path, use CFURLGetFileSystemReprestnation.
That said, I recommend you to use Cocoa. Rob will write a blog post how to use NSOpenPanel from GLUT :)