Let's mount the RPi camera on the robot; you will need a RPi camera case for this. A quick search on amazon.com for RPi camera case will show the following case:
I do not recommend this particular case as it did not fit my RPi camera module properly. When the case is closed, the lens of my RPi camera did not properly align with the small hole of this camera case.
The image of the RPi camera case that I used is shown in the following image. I bought this case from an Indian website called www.robu.in. On this website, search for Camera mount module for Raspberry Pi to find this camera mount:
Even though this camera mount contains four small nuts and bolts to attach the RPi camera to the camera mount, I found that the threading of the nut and bolt was inaccurate, and attaching the RPi camera to the camera mount was way too difficult. Therefore, I used four small pieces of double-sided tape and attached the tape to the holes of the RPi camera:
Next, I attached the RPi camera to the camera mount. In the following image, the RPi camera is fitted upside down. So, when we capture an image, the image will appear upside down, and to view the image properly, we need to flip it (the process of flipping the image horizontally and vertically inside OpenCV is explained in Chapter 7, Building an Object-Following Robot with OpenCV):
After this, I attached the camera mount on top of my RPi case using small strips of double-sided tape, thus mounting the RPi camera on the robot:
Now that we've mounted the camera case on the robot, let's see how we can capture images and video using the RPi camera.