Qengineering / BananaPi-M2-Zero-OV5640

Banana Pi M2 zero with OV5640, WiringPi and OpenCV image.
https://qengineering.eu/deep-learning-with-raspberry-pi-and-alternatives.html
BSD 3-Clause "New" or "Revised" License
37 stars 4 forks source link
allwinner armbian banana-pi banana-pi-m2 banana-pi-m2-zero bluetooth cpp gstreamer h2-plus opencv ov5640 sd-card sd-card-image ssh wifi wiringpi

Banana Pi M2 zero + OV5640

A Banana Pi image with OV5640 camera, WiringPi and OpenCV

output image

License


Installation.


Split image.

Because the image is large (5.5 GB), the download may take quite some time. It makes downloading vulnerable.
That's why we split the file into smaller chunks. These are more manageable than one huge download.
If you prefer this partial download over one large one, download the following 12 files (500 MB each) and place them in one folder.

Once you have all the files run

7z x BananaPi_M2_zero_OV5640.7z.001

7Z will start extracting the first file (*.001) and then automatically the next files in order.
You will endup with BananaPi_M2_zero_OV5640.zip, the original image which you now can flash on a SD card with Imager or balenaEtcher.

If you get the error '7z' is not recognized as an internal or external command, operable program or batch file. please give the full path to 7z. For instance,

"C:\Program Files\7-Zip\7z.exe" x BananaPi_M2_zero_OV5640.7z.001

output image


Good to know.


OV5640.

First, we would like to thank Wim van ‘t Hoog for the many hours of work rebuilding the Linux device tree on the Banana Pi to get the OV5640 drivers installed. Please visit his website, if you want more information on the subject. Also, if you like to get the Cedrus encoder (used for FFmpeg and GStreamer) up and running. Note, Wim is using the Nano Pi with the Allwinner H3, instead of the Banana Pi with the H2+.

output image

:point_right: You cannot use a Raspberry Pi camera! The OV5640 has a parallel output port, while the RPi OV5647 has a MIPI-lane interface.

:point_right: There are several connector layouts of the OV5640 camera. Buy one specifically for the Banana Pi, like this one.

output image
With the wrong connector you are facing issue #6.

Before using the ov5640 camera, it must be initialized. It is done by the command $ sudo media-ctl --device /dev/media1 --set-v4l2
The command allows you to set the resolution, framerate, compression and other parameters. You can issue a new command at any time to change the parameters. You can also set the initialization during boot, for example by placing the command in /etc/rc.local.
The camera is located at /dev/video1, not /dev/video0 where the cedrus engine lives.
Some examples

$ sudo media-ctl --device /dev/media1 --set-v4l2 '"ov5640 2-003c":0[fmt:YUYV8_2X8/1280x720]'
or
$ sudo media-ctl --device /dev/media1 --set-v4l2 '"ov5640 2-003c":0[fmt:YUYV8_2X8/640x480]'

With framerate:

$ sudo media-ctl --device /dev/media1 --set-v4l2 '"ov5640 2-003c":0[fmt:YUYV8_2X8/640x480@1/30]'
or
$ sudo media-ctl --device /dev/media1 --set-v4l2 '"ov5640 2-003c":0[fmt:YUYV8_2X8/1280x720@1/15]'

GStreamer

You can use GStreamer. However, be aware of the limited resources on the Banana Pi M2 zero.
Streaming to screen:

$ gst-launch-1.0 v4l2src device=/dev/video1 ! video/x-raw, width=640, height=480, framerate=30/1 ! videoconvert ! autovideosink

UDP streaming to another computer. (192.168.178.84 is the address of the recieving host)

$ gst-launch-1.0 -v v4l2src device=/dev/video1 num-buffers=-1 ! video/x-raw, width=1280, height=720, framerate=30/1 ! videoconvert ! jpegenc ! rtpjpegpay ! udpsink host=192.168.178.84 port=5200

OpenCV

Once the camera is set up, you can receive the video stream in OpenCV for further processing.
We've added an example to the SD image. It is almost identical to the OpenCV camera example for the Raspberry Pi. See our webpage for more information.

output image


Pre-installed frameworks.

output image

output image


Tips.

If you want to change the password, here are the commands( =pi ).

$ sudo -i
# passwd <username>
New password: 
Retype new password: 
passwd: password updated successfully
# exit
$ sudo reboot

paypal