"In the world ye shall have tribulation: but be of good cheer; I have overcome the world." –John 16:33

San Pedro Garza Garcia

Tag: PySide

More C++, Python, PySide, SWIG, OpenCV and an early Christmas gift

We received a great Christmas gift last night. The big, big boss of our company in Sydney (not just the big boss from Prescott) wrote a letter and gave us an extra five days of vacation over the holidays because we had such a tough year and because of some health issues in our new executive team. The reality is that no one has taken much of a vacation over the last two years and most of us have worked just about every weekend. It will be nice to spend a couple of unfettered weeks with the family.

Just as good, I have been put on a project that involves writing programs in two different languages using a couple of libraries I really like in both of those languages.

“Why two languages?” you ask.

Well, C++ is a language that is very good for doing things very efficiently and effectively, but that can really get you in trouble if you do not know what you are doing. Well written C++ code generally runs much faster than code written in higher level languages like Python. It lets you do just about anything you want and does not provide any restrictions with respect to leaking memory or jumping off into areas of memory that are totally unrelated to what you are doing. Python is a great language for people who are not so comfortable with the freedom of C++. It also allows user to write a lot of functionality fast and has lots and lots of add-on libraries to do lots and lots of things easily.

I normally use C++ because of the need for speed. Other members of my team need to use my code in programs they can develop rapidly for use in scientific experiments and production code for the instruments we make. So, we have decided that I will write my machine vision code in C++, then wrap it up in a Python wrapper using a tool called SWIG. All the tools I normally use in C++ to build GUI’s (Qt) and perform image processing tasks (OpenCV) are available in Python as libraries. The Qt libraries we use are called PySide and the OpenCV libraries are just called Python OpenCV.

I have set up my environment so that whenever I write a C++ library, the Python wrapped results are automatically built and stuck into the correct directory for use by the rest of the team. In addition, when I build a GUI with Qt Designer, I can run a batch file that turns the C++ code into a Python program. I have to do a little merging with that if I change the GUI, but it is all quite painless. I think I might write up what I have done and post it here. I am sure I have some inefficiencies and someone might be able to make some suggestions.

Betty Blonde #219 – 05/19/2009
Betty Blonde #219
Click 
here or on the image to see full size strip.

No Shave November (more than Movember), Python, C++, PySide and SWIG

What you see below is a little program I have worked on over the last week or so. It does not look like much, but there is quite a bit under the hood. The GUI is built with something called PySide which is an open source version of the wonderful C++ Qt libraries in a Python wrapper. It is amazing how easy it is to use. I knew nothing about it less than a week ago. In addition, I built a C++ capture library based on OpenCV (I will switch to camera specific libraries when we decide what camera we want to use for our project). I then used SWIG to add a Python wrapper around the library. I write this, not because I think it is particularly interesting to anyone, but because I am having a great time learning some new things, there appears to be a lot more coming and it will be good to remember what a good time I had doing it a few years from now.

You might notice that I got a little jump on No Shave November. I decided to go with the beard, partly because I have been away from home quite a bit over the last month, so Lorena has not been able to wrestle me down and shave it all off. If I can just last until Thanksgiving…

Python/C++ GUI for Machine Vision Development

Betty Blonde #212 – 05/08/2009
Betty Blonde #212
Click 
here or on the image to see full size strip.

Programming Python (again)

I have been given a project at work to write a program to control a camera, some motors and I/O and perform some machine vision. That is pretty much what I do anyway, but the high level parts of the project are to be developed in Python with the low-level, “need to go fast” parts to be written in C/C++ with a Python wrapper. I am going to be able to develop some new skills and play with some new toys, but will have to slow down my Our Homeschool Story posts a bit. I hope to keep going but not a post a day, at least for awhile.

Betty Blonde #207 – 05/01/2009
Betty Blonde #207
Click 
here or on the image to see full size strip.

Powered by WordPress & Theme by Anders Norén