Am I not cultured enough to learn OpenCV?

My recent visit to Chennai’s City Centre Mall changed my daily routine. I have a very bad habit of buying books whenever I stroll in to a bookstore to have a look. I visited the ubiquitous Landmark and my eyes struck a copy of “Learning OpenCV” by Gary Bradski and Adrian Kaehler.

I was educated about OpenCV quite a long time back but I never got an opportunity to get my hands on it. I bought this copy to realize my wishes. I have been struggling to write my “Hello World example” using the OpenCV libraries.

I hope you had read my earlier post on building the OpenCV library. I am a beginner in C++ programming and I felt it quite difficult to understand the arguments and commands used with the OpenCV library.

However, this tutorial by Gavin Page came to the rescue:

OpenCVTutorial_I

My new image read “Hello world!” Yupeee.

When I compiled my first code from the book, I was happy enough to press the “Start Debugging”

Now this was the error that I received 😦

I couldn’t understand what was going on.  The author has made a special mention that:

A proper program would check for the existence of argv[1] and, in its absence, deliver an instructional error message for the user. We will abbreviate such necessities in this book and assume that the reader is cultured enough to understand the importance of error handling code.

I was shocked to read this. Since I had a friend who is an expert in programming, he told me that that I am using a command line argument function

He told me that I either had to use a file pointer or a command prompt to execute the code correctly.

So I searched the web for this information and found that my friend was right. I had to go to the directory where my compiled exe file is located and pass the image file as an argument to the exe file.

This is how you are supposed to do it

>opencv.exe F:\affidavit.jpg

Bingo! I was able to load my image. Now, I wanted to load a video using the example from the book. I wasn’t cultured enough to understand the problem behind the code once again. The code execution was perfect but no video was loaded!

Google came to the rescue. This is what OpenCV wiki had to say.

You have to use tools like mencoder to convert the avi files into compatible formats.

This is the command I used for the mencoder.exe file

>mencoder.exe in.avi -ovc raw -vf format=i420 -o out.avi

Please note that the converted video is of a bigger file size.

After conversion, you may execute the converted file as follows:

>opencv.exe out.avi

I am worried about the n number of surprises that I would come across in the days to come 😦

Advertisements

One Response to Am I not cultured enough to learn OpenCV?

  1. jack bourque says:

    The mechatronics craze really is where many companies are now moving toward.

    I am seeing much more interest in engineers who have mechanical and electrical application experience. With the advent of new degrees combining mechanical engineering and electrical/electronics engineer, I believe that you will begin to see more international companies look for engineers who have worked on mechanical problems related to data communications and transmission. Recently we have seen three major companies in the USA who have a global footprint in communications products and systems reach out for mechanical engineering depth to balance the electrical (electronic) depth they have. The challenge right now is to find the kinds of engineers who go beyond an academic setting and have also practical work and application experience. So while companies know they need the creative academic side of R&D they also want the highly focused “D” side of that equation and are hiring people who have career experiences working in environments where there have been melding of electrical and electronics requirements with mechanical structures. Interesting future for students pursuing degrees that have mechatronics as a focus.

    Jack
    860-738-5035 ex: 23

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: