gr4gallery = Gallery in Python 2.7.10 + OpenCV 3.0.0 + Tkinter GUI

Hi there fellows, a project emerged from the need of using OpenCV with GUI possibilities larger than trackbar. I am currently keen on Python, but I didn't want to spend any time finding out how to make OpenCV + Python + Qt work, because the commercial licensing of Qt borthered me too much. Therefore I turned to the only other python GUI library I know so far the good ol' Tkinter.


Although I had a rough time finding how to make it work together, in the end I find some discussion where they had a simple example. The code took webcam video stream captured by OpenCV and transformed its image data to tkinter label background periodically by a little help of multiprocessing.

I think its not a clearest solution, but it works so I am trying to build my project on it. The code does not include the upper class, it was just a snippet and with my not so great knowledge of Python I was not able (after a boring half hour trying) to rewrite it to work. It was complaining about some Pickling problem when I tried to write it class style, so I stopped trying for now.

Instead I created a little demonstration program. It is essencially "a gallery" that is disk image browser with extra webcam snapshot capabilities. You can use all the mighty OpenCV functions to play with pictures and webcam stream and use the easy tkinter gui to make interactions with the user.

Webcam on the left, browsed folder in the middle and selected image on the right. Many of the label texts are confusing and the saving or loading may switch RGB and BGR channels.

Whole project created in Python with PyCharm as a devenv is accessible through git repository here:

The code is a mess as I wrote it in about 2 hours, but you'll get the idea how to fuse these tools together 😉

PS: If you happen to succeed in rewriting it into class please send it to me 😉

Napsat komentář

Vaše emailová adresa nebude zveřejněna. Vyžadované informace jsou označeny *