Patrick222122
Posts: 80
Joined: Sun Dec 02, 2012 5:51 pm

using python with opencv

Thu Mar 07, 2013 6:33 pm

I have successfully gotten my pi to communicate with a propellor chip by adapting some python code for doing the same with an Arudino. Phase two is to set up computer vision using open cv. Are there any particularly good threads relating to doing this in python or tutorials on other websites?

KenB
Posts: 11
Joined: Mon Mar 04, 2013 6:06 pm

Re: using python with opencv

Fri Mar 08, 2013 10:04 am

I've been using something called SimpleCV which is basically OpenCV but translated from C/C++ (don't know the proper technical term) into Python. It is pretty powerful and you can find some pretty good tutorials out there.

I'd recommend checking out the book they've written for a nice introduction to all you can do.

Patrick222122
Posts: 80
Joined: Sun Dec 02, 2012 5:51 pm

Re: using python with opencv

Fri Mar 08, 2013 11:35 am

Can it do everything that normal open cv can do and also I don't know how to uninstall programs on the pi. Please advise.

ghans
Posts: 7882
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany

Re: using python with opencv

Fri Mar 08, 2013 11:47 am

You might have a look at this :

http://simplecv.tumblr.com/post/1930783 ... s-simplecv

I never worked with any of these frameworks , but the SimpleCV
guy is selling his software well.

ghans
• Don't like the board ? Missing features ? Change to the prosilver theme ! You can find it in your settings.
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org

KenB
Posts: 11
Joined: Mon Mar 04, 2013 6:06 pm

Re: using python with opencv

Fri Mar 08, 2013 6:07 pm

Patrick222122 wrote:Can it do everything that normal open cv can do and also I don't know how to uninstall programs on the pi. Please advise.
I think there might be some limitations but that is just an ignorant guess. What do you want to do?

You'll need to have your Pi connected to the internet to install things (this way atleast) To install SimpleCV on the pi type the following into the terminal

Code: Select all

sudo apt-get install python-opencv python-scipy python-numpy python-pip
Once that's done type in

Code: Select all

sudo pip install https://github.com/ingenuitas/SimpleCV/zipball/master
I got the instructions from the following book, which I highly recommend if you want a nice basic tutorial of SimpleCV and using it on the Pi.

http://shop.oreilly.com/product/0636920023371.do

Patrick222122
Posts: 80
Joined: Sun Dec 02, 2012 5:51 pm

Re: using python with opencv

Fri Mar 08, 2013 10:30 pm

my ultimate hope is to run object and facial recognition algorithms on the pi, but at the moment I would settle for color recognition and blob tracking, however I already have installed opencv last week. How would I go about removing it if necessary?

KenB
Posts: 11
Joined: Mon Mar 04, 2013 6:06 pm

Re: using python with opencv

Fri Mar 08, 2013 10:48 pm

Yeah SimpleCV can do all that. There's no need to uninstall anything. In fact I think SimpleCV may need OpenCV libraries.
I've done stuff with still images, just be aware that you won't get a good frame rate with the Pi doing complex computer vision.
Even with a basic webcam viewing software called luvcview I only get 3fps at 320x240 resolution.

ghans
Posts: 7882
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany

Re: using python with opencv

Sat Mar 09, 2013 8:14 am

If you were able to use the camera module ,
the dedicated hardware support should make
it able to run the camera at 30 FPS. But the
CPU of the PI is still slow , so the question remains
if it can do analysis in realtime.

ghans
• Don't like the board ? Missing features ? Change to the prosilver theme ! You can find it in your settings.
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org

Patrick222122
Posts: 80
Joined: Sun Dec 02, 2012 5:51 pm

Re: using python with opencv

Sun Mar 17, 2013 8:36 pm

I've decided to use opencv after all. However I have not found one thing in the documentation that I need for my project. I need to know at least roughly the location of a blob or detected object in a frame. Do any of you know how to do this? Please note I have to use python for this project do some issues using other languages to communicate with a microcontroller.

badook
Posts: 43
Joined: Sun Dec 16, 2012 7:44 pm

Re: using python with opencv

Mon Mar 18, 2013 8:42 am

Depending on what kind of object you are trying to recognize there are several algorithms and implemented solutions available on-line.
  • - Checkerboard detection
If you are using a usb webcam with the pi, you shouldn't expect high framerates, even at the lowest resolutions available.

Patrick222122
Posts: 80
Joined: Sun Dec 02, 2012 5:51 pm

Re: using python with opencv

Sat Mar 23, 2013 1:45 pm

I think i found a way around the problem in previous post, the answer was right there in the facial detection sample, just needed to use the X value of the detected object and the rest was easy. However I do have another problem. Would the haar algorithm be appropriate for detecting an object that is not a face. I am asking for another of things I want my robot to do, besides detecting and being attracted to faces, is to steer clear of my cat. What do you think?(Do note that I do realize I will have to create my own HAAR cascade to do so.)

Patrick222122
Posts: 80
Joined: Sun Dec 02, 2012 5:51 pm

Re: using python with opencv

Sat Mar 23, 2013 1:56 pm

disregard that last post I had no clue that creating a HAAR file was such a intense process.

Patrick222122
Posts: 80
Joined: Sun Dec 02, 2012 5:51 pm

Re: using python with opencv

Sat Mar 23, 2013 9:31 pm

Doe anyone know what to make of this error message?
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
from SimpleCV import Shell
File "/usr/local/lib/python2.7/dist-packages/SimpleCV/Shell/__init__.py", line 1, in <module>
from Shell import *
File "/usr/local/lib/python2.7/dist-packages/SimpleCV/Shell/Shell.py", line 54, in <module>
raise(e)
ImportError: No module named IPython
I tried to use SimpleCV to reduce the complexity of my code and got this. Please help!

ghans
Posts: 7882
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany

Re: using python with opencv

Sat Mar 23, 2013 10:23 pm

Did you follow the installation instructions ?
IPhython seems not to be installed.

ghans
• Don't like the board ? Missing features ? Change to the prosilver theme ! You can find it in your settings.
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org

Return to “Python”