Saturday, November 12, 2016

IOT: How to setup Camera module on Raspberry Pi?

Objective: The Objective of this exercise is to setup RaspiCam on Raspberry Pi and how take some pictures and videos with it.
Overview about RaspiCam:
The Raspberry Pi Camera Module can be used to take high-definition video, as well as stills photographs. It is a custom designed add-on for Raspberry Pi. It attaches to Raspberry Pi by way of one of the two small sockets on the board upper surface. This interface uses the dedicated CSI interface, which was designed especially for interfacing to cameras. The CSI bus is capable of extremely high data rates, and it exclusively carries pixel data.
The board itself is tiny, at around 25mm x 20mm x 9mm. It also weighs just over 3g, making it perfect for mobile or other applications where size and weight are important. It connects to Raspberry Pi by way of a short ribbon cable. The camera is connected to the BCM2835 processor on the Pi via the CSI bus, a higher bandwidth link which carries pixel data from the camera back to the processor. This bus travels along the ribbon cable that attaches the camera board to the Pi.
The sensor itself has a native resolution of 5 Megapixel, and has a fixed focus lens onboard. In terms of still images, the camera is capable of 2592 x 1944 pixel static images, and also supports 1080p30, 720p60 and 640x480p60/90 video.
Steps to install RaspiCam:
1.   Open up your Raspberry Pi Camera module from the grey anti-static cover. Before removing the camera, make sure you have discharged yourself touching an earth object (ex: radiator or PC Chassis).
2.    Ensure that Raspberry Pi is switched off and install the Raspberry Pi Camera module by inserting the cable into the Raspberry Pi. The cable slots into the connector situated between the Ethernet and HDMI ports, with the silver connectors facing the HDMI port.

3.   From the command prompt, run "sudo apt-get update" to check for the updated packages.
sudo apt-get update

4.   From the command prompt, run "sudo apt-get upgrade" to install the updated packages and enter Y to install the updates (if asked). It will take some time to finish, depending on the speed of your internet.
sudo apt-get upgrade

5.   The Camera option need to be enabled in the raspi config settings by running the following command: 
sudo raspi-config
6.  Now go to "Enable Camera" option and enable it (if it is not already enabled), select “Finish” and reboot your Raspberry Pi.
        Select "Yes" and hit Enter to enable the Camera interface.
       Select "Finish" and hit Enter.
      Select "Yes" and hit Enter to reboot.
7.   That’s it; you are all set with the Raspi Cam setup on the Raspberry Pi.

How to take a photo with Raspberry Pi Camera Module:
8.   "raspistill" is a command line application that allows you to capture images with your camera module. Enter the following command (without any parameters), which will list you the parameter options that you can consider. For example, you can change the width, height, quality, Image effects etc.
raspistill

9.   To keep it simple, let’s capture an image in jpeg format using the following command, where "image" is the name of your image, which will be created in the current directory.
 raspistill -o image.jpg

10.  You can verify the file image.jpg by entering the ls command.

How to record a video with your Raspberry Pi Camera module: 
11.  "raspivid" is a command line application that allows you to capture video with your camera module.  Enter the following command (without any parameters), which will list you the parameter options that you can consider. For example, you can change the width, height, quality, Image effects etc.
raspivid
12.  To keep it simple, let’s capture a 10 second video with your Raspberry Pi camera module using the following command, where "video.h264" is the name of your video (which will be created in the current directory from where you execute this command) and "10000" is the number of milliseconds (which means 10 seconds).
raspivid -o video.h264 -t 10000

13.  You can verify the file video.h264 by entering the ls command. 
Hope it was useful..:-)

No comments:

Post a Comment