BananaPro/Pi:Camera Module

From BananaPro/Pi
Jump to: navigation, search

Overview

Banana Pi Camera

Banana Pi Camera

Banana Pi Camera

The Banana Pi camera module is available right now and is a high definition camera module for the Banana Pi using an Omnivision 5640 CMOS image sensor in an auto-focus module and with an integral IR filter. The camera module connects to the Banana Pi board via the CSI (CON1) connector designed specifically for interfacing to cameras. Providing high sensitivity, low crosstalk and low noise image capture in a small and lightweight design, it is an excellent and worthwhile accessory for your favourite SBC!!!


Specifications

Image sensor Omnivision 5640 CMOS image sensor in an auto-focus module with integral IR filter (650±10nm)
Still resolution 5 Megapixels
Active array size 2592 X 1944
Max frame rate 1080P 30fps@24Mhz
Picture formats JPEG PNG YUV420 RGB888
Video formats Raw
Connection to Banana Pi 40 Pin FPC to the Camera Sensor Interface (CSI-0)
Image control functions Automatic exposure control (AEC)

Automatic white balance (AWB)
Automatic black level calibration (ABLC)
Automatic band filter

Mirror and flip functions

Temp range Operating: -30°C to 70°C

Stable image: 0°C to 50°C

Lens size 1/4” (quarter inch)
Dimensions 36 x 32 x 10 mm
Weight 5g

Connecting the camera module

First, carefully unpack the camera module. I was using the LeMaker Banana Pi Camera v1.0 as seen in the photos above. It's about 35mm x 35mm square and black with white lettering.

Examine the module and handle it gently and carefully. Hold it by its edges at all times and do NOT allow your fingers to come in contact with the front or the back faces. On the front is the lens, the screen-printed product name and company logo, and a small fixed-on ribbon cable (similar to what you see on the underside of some hard drives) about 1cm in length.

Turn the module over with the lens pointing forward (away from you) and with the connector for the ribbon cable at the top. You'll see it is numbered with pin 10 on the left and pin 40 on the right, although that is not much use to us as there are no corresponding numbers on the B-Pi's connector that we will be interfacing it with in a little while.

You should have been also provided with a short (about 60mm) or a long ribbon cable. Needless to say, only handle this by the sides of the long edges or with finger and thumb on the flat sides in the middle, but DO NOT AT ALL COSTS touch either of the silvered ends.

On the module itself, use the very edge of your fingernail to GENTLY prise the black section of the connector back. It will swing open to a maximum of 90 degrees (similar to how a RAM module fits into a motherboard, although that is only typically 30-45 degrees of movement). I found putting my thumb (on the same hand as the index finger) on the underside of the white part of the ribbon connector bit (rather than on the bottom of the whole PCB) made this slightly easier. But be careful not to touch or damage any of the components or wires there. Only a small amount of force is necessary to make it open. Using an implement (either metal or plastic) of any sort to do this step is definitely NOT recommended.

Taking the ribbon cable, you will see that on each end there is a silvered end (with the cables exposed) and on the reverse of that there is a band of colour (in my case blue). The other end of the ribbon has these switched around, so that the silvered parts are on opposite sides of the ribbon at each end. (I will upload some photos ASAP to make this clear.)

With one end of the blue band facing you (in other words, so the metal ends of the ribbon meet the metal receiving pins inside the connector - use a magnifying glass to check this if you want), insert the end of the ribbon into the connector of the camera module. There are two little guides to help you do this. Don't rush it, and make sure it is seated properly and fully (otherwise you run the risk of crimping and squashing and potentially damaging/ruining it) before pushing the black hinge back into position with a very satisfying soft 'click'. A light tug on the ribbon will tell you if it is secure.

On the B-Pi locate CON1 (CSI connector). It is on the same edge of the board as the SD card but on the top side. It lies between the Reset and Power switches, with one end nestling close to Pin 1 of the GPIO pins.

DO NOT EVEN THINK of trying to use the other connector CON2, even though it looks the same. That one (which is positioned behind the Ethernet socket) is for LVDS (LCD modules, touch screens and similar devices) and the pin definitions are VERY different.

Beware!! This connector for CON1 works in a different way to that of the camera module. It has a black T-bar that pushes up and down into and out of the white part of the connector which is fixed to the board (but it only moves by about 1 millimetre), then it swings back (but again, only by a small amount, about 10 degrees). Do not force it back any further!!

Ground yourself on the metal chassis of your PC, pick up the B-Pi and disconnect all cables & plugs and SD cards if you did not already do so. You can hold the board upright, either with the SD slot facing you, or with the Ethernet & USB ports facing you. It's up to you.

As before, the ribbon cable must only go into this slot one way, i.e. with the metal exposed end of the ribbon connecting with the metal pins inside the connector. Pity there are no numbers on the PCB to help us here (everything else including caps and resistors and all the jumpers and pins are numbered!!!).

This means: if the SD slot is facing you, the silvered end of the ribbon must be facing you as you insert it.

On the other hand, if the USB/Ethernet ports are facing you, the blue strip is also facing you and the silvered end is on the other side and unseen by you.

Like before, insert the ribbon into the slot carefully and fully and at 90 degrees (in both orientations, front-to-back AND side-to-side) using the inner guides to assist you. Then swing the black T-bar back and push down. I admit I had to use the edge of an SD card to assist me to ensure both ends were seated securely and there were no gaps at either end where the ends of the T-bar meet the body of the connector. It's especially tricky near pin 1 of the GPIO headers as there's VERY little room for manoeuvre. Like before, the use of metal implements or even pointed plastic ones should be avoided in case they slip and damage components and/or PCB tracks.

Final check: make sure the ribbon cable is secure at both ends and is coming out of each connector (B-Pi and camera module) at 90 degrees.

Just before using the camera, you should gently peel off the plastic foil from the lens using the small red tab. If you do that, just make sure you then don't get any fingerprints on the front of the lens!!

(With thanks to native speaker “roses” for providing this text)


Implementation

Setting up the B-Pi
First you have to load the necessary drivers needed by the camera module:


sudo modprobe ov5640
sudo modprobe sun4i_csi


if modprobe sun4i_csi does not work try:


sudo modprobe sun4i_csi0


Then you can use MPlayer to test the camera:

mplayer tv://


The API library for the Banana Pi camera module (such as Picamera for the Raspberry Pi) is still in the development stages. But you can also use your own program to process the camera data.


The camera module ov5640 driver source code is at: external link.

Using the camera – a practical example

Text by wojtekadams

Original text (in Polish) for his blog is at external link.

Translation into English by native speaker “roses”.


BMK (Polish abbreviation for Banana Pi Camera Module)


With the phenomenal success that the Banana Pi is having, the engineers at LeMaker told us that we wouldn't have to wait a long time for one – for they are walking the same path that was originally taken by their British counterparts at the Foundation – and indeed they have now produced a camera module for your favourite SBC mini-computer. Here it is:


Wojtekadams - blog - front side lens.jpg

Front side (lens)



Wojtekadams - blog - reverse side connector.jpg

Reverse side (connector)


This device communicates with the CSI connector (CON1) which is located right next to the GPIO pins and just behind the Power & Reset buttons on the B-Pi. The module is equipped with a 5640 Omnivision CMOS image sensor with integrated auto-focus and an infrared filter. See section 2 above for the full specifications.


Operating either as a webcam or as a still picture camera


Mounting of the module is very easy. You just need to properly connect the Banana Pi and the camera using the supplied ribbon cable (see section 3 above for more detailed instructions) and as shown in this picture below:


Wojtekadams - blog - mounting.jpg


In order to finally get the camera working, simply load the necessary modules. To do this, follow the instructions with the relevant Linux commands in Section 4 above.


Wojtekadams - blog - console dmesg.png


If all goes well, we should see 'video0' in the list of devices.


Wojtekadams - blog - video0.png


Now we can do some testing of the device. We can check that it's working correctly using almost any program as the camera is seen by the system as 'video0', and most applications can deal with this and handle it without a problem. Just install on your system (in my case Lubuntu for Banana Pi Downloads section) the application GUVCvideo.


You can also check it with the mplayer tv:// command (see Section 4 above).


Wojtekadams - blog - lubuntu.png



In the Banana Pi forum, many users have already started using the camera module to create their own webcam monitoring program using Motion forum link.


However, going back to my tests, which are still ongoing, I could not squeeze out of the camera anything close to what is promised in the specifications. The maximum I was able to achieve for an image was a resolution of 1280 x 720. Any more than that and the photos were poor quality – either distorted or all black.


Wojtekadams - blog - room with cat.jpg


Wojtekadams - blog - room with 2 cats.jpg



However, we must be of good cheer for the engineers at LeMaker are still working to improve the operation of the camera, as well as developing an API library for it (like the PiCamera for the Raspberry Pi).

See Also

The full version and original link for the blog in Section 5 (in Polish, the author's native language): external link.


The camera module ov5640 driver source code: external link).


Wiki page for setting up as a webcam: internal Wiki link.


Help and support in our forum: forum link.


Youtube video for Camera module: ExplainingComputers