0

I am capturing images using a USB Camera connected to a Raspberry Pi CM4, which in turn is connected to an external PCI interface. Sometimes, the camera works fine, but at other times, it shows an error stating that it is unable to capture the image. We are trying to capture image using python code and cv2 library. When this issue occurs, I execute the following commands:

When the camera is working properly, the command output is as follows:

v4l2-ctl --list-device
USB Camera: USB Camera (usb-.&checktime(0000,01,00,':').0-1.4):
/dev/video0
/dev/video1
/dev/media4
v4l2-ctl --all
USB CAMERA
Priority: 2
Video input : 0 (Input 1: ok)
Format Video Capture:
Width/Height : 640/480
Pixel Format : 'YUYV' (YUYV 4:2:2)
Field : None
Bytes per Line : 1280
Size Image : 614400
Colorspace : sRGB
Transfer Function : Rec. 709
YCbCr/HSV Encoding: ITU-R 601
Quantization : Default (maps to Limited Range)
Flags :
Crop Capability Video Capture:
Bounds : Left 0, Top 0, Width 640, Height 480
Default : Left 0, Top 0, Width 640, Height 480
Pixel Aspect: 1/1
Selection Video Capture: crop_default, Left 0, Top 0, Width 640, Height 480, Flags:
Selection Video Capture: crop_bounds, Left 0, Top 0, Width 640, Height 480, Flags:
User Controls
brightness 0x00980900 (int) : min=-64 max=64 step=1 default=0 value=0
contrast 0x00980901 (int) : min=0 max=100 step=1 default=35 value=35
saturation 0x00980902 (int) : min=0 max=100 step=1 default=50 value=50
hue 0x00980903 (int) : min=-2000 max=2000 step=1 default=0 value=0
white_balance_automatic 0x0098090c (bool) : default=1 value=1
gamma 0x00980910 (int) : min=1 max=300 step=1 default=100 value=100
power_line_frequency 0x00980918 (menu) : min=0 max=2 default=1 value=1
0: Disabled
1: 50 Hz
2: 60 Hz
white_balance_temperature 0x0098091a (int) : min=2800 max=6500 step=1 default=4600 value=4600 flags=inactive
sharpness 0x0098091b (int) : min=0 max=16 step=1 default=6 value=6
backlight_compensation 0x0098091c (int) : min=0 max=1 step=1 default=1 value=1

However, when the issue arises, the same commands produce the following outputs:

v4l2-ctl --list-device
USB2.0 Camera: USB2.0 Camera (usb-.&checktime(0000,01,00,':').0-1.4):
/dev/video0
/dev/video1
/dev/media4
v4l2-ctl --all
USB2.0 CAMERA
Priority: 2
Video input : 0 (Input 1: ok)
Format Video Capture:
Width/Height : 160/120
Pixel Format : 'YUYV' (YUYV 4:2:2)
Field : None
Bytes per Line : 320
Size Image : 38400
Colorspace : sRGB
Transfer Function : Default (maps to sRGB)
YCbCr/HSV Encoding: Default (maps to ITU-R 601)
Quantization : Default (maps to Limited Range)
Flags :
Crop Capability Video Capture:
Bounds : Left 0, Top 0, Width 160, Height 120
Default : Left 0, Top 0, Width 160, Height 120
Pixel Aspect: 1/1
Selection Video Capture: crop_default, Left 0, Top 0, Width 160, Height 120, Flags:
Selection Video Capture: crop_bounds, Left 0, Top 0, Width 160, Height 120, Flags:
User Controls
brightness 0x00980900 (int) : min=-64 max=64 step=1 default=0 value=0
contrast 0x00980901 (int) : min=0 max=100 step=1 default=40 value=40
saturation 0x00980902 (int) : min=0 max=100 step=1 default=32 value=32
hue 0x00980903 (int) : min=-2000 max=2000 step=1 default=0 value=0
white_balance_automatic 0x0098090c (bool) : default=1 value=1
gamma 0x00980910 (int) : min=100 max=300 step=1 default=100 value=100
gain 0x00980913 (int) : min=0 max=2 step=1 default=1 value=1
power_line_frequency 0x00980918 (menu) : min=0 max=2 default=2 value=2
0: Disabled
1: 50 Hz
2: 60 Hz
white_balance_temperature 0x0098091a (int) : min=2800 max=6500 step=1 default=4600 value=4600 flags=inactive
sharpness 0x0098091b (int) : min=0 max=31 step=1 default=2 value=2
backlight_compensation 0x0098091c (int) : min=0 max=1 step=1 default=1 value=1
Camera Controls
exposure_dynamic_framerate 0x009a0903 (bool) : default=0 value=1

From these outputs, it appears that some internal properties of the camera change unexpectedly, resulting in the inability to capture images. I have checked the kernel logs using the dmesg and journalctl commands, but I have not found any specific reasons for this behavior.

jsotola
7181 gold badge9 silver badges13 bronze badges
asked Nov 13, 2024 at 12:31

0

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.