"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: SWIG

Programming and comic strips: An example

Kelly has decided she wants to start drawing her comic strip again as she has time. You can see an example of what she did before at the bottom of this post. She is going to do something different now, but plans to do a four panel strip like before. I wrote up some code to accumulate the hand draw single panels, add titles, copyright notices, borders, etc, and then post the results to our website. I could easily dust off the old code and use it again for her current efforts, but have decided to try to rewrite it as a way to improve some new skills on which I am working.

The idea will be to write a series of blog posts on how to set up an environment to write low level code that needs to go fast in C++ and the GUI and everything else in Python. I plan to talk about how I use Qt Creator, OpenCV, SWIG, PyCharm, PySide, some batch files, and a merge tool to automate this and make it easier. I am at the beginning of another series called Our Homeschool Story that I will also continue, but this is a very different thing that will provide some variety. I hope to start sometime over Christmas break.

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

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.

Getting out the product

The small team of engineers with whom I work spent last week, the entire weekend and yesterday putting the final touches on two of the retinal imaging cameras we designed so they can be shown at a conference in Colorado starting tomorrow. Everyone who has done real engineering has participated in this type of sprint to the finish. Really, I do not get a lot of satisfaction out of my work unless I get to do something like this a couple of times per year. We worked 16 hour days and barely made it, but the cameras will do well at the show.

The times when I work hard like this are the times I remember and cherish most about my work life. These times are when big advances are made in product understanding and, more importantly, lasting friendships are built. I love that. At the same time, now we are all completely fried. One of the guys took the day off. I am going to work on my really fun programming project (cameras, Python, SWIG and C/C++) and get back to blogging. We will have to work hard until Christmas, then take it up again for a rush to another product milestone in March, then it will be on to a new product for me.

So, that is why I have missed a few days of blogging. I hope to continue my Our Homeschool Story tomorrow.

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

Powered by WordPress & Theme by Anders Norén