In the second segment on Raspberry Pi, we introduce the camera module. Using the camera, one can click still pictures and also film events. In the first post on Raspberry Pi, we used Raspberry Pi 3 Model B. We will be using the same for all the work in this article as well. Using Python based picamera package, we can communicate with the camera in Raspberry Pi. The code for picamera is here. Documentation to latest picamera release that we will be using is here. It is assumed that a camera that is compatible with this model of Raspberry Pi is already attached. The attached camera is shown below:
Then, click on enabled as shown below against Camera:
Finally, it should look like as shown below:
Then, click on OK. On the Reboot needed window click Yes:
Once roboot is complete, login into Raspberry Pi, check version of picamera by running validate.sh that contains below code:
In the first program in Python, we will see the different properties of the attached camera hardware. The program is shown below:
In the same manner, we can also video record any event and play it in omxplayer in Raspberry Pi. This concludes the post on adding camera module to Raspberry Pi
As a first step, we have to enable the camera software on the Raspberry Pi. So, navigate to Raspberry Pi icon --> Preferences --> Raspberry Pi Configuration --> Configure Raspberry Pi system as shown below:
Then, click on enabled as shown below against Camera:
Finally, it should look like as shown below:
Then, click on OK. On the Reboot needed window click Yes:
Once roboot is complete, login into Raspberry Pi, check version of picamera by running validate.sh that contains below code:
python3 -c "from pkg_resources import require; print(require('picamera')[0].version)"
In the first program in Python, we will see the different properties of the attached camera hardware. The program is shown below:
The output is shown below:
Note that the default resolution is 720x480, and default value for hflip, and vflip is false. For more details of above properties that can be also set, please refer the documentation. In the next program, we will click a picture. We set a few properties like resolution, hflip, and vflip before clicking the picture and capture it in .jpg format as shown below:
Command to run above program is below:
The captured picture is shown below:
In the same manner, we can also video record any event and play it in omxplayer in Raspberry Pi. This concludes the post on adding camera module to Raspberry Pi