Monday, July 23, 2007

My Experience with OpenCV 1.0 + Ubuntu 6.10 - UPDATED

With the help of my awesome brother, I figured out what causes the segmentation fault.

Apparently (as I feared), my whole OpenCV installation is messed up. My recent installation of OpenCV 0.9.7 got mixed up with my earlier OpenCV 1.0. So I had to remove my 0.9.7 (using the Package Manager -- since I installed it using the Package Manager) and uninstall OpenCV 1.0 using make uninstall from the directory where I extracted the OpenCV-1.0.0.tar.gz. Now that I had it cleaned out, this time I re-installed OpenCV 1.0.

To be safe, I used the steps described (once again) in the OpenCV wiki but this time I put the install directory in my home/*myusername* directory -- my profile directory.

./configure --prefix=/home/*myusername*/opencv/1.0.0/
make
make install

In addition to that, i set the LD_LIBRARY_PATH with the directory where my OpenCV library files are located, in this case: /home/*myusername*/opencv/1.0.0/lib

export LD_LIBRARY_PATH=/home/*myusername*/opencv/1.0.0/lib

I didn't have anything in my LD_LIBRARY_PATH before that, so the above is enough. But if I already have something, I want to make sure I don't screw up the existing paths, so I have to include the current paths by adding :${LD_LIBRARY_PATH} at the end. The colon ":" tells bash that whatever comes after it is another path; in this case, is whatever is inside the current LD_LIBRARY_PATH -- that's why I need to use "$" and the curly brackets to indicate the variable name "LD_LIBRARY_PATH".

export LD_LIBRARY_PATH=/home/*yourusername*/opencv/1.0.0/lib:${LD_LIBRARY_PATH}

Now, compile my loadimage.cpp program using the same g++ command as before:

g++ loadimage.cpp -o loadimage -I /home/*myusername*/opencv/1.0.0/include/opencv/ -L /home/*myusername*/opencv/1.0.0/lib -lhighgui -lcv -lml

Yay! It works! The picture showed up, and there was no segmentation fault. *phew* My head was already about to explode trying to figure out how to make this work.

Then, trying the inversion tutorial, and the facedetect (included in OpenCV installation) everything works! Yay! Now I can go on and play around some more. Now I just need to figure out how to use this to detect poses...

1 comment:

Unknown said...

thank you for help me
I had same problem to you.
((The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support)
in function cvNamedWindow, window.cpp(71)
Terminating the application...
)
I pay one day to solve this.
thank you very much