Raspberry PI is a very smart single board computer and work with Raspberry OS (some kind of a Linux OS) and It can be use for many interesting projects. In this tutorial it is trying to interface a USB web camera to the Raspberry PI and use some image processing work on the grabbed web cam images. For that purposes it is used Python and C scripts and also some important libraries. All steps of the project , requirements and cods are listed below.
Requirements:
You may also need an Internet connection in order to download libraries.
Methodology
If you have a new SD card for the Raspberry (without install Raspberry OS) firstly install raspbian OS.
Or
If you are a Raspberry PI user then please install custom libraries to interface the web camera and for the image processing as the following way.
Boot your Raspberry Pi up with a monitor and keyboard and your newly-written SD card. Then open the Root Terminal once the desktop loads (Menu > Accessories > Root Terminal). After load it please type this command on it as,
sudo apt-get update
after update complete then upgrade it,
sudo apt-get upgrade
After successfully upgraded, now let’s install some software packages which are help to access external devices. For that please type the following code in the terminal
sudo apt-get install python-smbus ipython bluetooth bluez-utils \
python-cwiid python-scipy python-numpy python-pygame \
python-setuptools libsdl-dev
Then download custom RPi.GPIO, i2c and image processing libraries:
wget http://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/robot/resources/RPi.GPIO-0.3.1a.zip unzip RPi.GPIO-0.3.1a.zip cd RPi.GPIO-0.3.1a sudo python setup.py install cd ..
wget http://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/robot/resources/i2c.py sudo mv i2c.py /usr/local/lib/python2.7/dist-packages/i2c.py
wget http://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/robot/resources/imgproc.zip unzip imgproc.zip cd library sudo make install cd ..
Then it is needed to have the i2c modules loaded by default so remove them from the blacklist by commenting them out. So go to the raspi-blacklist.conf file by entering the code:
nano /etc/modprobe.d/raspi-blacklist.conf
Then insert # at the beginning of the following lines which are consist of the raspi-blacklist.conf file.
blacklist spi-bcm2708
blacklist i2c-bcm2708
Then load the modules file
nano /etc/modules
And add followings in it
i2c-bcm2708
spi-bcm2708
i2c-dev