March 31, 2009 was our first night of combining the OpenCV Study Group with a weekly Maker’s Night Out session in the CCCKC Underground Lab. We changed things up for the OpenCV session with a presentation by Amith about fundamentals of image processing. He uses these techniques every day for medical imaging research.

Amith gave a brief comparison of medical imaging in a 3D environment using voxels where the 2D environment uses pixels to represent images. I’ve started reading the book Non-Photorealistic Rendering where a 3D model is used to represent surface textures of drawing materials in pencil sketches, pen and ink, and painting methods. Voxels are used there to simulate voids in the drawing surface where the art medium is deposited.

Amith spent a few minutes talking about video compression techniques and how a frame is displayed showing the entire image while subsequent frames only show changes from the previous frame, these are called P-Frame and I-Frames. The I-Frame or Intraframe is also called a keyframe and contains the entire image. The P-Frame is a predictive frame that only contains the changed data. A couple of nights earlier I came across a great example about How to Datamosh that plays with combining two video segments when most of the I-Frames are removed.

He also gave an overview of filters used in image processing and touched on a few filtering methods. For our next OpenCV session he would like to give some demonstrations of what various filters provide. As a challenge we are looking into methods of being able to use an image to identify coins and denomonations of coins.

Makers Row

Jestin was showing some of his recent work in OpenCV using color correction and filters to display live video. I had the prototype of a project I’m calling a Refrigerator Art Machine designed to capture artwork using OpenCV.

Others were busy tonight working on various Maker projects and crafts.

Recommended Equipment and Materials

We suggest you bring the following items with you to the study group sessions:

Computer

Webcam

Learning OpenCV book

Try to come prepared with programming tools installed for your chosen operating system(s). If you’re planning to attend and having trouble getting everything installed leave a message in the CCCKC Google Groups or KCRS OpenCV forum ahead of time and maybe someone can help you. Don’t forget the Yahoo Technical Group and the OpenCV Wiki for support issues. Bring your book if you have one, otherwise you can probably share.

Lets try to get our equipment working so we can run the sample programs and discuss topics from Chapters 2 and 3 of the Learning OpenCV text. You can download the sample programs free of charge.

Book Options For Learning OpenCV

The Learning OpenCV book uses the same policy as the OpenCV library. The sample files are free for commercial or research use. O’Reilly would appreciate you referencing the book when using the example programs in your work. To find information about the book and download the sample files go to: http://oreilly.com/catalog/9780596516130/ then click on Examples link.

Buying books gets expensive. O’Reilly offers a couple of alternatives. You can download an Ebook version for about $10 less than the paperback price. O’Reilly publishes a number of technical books of interest to programmers. Another alternative you can choose is their Safari Books Online option. This service requires a monthly fee. A limited free trial offer is available if you are undecided about this option.

More Linux Setup Tips.

If you’re new at using Linux you may want to install Cheeze or Camerama to check and see if your webcam is working properly.

More Windows Setup Tips.

I’m planning on using Microsoft Visual C++ Express Edition instead of Eclipse to avoid some setup issues. You are free to use any IDE you choose, the Microsoft toolset is my personal preference at this time. You can download a free copy from the MSDN Visual C++ Developer Center.

Why study computer vision / image processing programming?Our study group started after Jestin and I got one of our labyrinth board games hooked up to an Arduino with servos to adjust the board game’s surface. Jestin’s version is using a Nintendo WiiFit running Ubuntu Linux so you move around on the platform to make the marble move through the maze. Mine is just using an XBox360 controller in Windows.

After getting the board game to work, the next logical thing to do would be to attach an accelerometer to the bottom of the board and place a video camera above to watch the marble move. We want to use the video to locate the marble through motion detection, ultimately getting the computer to play the game for us so we can set back and watch.

Why study OpenCV?There are other vision processing options which are home-grown, supported by a niche group, or have specific features. OpenCV has an active Yahoo Group that hopefully provides a good support role as we learn to program its features. The DARPA Grand Challenge winner Stanley is reported to use OpenCV as part of its navigation capabilities and robot vision is definately one of our interests. OpenCV comes with example programs to easily begin facial detection. All in all it just looks like a good place to start with a lot of potential for future enhancement.

The list of tutorials is a random collection and not placed in any significant order. It would be great if we could rate the tutorials showing how useful you think they are. If you find other useful tutorials that aren’t on the list please leave a comment so I can add them.

This will also work with some modification under Visual C++ 6.0 and Visual C++ 2005, 2008 Express Edition.

Creating a Project With Visual C++
Make sure you aren’t mixing C character strings with Unicode strings

The OpenCV library uses the standard pointer to char array for text strings. I started a new program using Visual C++ and it was using Unicode character strings by default.

int _tmain(int argc, _TCHAR* argv[]){ return 0;}

A quick way to switch to using standard character strings is by changing the main function statement to:int main(int argc, char* argv[]){ return 0;}
Possibly the better way to handle this is to convert from unicode to character strings before calling the OpenCV functions.

Visual C++ libraries.
Make sure the library, include, and source file paths are included on the property page.

Programming with C#
Take a look at the opencvsharp Google Code site.OpenCvSharp, a wrapper of OpenCV for .NET Frameworkcode.google.com/p/opencvsharp
I tried downloading the help file from there but got error messages when trying to access the help pages: “Navigation to the webpage was canceled.” and “The address is not valid”. I left an issue report on that site.
To download their source code use an SVN system to check out the code

Problems Opening Video Files
Example 2-2 in the book is about viewing AVI video. It uses the cvCreateFileCapture function.
I found a couple of video files on the computer. A file captured from a Logitech web camera in .wmv format and some files from my cell phone stored in .mp4 format.Wikipedia definition of AVI definition for the AVI acronym is Audio Video Interleave.