The problems were not only about the import approach. Although I found I can import opencv.cv module, which looked similar to the so-called cv module, there had been other problems about the function names. I noticed that many functions given by the opencv.cv module have the ``cv'' prefix, while the same functions given directly by the cv module don't. For example, opencv.cv offers open.cv.cvSomeFunction() while in cv it is cv.SomeFunction(). Based on the observation, I suspected that my installation of OpenCV an/or Python bindings are not totally right.
So another solution searching journey begun, and I think I've got the right answers.
First, according to [1], I went to one of the OpenCV document pages, and it read:
You can not use the python-opencv package because he provide old python support. On Ubuntu, python bindings won't work.
Gosh, I had used the python-opencv package for weeks without knowing such a fundamental problem!
After reading the document page carefully, I install the OpenCV2.2 with the guidance given by Montabone. Make sure to have python-dev so that you can compile and have the most import thing -- cv.so.
Note that the cv.so will be in the site-packages directory which is not in the Python's searching path. You need to cp the cv.so to the dist-packages directory, that is:
$ sudo cp /usr/local/lib/python2.6/site-packages/cv.so /usr/local/lib/python2.6/dist-packages/cv.so
So far, I can use ``import cv'' in Python. That's great, but I've started to worry about my previous trials about the image processing with webcam... Orz
---
Ref:
[1] http://ubuntuforums.org/showthread.php?t=1500834
No comments:
Post a Comment