Log in

View Full Version : OpenCV on Raspberry Pi - where is CV2?


David Lame
21-07-2016, 22:57
I was running OpenCV on a Raspberry Pi for some off season programming, and it was all well and good, when suddenly, it stopped working. After some troubleshooting, I determined it was actually a bad SD card. Losing data. Grrr....

No problem, though. New SD card. Format. Install OS. Install OpenCV (in a virtual environment.....good idea? ...the guy who wrote the tutorial seemed to think so...) .Run script, and it can't find CV2. Import cv2 fails in the script because it can't find cv2. It found numpy, but not cv2.

Hmmmm......what's up with that? After trying lots of ideas, it still can't find CV2. Well, I hadn't done python except on the pi, so eventually I decided to find out how import worked, and point to the right place so it can find cv2. Here's where my problem comes in.

Where is CV2? What am I looking for? I've got a directory called opencv-3.1.0 . That directory has a lot of stuff in it, but it doesn't have a file name or a directory named cv2, or cv2.py.

I've figure out some things about some environment variables and the python path and such, so that if I could find the directory where cv2 was located, I think I could import it, but I can't find it.

Does anyone know what I ought to be looking for?

JamesBrown
22-07-2016, 08:37
Install OpenCV (in a virtual environment.....good idea? ...the guy who wrote the tutorial seemed to think so...)

Did you follow the tutorial on pyimagesearch.com? If thats the case I suspect you missed or had an error on Step 10 of this tutorial http://www.pyimagesearch.com/2015/02/23/install-opencv-and-python-on-your-raspberry-pi-2-and-b/

euhlmann
22-07-2016, 08:51
sudo apt-get install python-opencv

David Lame
22-07-2016, 23:34
Did you follow the tutorial on pyimagesearch.com? If thats the case I suspect you missed or had an error on Step 10 of this tutorial http://www.pyimagesearch.com/2015/02/23/install-opencv-and-python-on-your-raspberry-pi-2-and-b/

Thanks. It wasn't that exact step, but it was closely related. I was doing the pi 3 installation instructions. It turns out the reason that I couldn't find the thing named cv2 was that there's a problem with the python 3 installation script which misnames the file. Adrian's instructions tell you what file to rename, but I didn't execute the step where it was called out.

Much appreciated.