How To Get Bayer Raw Data Of WDR DOL mode with 2 Frame Exposure?

Hi All,

I want to test the WDR DOL mode and I have porting the driver code and device tree. So, Is there any tool or way to get the bayer raw data, it should be include a short exposure and a long exposure.

Have you try v4l2-ctl?

I can use following command to get liner mode raw data. but how to get wdr mode raw data?
v4l2-ctl -d /dev/video0 --set-fmt-video=width=1920,height=1080,pixelformat=RG12 --set-ctrl bypass_mode=0 --stream-mmap --stream-count=1 --stream-to=ov1080.raw

hello tangqc023,

please check IMX274 for the reference driver,
as you can see, there’s double of image height for its DOL sensor mode. there’re also some DT properties to specify cropping area for DOL sensors.
for example,

                                mode2 { // IMX274_MODE_3840X2160_DOL_30FPS
                                        mode_type = "bayer_wdr_dol";
                                        active_w = "3856";
                                        active_h = "4448";
                                        num_of_exposure = "2";
                                        num_of_ignored_lines = "14";
                                        num_of_lines_offset_0 = "50";
                                        num_of_ignored_pixels = "4";
                                        num_of_left_margin_pixels = "12";
                                        num_of_right_margin_pixels = "0";

you may also refer to Sensor Software Driver Programming Guide for the diagram of a two-exposure DOL (Digital Overlap) multi-frame. that’s the actual signaling of the DOL-WDR sensors. you may have a try to assign those settings to dump raw images.

may I know what’s your use-case to obtain raw data of DOL-WDR sensor mode?

Hi JerryChang,

I need get the raw data of DOL-WDR sensor mode, then call my own neural network model(CNN) to get a rgb image。So,it’s input image is a short exposure raw data and a long exposure raw data。

hello tangqc023,

please have a try to dump raw files as I mentioned in previous comments, post #6.

HI JerryChang,

I have used following command to get hdr raw frame, but the frame size is 4147200, it should be 4147200 * 2. what’s the correct command?

command: v4l2-ctl -d /dev/video0 --set-fmt-video=width=1920,height=1080,pixelformat=BA12 --set-ctrl=bypass_mode=0,hdr_enable=1,sensor_mode=1 --stream-mmap --stream-count=1 --stream-to=ov1080.raw

hello tangqc023,

ideally, the hdr raw in the sensor stream should have double the height.
you may specify that into your v4l2 command lines,
for example, --set-fmt-video=width=1920,height=2160.

you should also specify correct pixelformat into the commands.
please check it with v4l2 standard controls.
i.e. $ v4l2-ctl -d /dev/video0 --list-formats-ext

Hi JerryChang,

I fix the command like this:
v4l2-ctl -d /dev/video0 --set-fmt-video=width=1920,height=2160,pixelformat=BA12 --set-ctrl=bypass_mode=0,hdr_enable=1,sensor_mode=1 --stream-mmap --stream-count=1 --stream-to=ov1080.raw

$ v4l2-ctl --device=/dev/video0 --list-formats-ext
	Index       : 0
	Type        : Video Capture
	Pixel Format: 'BA12'
	Name        : 12-bit Bayer GRGR/BGBG
		Size: Discrete 1920x1080
			Interval: Discrete 0.033s (30.000 fps)
		Size: Discrete 1928x2184
			Interval: Discrete 0.033s (30.000 fps)

But if I disable the error (tegra194-vi5 corr_err: discarding frame), like Get half raw data of wdr DOL mode 2 exposure , I still only get 4147200 Bytes and kworker/0:0-8379 [000] .... 418.870401: rtcpu_vinotify_error: tstamp:13454018340 tag:CHANSEL_NOMATCH channel:0x50 frame:8 vi_tstamp:13454015522 data:0x00000589 error.

Other, I find if I set is_interlaced=1 and interlaced_type=1 in dtsi file, I can output the 8294400 Bytes, but the first 4147200 bytes are normal images, and the second 4147200 bytes are all zeros。

hello tangqc023,

is this your WDR sensor mode (1928x2184) which reported by v4l2 controls?

Hi JerryChang,

Yes, this is mode1 for dtsi file.
The info Size: Discrete 1920x1080 is liner mode and is mode0 for dtsi file.

		Size: Discrete 1920x1080
			Interval: Discrete 0.033s (30.000 fps)
		Size: Discrete 1928x2184
			Interval: Discrete 0.033s (30.000 fps)

hello tangqc023,

please assign the exactly same format resolution to the v4l2 command line to let driver select mode-1 for testing,
for example,

$ v4l2-ctl -d /dev/video0 --set-fmt-video=width=1928,height=2184,pixelformat=BA12 --set-ctrl=bypass_mode=0,hdr_enable=1,sensor_mode=1 --stream-mmap --stream-count=1 --stream-to=ov1080.raw

Hi JerryChang,

I use your command get raw data, the ov1080.raw has 1928x2184x2 Bytes And the data first half is correct, the second half is zero.
CHANSEL_NOMATCH disappears and CHANSEL_FAULT errors occur. Please check debug.log (104.8 KB)

[ 635.244055] [ar0221_power_on][426] …
[ 635.290728] [tegra_channel_update_format] entry…sizeimage0=8421504
[ 635.290918] [tegra_channel_update_format] entry…sizeimage1=8421504
[ 635.329125] [vi5_channel_start_streaming] chan->bypass=0
[ 635.337703] ar0221_set_mode …, mode=1
[ 635.337883] [ar0221_write_table][207] …
[ 635.348423] [ar0221_start_streaming][560] …
[ 635.348543] [ar0221_write_table][207] …
[ 635.360682] tegra194-vi5 corr_err: discarding frame 1, flags: 0, err_data 512
[ 635.360872] tegra194-vi5 [debug]discard error
[ 635.394003] tegra194-vi5 corr_err: discarding frame 2, flags: 0, err_data 512
[ 635.394184] tegra194-vi5 [debug]discard error
[ 635.427406] tegra194-vi5 corr_err: discarding frame 3, flags: 0, err_data 512
[ 635.427622] tegra194-vi5 [debug]discard error
[ 635.460734] tegra194-vi5 corr_err: discarding frame 4, flags: 0, err_data 512
[ 635.460909] tegra194-vi5 [debug]discard error
[ 635.494018] tegra194-vi5 corr_err: discarding frame 5, flags: 0, err_data 512
[ 635.527385] tegra194-vi5 corr_err: discarding frame 6, flags: 0, err_data 512
[ 635.527570] tegra194-vi5 [debug]discard error
[ 635.527757] [ar0221_stop_streaming][572] …
[ 635.527840] [ar0221_write_table][207] …
[ 636.381601] [ar0221_power_off][448] …

hello tangqc023,

is that frame size as expect for WDR mode? i.e. 4147200*2.

Hi JerryChang,

No, frame size should be 4147200*2. But if the command --set-fmt-video=width=1928,height=2184,it will output 1928x2184x2 Bytes. The 1928 is activte_w and 2184 is activte_h in dtsi file.

if I set line_length=active_w, the CHANSEL_NOMATCH error will disappear, if I set line_length > active_w, CHANSEL_NOMATCH error will occur.
Is there any way can get raw data from frame start to frame end?

hello tangqc023,

please refer to Sensor Software Driver Programming Guide. it’s timing settings,


Pixel line width horizontal timing size for the sensor mode. Used to calibrate the features in the camera stack.
The value must be greater than or equal to active_w.

as I mentioned in post #6, there’re other DT properties for VI to crop two different exposure frames for usage.
since v4l2 standard controls did not recognize those additional settings, to dump DOL raw images might be not supported.

Hi JerryChang,

Is there any way to dump DOL raw images after VI to crop?
Or the sample argus/samples/cudaBayerDemosaic/main.cpp can help to dump DOL raw images?

hello tangqc023,

please refer to Camera Architecture Stack;
Argus samples were based-on libargus library, which going through [Camera Core] block for handling sensor signaling. Hence, you cannot dump raw images at Argus level.
There’s only single approach to dump raw files. You should enable v4l2 standard controls, which bypass [Camera Core] block for accessing sensor device.

However, as our previous comments.
v4l2 standard controls should be not support to DOL-WDR raw files at current release versions.