OpenCV

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Not applicable
Hello everybody


This is going to be a collective Thread. I´m going to present to you different [HowTo´s] in order to work with your Raspberry Pi 2 and OpenCV.
For this reason, I´d kindly ask you to be patient, I´ll be publishing all information in different Posts.

If you have any questions, please use the PM-System. I´ll try to answer all your questions as soon as possible.

[HowTo] Install OpenCV on the Raspberry Pi 2 B Model


I know there are a lot of HowTo´s on this topic on the web. However, most of them require compiling the source-files on your own. A task, that takes a lot of time, effort and patience.
As some teams will use a Raspberry Pi 2 / Pi 3 in combination with the XMC4500 for the object-detection, I´ve decided to show how it is done the "lacy"-way:

Requirments:
- Raspberry Pi 2 running Raspbian
- connection to the internet on the Raspberry Pi
- some experience using the terminal and the 'nano'-Editor


Pre-Installation Duties
Befor installing opencv and its dependencies, make shure your entire system is up-to-date.
sudo apt-get update

sudo apt-get ugrade

sudo rpi-upgrade




Installation
The easiest way is to go with the apt-get-thing
sudo apt-get install libopencv-dev python-opencv


This installs all dependencies required to work with OpenCV in C/C++ or PYTHON.
That was all the magic :p.

EDIT: This is taken from http://milq.github.io/install-opencv-ubuntu-debian/
0 Likes
1 Reply
Not applicable
[HowTo] Use OpenCV with a PiCam NoIR

I know there are again hundrets of tutorials around this topic. As I mentioned befor, I´ll show you the "lacy"-way without compiling anything ect.

Requirments:
- Raspberry Pi 2 running Raspbian
- a Keyboard, Mouse and Screen connected to the Raspberry Pi 2 (in the further course RPi2)


Pre-Installation Duties:
As in the Post above please enshure that your system is up-to date. For this, please refer to the previous post (section is named the same).

Configuration:
Once the system is up and running, open a terminal (shell). Run the following command:
sudo raspi-config


The following Screen should come up:
2198.attach
Select Option "5 Enable Camera"
You should now be asked if you want to enable the PiCam on the RPi2:
2199.attach
Once enable leave the raspi-config. When leaving you might be asked to reboot.

After Reboot run the following command in the terminal:
sudo modprobe bcm2835-v4l2


A classy note of mine:
Insert this line into a shell-script and make it executable. It´s not realy a driver that you start, I´ll just call it that way. The correct description would be kernel-module.
nano InitPiCamDriver.sh

Insert the line and with STRG+X save changes and close.
Make it executable:
sudo chmod +x InitPiCamDriver.sh

OpenCV offers the isOpened()-method. With the help of this method it should be easy to detect wether the driver is running or not.

Last Step is to include the PiCam into your OpenCV Code:

int main()
{
VideoCapture cap;
Mat frame;

cap.open(0);

while(1)
{
cap>>frame;
imshow("Original-Image", frame);

waitKey(30); // this is extremly important, otherwise there is now time to grab the next frame and display it to the screen.
}
}


Have fun!
0 Likes