How to Use Orange Pi Camera in Linux (with Motion)

Earlier this month, I wrote a Quick Start Guide for Orange Pi Allwinner H3 boards such as Orange Pi PC, and showed how to install and configure Debian on the boards. I’ve also received the $5.90 Orange Pi camera, which when combined an Orange Pi PC, costs around $27 including shipping. So today, I’ve attached the CSI camera to my Orange Pi 2 mini board, and used it with motion to transform for the board into an IP camera.

Orange_Pi_2_mini_CameraFirst, you’ll need to insert the camera into CON1 connector with the camera facing the ceiling, and close the black clip to keep it in place.

Now connect all cable and power on your board. First, I studied the steps described on that forum thread, and modified Allwinner configuration files, but after one or two hours, I found out some work at been done since May, and it was now much easier to use the camera since gc2035 drivers was part of the Debian image, and the script.bin file (allwinner config file) was already setup to be used with Orange pi camera.

Open a terminal window in the board to load drivers:


and then mostly followed the instructions for USB webcams on Orange Pi website to install and configure motion:


and enable the following line:


This will make sure the web server started by motion will be accessible from other network devices.

I’ve also changed target_dir to /home/orangepi/motion, as motion would crash each time it would create a file when detection motion.


You’ll also need to change the startup script


and change the only line in the file as follows:


Finally, we are ready to give it a try:


You can launch your favorite browser, or access localhost:8081 if you are using your board, or <orange_ip_address>:8081 from another machine on the network, and you should the the picture camera updated into your web browser about twice per second.

Orange_Pi_PC_Camera_Motion
Click to Enlarge

If the system detects motion will save pictures and videos in target_dir directory, which I set to /home/orangepi/motion earlier. The image resolution is set to 800×600, and it ignored width and height settings (320×240) set in motion.conf.

Motion will start automatically, but you still need to load the modules automatically at boot time for this to work. Simply edit /etc/modules, and add the two required modules at the end of the file.


Now motion will run automatically, and the camera work properly each time the board starts.

Share this:

Support CNX Software! Donate via cryptocurrencies, become a Patron on Patreon, or purchase goods on Amazon or Aliexpress

ROCK Pi 4C Plus
Subscribe
Notify of
guest
The comment form collects your name, email and content to allow us keep track of the comments placed on the website. Please read and accept our website Terms and Privacy Policy to post a comment.
40 Comments
oldest
newest
onebir
onebir
8 years ago

Is the Orange Pi camera comaptible with Raspi?

Lissanro
4 years ago

No, cameras for Orange Pi and Raspberry Pi are not compatible. Even ribbon cables are not similar – different number of pins and different width.

(I know this post few years old but I think it is worth posting here correct answer for those who will read this in the future)

Richard
Richard
8 years ago

Which Debian image are you using?

Richard
Richard
8 years ago

@Richard
Scratch that – I figured it out. I still can’t seem to get motion to work though.

Is there any program like raspistill out there that would let me take still frames on a command line call that will work with the gc2035 driver?

Richard
Richard
8 years ago


Just got it working – it was a permissions issue.

That said, I played around with mplayer and found the IOCTL errors, and I also played around with the v4l-utils package (using v4l2-ctl) to see if I could change some of the parameters (shutter speed, white balance, etc), but it looks like the driver doesn’t have any of that implemented either.

Do you know if any instructions exist for compiling the driver on the Orange Pi 2 for Debian 8 exist? I’d be very grateful if you could link me to them 🙂

Thanks!

Wim
Wim
8 years ago

@Richard

Can you explane how jou solve the premission issue?

birky
birky
8 years ago

Please how can I vertically flip the camera image?

111111z
111111z
8 years ago

Anybody noticed that the gc2035 image is mirrored?
Things on the right side of the picture is on the left.
Any easy fix?

111111z
111111z
8 years ago

Motion alone does not fix that problem. I had to convert the script.bin to a fex file and edit the fex file item hflip to 0 and then convert back to a script,bin file and then rotate via motion to 180.

That fixed it. convert programs bin2fex and fex2bin
Only the linux version worked, the windows version gave a error.

alpha le ciel
alpha le ciel
8 years ago

hello , how to know my camera module of orange pi work or not … i try follow you but it’s not work at all

alpha le ciel
alpha le ciel
8 years ago

now i can fix it easily … before i use orangepi-debian-jessie-xfce , but it does’nt work …. now i install news os OrangePI-PC_Ubuntu_Vivid_Mate.img to my orange-Pi.. and then it’s work properly .. download it https://drive.google.com/folderview?id=0B1hyW7T0dqn6fndnZTRhRm5BaW4zVDVyTGlGMWJES3Z1eXVDQzI5R1lnV21oRHFsWnVwSEU&usp=sharing
and get os and install OrangePI-PC_Ubuntu_Vivid_Mate.img … and follow cnxsoft and then can use that thing 😀

Nachiket
Nachiket
8 years ago

Hi, Can anybody post a tutorial on how to get opencv working with orange pi pc ? In debian or Linux.

Yossi
7 years ago

I tried according step by step, but unfortunately the camera “unable to open video device” in browser. I used Firefox Browser and url : http://localhost:8081
can you help me to solve it?

Regards,

djames suhanko
7 years ago

I know this guy. He’s a expert in OpenCV (computational vision) and lives in Rio de Janeiro – Brazil. Their name is Leonardo Lontra.

Clive Pengelly
Clive Pengelly
7 years ago

Please can you give me a step by step instruction of how you solved this problem. I have tried for 5 days now with all different OS and I cant get it to work. I get no video at all. The only OS that sees the camera is the Android version which is installed on the OP Plus

Lutz Fechner
Lutz Fechner
7 years ago

Steps described work fine with the OPI Lite. Image quality is ok. I’d say quality of the RPI Cam is a bit better. But good enough for my purpose and OPI+Cam is cheaper than RPI Camera alone.

Only thing I noticed is that CPU consumption is quite high. Even if no client is connected. I disabled motion detection already to lower power consumption.

Is there a way to stream using uv4l like you can on Raspbian?

celem
7 years ago

Thank you for publishing this guide – it really helped me setup motion on my Orange Pi Lite.

Question: What prevents the motion folder’s files from growing until it consumes all space?

celem
7 years ago


Setting output_normal=off in motion.conf stopped the jpg photos from being created but it still creates .swf files, which will still fill up the folder. I haven’t figured out how to stop their creation. I just want video via the 8081 web portal.

celem
7 years ago

@celem
Solved it! In motion.conf, setting the following stops creation of both .jpg and .swf files:

ffmpeg_cap_new=off
output_normal=off

tkaiser
tkaiser
7 years ago

BTW: We now have the ability on H3 boards to use ffmpeg with GC2035 (and most probably also OV5640) cameras to record video using Allwinner’s HW h.264 encoder freeing up the CPU cores completely: http://forum.armbian.com/index.php/topic/1842-ffmpeg-with-cedrus-h264-hw-encoder-h3-cmos-camera/#entry14157

I hope a few more video enthusiasts join the party since these are really great news to get rid of Raspberries (still my only use case for these devices: using raspivid to record HW accelerated h.264)

Sancho
Sancho
7 years ago

I managed to get mjpg_streamer running with the camera!
http://sanchosk.blogspot.ch/2016/08/orange-pi-one-and-camera.html

Ivalion
Ivalion
7 years ago

You have to edit the “stream_maxrate 4” parameter in order to change the framerate.

Ben
Ben
7 years ago

@Sancho
Please write a mor concise tut that I can follow to! Thanx in advance

Ferri
Ferri
7 years ago

Hi, on a OPI Lite + gc2035 (+ expansion board) and Debian Jessi (Linux orangepilite 3.4.113-sun8i) I failed to get the camera working.
Both gc2035 and vfe_v4l2 modules are loaded and live. but I have these on my syslog, while camera connected:

[ 13.398284] [CSI_ERR][GC2035]sensor_read err at sensor_detect!
[ 13.398297] [CSI_ERR][GC2035]chip found is not an target chip.

and no /dev/videoX at all. i2cdetect doesn’t show any device.

green16
green16
6 years ago

Hello! Will this camera work with banana pi m2u?

pavelr
pavelr
6 years ago

Hi,
I’ve tried to follow the tutorial and everything worked until the access to localhost – I can’t access to the page.
Can you please clarify this step? Where I can check the exact address (maybe I missed something and using wrong ip address)?

Thanks.

redge
redge
6 years ago

@Ferri
see solution here: https://forum.armbian.com/topic/3613-armbian-525-on-orangepi-pc-the-gc2035-video-camera-doesnt-work/?page=3
modprobe gc2035 hres=0
modprobe vfe_v4l2
sunxi-pio -m “PG11” #DOVDD
sunxi-pio -m “PE15” #Power_Down
sunxi-pio -m “PE14” #reset

theguyuk
theguyuk
5 years ago
DLU
DLU
1 year ago

Are there Orange Pi camera OpenCV learning videos?

Khadas VIM4 SBC