lak4cyut
Posts: 6
Joined: Wed Aug 21, 2019 6:27 am

V4L2 output frame abnormal (bcm2835_unicam + ov5647)

Wed Aug 21, 2019 8:52 am

Hi everyone,
I built a custom kernel to enable bcm2835-unicam and ov5647 kernel module and add ov5647 dt overlay, try to capture camera image via V4L2 official interface. (Of course I bought a Raspberry Pi official camera module - OV5647 version.)

Kernel base version: 4.19.64
Raspberry Pi: 3 model B v1.2
Camera Module: Raspbery Pi (OV5647) Rev 1.3

The good news is, I can capture the image, but the bad news is that image is abnormal (overlay & distortion).
(I put the image below)
Is there have anyone know why the image will wrong? Or have any idea to solve this problem?
Thanks for the help.

My capture command:
v4l2-ctl --device /dev/video0 --stream-mmap --stream-to=frame.raw --stream-count=1
frame2.jpg
frame2.jpg (79.79 KiB) Viewed 1463 times
frame1.jpg
frame1.jpg (106.56 KiB) Viewed 1463 times
frame.jpg
frame.jpg (122.32 KiB) Viewed 1463 times
====================== Here is the complete story ====================
My finial goal is to connect my own camera sensor via V4L2 architecture on Raspberry Pi CSI-2.
So I plan to use bcm2835-unicam + write a subdev driver to control my camera sensor.

Before that, I want to study and make sure bcm2835-unicam driver is workable.
Therefore, I buy a official Raspberry Pi camera module (OV5647) and build a custom kernel to enable bcm2835-unicam & ov5647 kernel module.
Final step, reference to https://github.com/raspberrypi/firmware ... ays/README, enable ov5647 dt overlay.

Then... I encounter this problem....

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 9850
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: V4L2 output frame abnormal (bcm2835_unicam + ov5647)

Thu Aug 22, 2019 12:31 pm

The ov5647 and bcm2835_unicam drivers should be in the standard kernel images built for Raspbian etc. Initially there should be no need to rebuild anything.
The ov5647 driver is pretty much vanilla Linux mainline - see https://github.com/torvalds/linux/blob/ ... c/ov5647.c
When first working on it I did have odd issues with short frames/dropped lines, but didn't dig too far as the mainline driver should "just work". You could try dropping the register set from raspiraw in to the driver instead, or at least analysing the differences. rapsiraw is known to work, although that is using 10bit Bayer mode instead of 8.
IIRC It was on this driver that I discovered the quirks of non-continuous clock mode and that the driver was running only in continuous clock. You can switch between them by changing the overlay (remove the "clock-noncontinuous;" line).
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

lak4cyut
Posts: 6
Joined: Wed Aug 21, 2019 6:27 am

Re: V4L2 output frame abnormal (bcm2835_unicam + ov5647)

Mon Aug 26, 2019 8:40 am

Hi 6by9,
First of all, I want to thank you of those information. It is helpful for me, I am a newbie on this scope (multimedia).
After remove "clock-noncontinuous;" on ov5647.dts and re-build it, the captured image has the chance become normal.

Then I reference the spec and your code, update the init-register settings, it finally become stable, thanks for your suggestion.

Now my problem is the RPi 3 seems cannot provide a good performance for play RAW (Bayer) stream.. It is very slow and lag...
But anyway, it is a huge step for me, thank you again.

Another question, actually, I don't really understand what it means, would you like to give me some info about that?
IIRC It was on this driver that I discovered the quirks of non-continuous clock mode and that the driver was running only in continuous clock. You can switch between them by changing the overlay (remove the "clock-noncontinuous;" line).

rego21
Posts: 30
Joined: Fri Feb 16, 2018 4:09 pm

Re: V4L2 output frame abnormal (bcm2835_unicam + ov5647)

Sun Feb 09, 2020 11:44 am

Hii,

I also start working with the bcm2835-unicam driver (just read a bit about it). I read the requirement to make it work is changing the device tree, am i right ? Hope you can guide me with this!

Thank you and nice work!

sumitnegi_4u
Posts: 6
Joined: Sat May 23, 2020 10:02 am

Re: V4L2 output frame abnormal (bcm2835_unicam + ov5647)

Mon Aug 17, 2020 1:14 pm

Hi guys,
Need your help ! newbie to camera domain.

I am also trying to capture frames using v4l2 +bcm2835_unicam+ov5647 driver.
Able to capture images but they are blur in nature attached are the images for reference.
Also removed dtbo clock-noncontinuous as already suggested in the post,but not able to figure out what changes done in the init.

Used below command to capture image
v4l2-ctl --device /dev/video0 --stream-mmap --stream-to=frame.raw --stream-count=1
and then used online tool to convert the raw to jpg .
My query is
1) Can you please highlight what i am missing.
2) Is this the maximum quality of image we can get with ( v4l2 +bcm2835_unicam+ov5647 driver) as there is no ISP module at time of image
capturing and we need to add libcamera SW stack for further refinement of image.

Thanks in Advance.
Attachments
n6.jpg
n6.jpg (79.44 KiB) Viewed 525 times
n7.jpg
n7.jpg (60.88 KiB) Viewed 525 times
n8.jpg
n8.jpg (62.98 KiB) Viewed 525 times

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 9850
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: V4L2 output frame abnormal (bcm2835_unicam + ov5647)

Mon Aug 17, 2020 2:33 pm

n6.jpg looks like something is incorrectly configured. The others look like they are fine but have a bad colour conversion matrix. Libcamera or better tuning in the processing tool should give better images than that.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

sumitnegi_4u
Posts: 6
Joined: Sat May 23, 2020 10:02 am

Re: V4L2 output frame abnormal (bcm2835_unicam + ov5647)

Fri Sep 25, 2020 2:19 pm

Thanks for your Prompt reply, but got stuck with some issue so not able to reply back on time apologies for that.

So now again i have started debugging and tried to localize this issue by capturing images with test pattern Enabled

Enabled test pattern 1 ,and attached the couple of images . Only one image out multiple image looks gud.
same i have observed with other mode in test pattern .
Not sure but looks to be some pipeline issue but not able to figure out.

Any suggestion would be of great help.
Attachments
17sep_1_9.jpg
17sep_1_9.jpg (76.95 KiB) Viewed 319 times
17sep_1_7.jpg
17sep_1_7.jpg (75.37 KiB) Viewed 319 times
17sep_1_6.jpg
17sep_1_6.jpg (69.17 KiB) Viewed 319 times

sumitnegi_4u
Posts: 6
Joined: Sat May 23, 2020 10:02 am

Re: V4L2 output frame abnormal (bcm2835_unicam + ov5647)

Fri Sep 25, 2020 2:23 pm

adding some more images
Attachments
17sep_1_11.jpg
17sep_1_11.jpg (95.5 KiB) Viewed 318 times
17sep_1_9.jpg
17sep_1_9.jpg (76.95 KiB) Viewed 318 times
17sep_1_8.jpg
17sep_1_8.jpg (9.48 KiB) Viewed 318 times

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 9850
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: V4L2 output frame abnormal (bcm2835_unicam + ov5647)

Fri Sep 25, 2020 2:50 pm

Which readout mode are you using?
It's just been noted that the original VGA raw8 mode seems iffy, but the 10bit modes all seem fine on the current 5.4 kernel.

I've just done a quick mod to add test pattern support to the ov5647 driver (I'll push it in a mo), and I'm getting rock solid images in 10 bit modes.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

sumitnegi_4u
Posts: 6
Joined: Sat May 23, 2020 10:02 am

Re: V4L2 output frame abnormal (bcm2835_unicam + ov5647)

Sat Sep 26, 2020 7:56 am

I am using raw 8 bit mode + VGA.
I read the linked shared by you so it seems clear that there are issue in 8 bit mode.
First i will try with 10bit mode on current pi ov5647 code base. If same result will check with 5.4 kernel as suggested.

Thanks for your input

Return to “Camera board”