2

I am designing a system using a Raspberry Pi (Model B - 512mb) that depends on OpenCV libraries for Haar-like feature detection, and fswebcam/gpio/libgphoto2. I need more speed than Python can offer.

My interface requires only text of different sizes and colours and rectangles. The image below shows a very rough paint mockup of the interface required.

enter image description here

I was able to produce the interface in half an hour using the PyGame engine, which runs at sufficient CPU requirements. I can also run the application from the terminal before startx, which runs great, with the Esc key set to exit the application.

I am not too keen to have the standard menu or minimise and exit controls that normal applications have, because this will run on a 5" display with no mouse.

I am looking for a solution like this that I can do with C++, or perhaps a good tutorial on a way to bridge python with C++. Will GTK suit my needs for this.

When using GTK, there are the following packages:

libgtk2.0-0        : GTK+ graphical user interface library
libgtk2.0-0-dbg    : GTK+ libraries and debugging symbols
libgtk2.0-0-udeb   : GTK+ graphical user interface library - minimal runtime
libgtk2.0-bin      : programs for the GTK+ graphical user interface library
libgtk2.0-common   : common files for the GTK+ graphical user interface library
libgtk2.0-dev      : development files for the GTK+ library
libgtk2.0-doc      : documentation for the GTK+ graphical user interface library

Which of these do I need to install to use GTK for this purpose, I would like to keep things as lightweight as possible? Is there another similar engine I can use for C++ like PyGame that may be better than GTK?

Note: This is a refined (yet related) post to the one I made on StackOverflow, which got no replies.

  • 1
    With such a simple interface, is it really worth even using a GUI? Unless you plan to dramatically improve upon the design and features of this GUI program, I would look into a command line interface. – syb0rg Aug 6 '13 at 15:21
1

It depends on what you want. Personally, I'm not a fan of GTK, but it is a viable option. Another would be Qt (pronounced cute). Personally, I prefer the look of it, it is truly cross-platform, and has a really nice designer suite and a python library.

Have you considered using a webpage as your application's interface? Python is capable of creating little mini web-servers so you wouldn't even really need Apache for something as simple as you described. If python is doing some of the legwork with your application anyway, it may be a fairly easy system.

As far as interfacing Python and C++ goes. I've never really found a better resource than it's own documentation. It is a fairly advanced processes, so just be forewarned (I don't know your skill level).

1

Pygame is built on SDL, which encapsulates openGL. This presumably works well on the pi since it has hardware support for OGL (more specifically, openGL-ES, which you should take note of, but I will not refer to the distinction any further). Generally in a linux context, SDL runs inside of the Xorg server, however, it can be run using the framebuffer. You imply that you have run pygame without X, so perhaps it is already set up for this.

GTK+ and Qt can also, apparently, be run on the framebuffer. Seeing as how you don't really need GL level graphics, they may be a better choice. OTOH, SDL will may allow you to customize the interface more.

Having not worked with the framebuffer, I can't say if it is significantly harder than just using X. Since SDL, GTK+, Qt, and so on are high level layers, most of the work should be exactly the same either way, and I'd approach this by doing the development in X and then figure out how to get it onto the framebuffer later.

There is a good chance the difference won't really matter anyway -- the X server sans desktop environment is a pretty lightweight thing. To run it without a DE, you need to create a ~/.Xclients, eg:

#!/bin/sh

midori

Now startx will present just a web browser and a mouse pointer: no extra workspaces, no taskbars, no menus, no other windows or options, no nothing. If you think your app is fine that way, GTK+ is probably a good choice. You can also create windows (as bare rectangles, etc) via Xlib directly, although this is not nearly as well documented as using a widget library like Qt or GTK+.

On linux, the native SDL, OGL, and GTK+ libraries have a C interface, but there are C++ wrappers, at least for GTK+: gtkmm; apt-cache search gtkmm will show you those. Presuming you want version 3, libgtkmm-3.0-dev should pull in all the packages you need to get going (except maybe gcc itself).

If you want to use SDL, the key package should be libsdl1.2-dev. Again, the interface is C, but will not pose any problems in a C++ context.

Qt is fundamentally a C++ API.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.