Orange Pi Camera with v4l2loopback and vidcopy

orange pi camera

Orange Pi Camera with v4l2loopback and vidcopy

Aside from USB cameras, the gc2035 camera for Orange Pi works together with vfe_v4l2 module, simulating a real v4l2 device.

Programs like v4l2-ctrl and ffmpeg doesn’t work, so I decided to study about it.
On my research i found the reason of the image formating error, some programs do not define the index of current input (VIDIOC_S_INPUT).
So that was my ace in the hole: I just need to define the index of current input, but then I face with another problem, change all of the original codes of each program using v4l2.
Not so easy…

To solve this problem I wrote the vidcopy.

The vidcopy got the following features:

  • Set the index of current input
  • Image resolution
  • Read the camera device and write an I/O (stdout is the default)

I used the v4l2loopback which creates a virtual video device, then the vidcopy capture from the camera and write on the device.

A killer combination! All of the programs worked like a charm.

Recalling that vidcopy is not only for Orange Pi, it works with any camera with v4l2 support and also give you the freedom to write on stdout, which allows you to work with ffmpeg.

Installing v4l2loopback (need kernel source)

# git clone
# cd v4l2loopback/
# make && make install

Installing vidcopy

# apt-get install libv4l-dev
# git clone
# cd vidcopy/
# gcc vidcopy.c -o vidcopy

Loading necessary modules

# modprobe gc2035
# modprobe vfe_v4l2
# sleep 5
# modprobe v4l2loopback

Starting copying frame

with camera orange pi, I tested with the following formats: UYVY/YV12/YU12/NV12/NV21

./vidcopy -w 800 -h 600 -r 20 -i /dev/video0 -o /dev/video1 -f UYVY

Ready, /dev/video1 ready for use!

Works fine on Orange Pi One/PC/Plus

Opencv and ffmpeg running gracefully.

I made some modifications to the 3.4.39-02 kernel-lobo:

  • gc2035: of 8fps to ~20fps eand improvements in the matter of light.
  •  The original driver accepts only 800×600, added the following resolutions: 800×600/640×480/320×240
  • sunxi_wdt: builtin to module (greater flexibility to change the module options) / pr_info some functions, causing flood in kern.log (switched to pr_debug)
  • CONFIG_CMDLINE=”earlyprintk=ttyS0,115200 loglevel=5 initcall_debug=0 console=ttyS0,115200 console=tty0 fsck.mode=force init=/init ipv6.disable=1
  • kernel size: ~59mb

For those interested, click here.

How about we find in his tube for tips, tutorials and Reviews boards? Sistemas Embarcados Channel

What about the Facebook page?

Or Instagram?

Who knows Google Plus?

What about the Pinterest?

Or maybe find us on Twitter to receive the latest news: @SEmbarcados

And do not forget we also have email,

Visit our Facebook groups:

Big hug and until the next embedded.