Hello all, sorry for bothering you.
I have been trying over the last two days or so to get OpenCV up and running on my Raspberry Pi for a motion detection project I am working on. There are plenty of great resources that I have stumbled upon for this, but many of them are outdated or conflicting and I have found myself with a bookmark folder full of dead-ends and a Pi filled with broken libraries and outdated git downloads. (For example, I spent a few hours trying to get Pierre Raufasts' and Emil Valkov's older MMAL libraries running before discovering the addition of our newer v4l2 driver.)
Can anyone give me a short list of steps for this installation, or an updated link to check out the play-by-play of OpenCV installation?
If I am putting 2 and 2 together correctly, I think I might need to:
*Start a New Raspbian installation
*Update the Firmware to access the v42l driver
*Run the code listed Here. (although this has not worked for me yet)
*Use make to build the latest version of OpenCV (Not quite sure how to get it on the Pi to do so. I think the apt-get opencv is 2.3.1 and thus not useable?)
--Also heard this takes a few hours to build. That's fine with me if it ensures I am able to get this running!
*Determine the install locations of these things and how to include them in a Makefile?
Sorry, I'm sure that little list there must be a pain to read. I've been working with the Pi off and on, but I think waveform80's Python Picamera library has spoiled me a little bit. It is fantastic, but not quite what I need to do this more complex motion-based job, unfortunately.
Thanks in advance for any help.
-
- Raspberry Pi Engineer & Forum Moderator
- Posts: 10530
- Joined: Wed Dec 04, 2013 11:27 am
- Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.
Re: Installing OpenCV with Pi Cam Board Compatability
Yes, update the Pi with sudo rpi-update first.
Ignore the stuff on the V4L2 thread for now - you only need it once you have the OpenCV library built.
Instructions for building OpenCV on the Pi - http://www.raspberrypi.org/forums/viewt ... 38#p527385
Instead of the wget, I'd recommend you do
instead to get the absolute latest and be able to update easily.
When building OpenCV I found it best to reduce the amount of RAM given to the GPU, otherwise memory got very tight and started throwing random errors. I think it was about 4 hours to compile (I left it overnight). I'd also suggest you DON'T start X and just run the build from the command line to save more memory whilst compiling.
Reboot.
to load the V4L2 driver.
startx, and then do stuff in OpenCV.
I used the code on http://www.raspberrypi.org/forums/viewt ... cv#p528389 as a start point - slap it in a text file, chmod 755 file, ./file did it for me and brought up a preview window. (Read the second page of http://www.raspberrypi.org/forums/viewt ... 38#p531638 for the discussions on latency. OpenCV can't keep up with V4L2, so dropping the framerate requested reduces it significantly).
Hope that helps.
Ignore the stuff on the V4L2 thread for now - you only need it once you have the OpenCV library built.
Instructions for building OpenCV on the Pi - http://www.raspberrypi.org/forums/viewt ... 38#p527385
Instead of the wget, I'd recommend you do
Code: Select all
git clone https://github.com/Itseez/opencv.git
When building OpenCV I found it best to reduce the amount of RAM given to the GPU, otherwise memory got very tight and started throwing random errors. I think it was about 4 hours to compile (I left it overnight). I'd also suggest you DON'T start X and just run the build from the command line to save more memory whilst compiling.
Reboot.
Code: Select all
sudo modprobe bcm2835-v4l2
startx, and then do stuff in OpenCV.
I used the code on http://www.raspberrypi.org/forums/viewt ... cv#p528389 as a start point - slap it in a text file, chmod 755 file, ./file did it for me and brought up a preview window. (Read the second page of http://www.raspberrypi.org/forums/viewt ... 38#p531638 for the discussions on latency. OpenCV can't keep up with V4L2, so dropping the framerate requested reduces it significantly).
Hope that helps.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.
I'm not interested in doing contracts for bespoke functionality - please don't ask.
-
- Posts: 177
- Joined: Tue Oct 16, 2012 3:03 pm
- Location: The East of England
Re: Installing OpenCV with Pi Cam Board Compatability
From the $ command line prompt I typed inKetta wrote:Can anyone give me a short list of steps for this installation, or an updated link to check out the play-by-play of OpenCV installation?
sudo apt-get install libopencv-dev python-opencv
You can also link OpenCV objects to the pi cam board with picamera
http://picamera.readthedocs.org/en
Re: Installing OpenCV with Pi Cam Board Compatability
Thanks for the tips! I'm working on 6by9's suggestion now. I'll see how that goes and report back in a few hours I guess.
Okay, one more question I guess. When running the commands suggested in that thread:
I get a LOT of 404 not found errors in the console output. Is this normal and expected for May 2014? I would assume it just means some of those libraries are deprecated or the like.
EDIT: OH, I didn't understand that "swig" was part of the same line entry. I'll start this step over again.
Okay, one more question I guess. When running the commands suggested in that thread:
Code: Select all
sudo apt-get install build-essential cmake pkg-config python-dev libgtk2.0-dev libgtk2.0 zlib1g-dev libpng-dev libjpeg-dev libtiff-dev libjasper-dev libavcodec-dev
EDIT: OH, I didn't understand that "swig" was part of the same line entry. I'll start this step over again.
Oh wow! I must have missed that part of the documentation before. I'll probably stick to C++ implementations for now as it is my primary language, but I'll be sure to keep that in mind in case I can adapt the Python library for a better solution down the road.BerryPicker wrote: You can also link OpenCV objects to the pi cam board with picamera
http://picamera.readthedocs.org/en
Re: Installing OpenCV with Pi Cam Board Compatability
Do run a
Most propably the info stored on your Pi on what is available in
the repos has become outdated , above command updates that.
ghans
Code: Select all
sudo apt-get update
the repos has become outdated , above command updates that.
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
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org
Re: Installing OpenCV with Pi Cam Board Compatability
Thanks ghans, I ran that command once I started over. Pretty easy to mess up the order of things when you are a Linux/RPi noobie.