Monday, October 3, 2016

Raspberry Pi & Arch Linux - Day 10 - Camera Module



We have two news for today; one is good and one is bad. Let us start with the bad one...

In the previous post, we mentioned that we can use coroutines in Python to handle the communication between different components. It turns out that it makes no sense because at the end of the day, we still need to explicitly invoke the function by sending a message to the generator, which is essentially equivalent to calling the function directly.

The problem still remains. How can  we handle the communication between different components? Looking into the details, the radar motor spins while the distance sensor constantly measures the distance. The motor needs to send back the data of its position and the sensor sends back the distance to the obstacles. They are in parallel. I guess at this point, we definitely need to go with multiprocessing in Python. Surprisingly, raspberry pi has 4 cores and I really cannot understand how they can sell it for $25. Amazing achievement.

The good news is I finally manage to install the cameral module and now my raspberry pi can open its eyes and see the world for the first time.

The module we use is Raspberry PI 5MP Camera Board Module.



We also use the LEGO bricks to build a frame that holds the camera module. It is possible to connect this frame to a motor but for now we will focus on the camera itself.

Here is a tutorial (from the internet) to connect the cable to the raspberry pi.

There is a Python API for the camera module: picamera. We can install it with pip.

Before trying to test it in python, we may need to take a look at the wiki page:
https://wiki.archlinux.org/index.php/Raspberry_Pi#Raspberry_Pi_camera_module

The page provides solutions to common errors often encountered when working with the camera. A very important thing: double check the connect of the cable. If the cable is not connected correctly, the camera will not be detected.

To see if the camera works properly, take our first picture:
$ raspistill -o first-sight.jpg

If you get an error saying that the camera is not detected, you need to check the connection and reboot the raspberry pi.

Note that with the LEGO frame the picture is upside-down.  lol.....

--END--

No comments:

Post a Comment