Resolution on B0196 with OpenCV

1.Which seller did you purchase the product(s) from?
Unknown
2.The Model number of the product(s) you have purchased?
B0196
3.Which Platform are you using the product(s) on?
Raspberry Pi3 running Raspian
4.Which instruction are you following?
Existing OpenCV code
5.Has your product ever worked properly?
It works on Windows but not Raspian
6.What problems are you experiencing?
Hello,

I’ve got a B0196 that I’m using to try and replace a logitech C270 in a product we make. Teh camera is controlled by Python/OpenCV running from a raspberry pi 3. The code to connect is very simple:


cam = self.__cameras[index]

if cam is None or not cam.isOpened():
raise Exception(“VideoCapture is not connected”)

logging.info('setting camera ’ + str(index) + ’ to width ’ + str(self.IMAGE_WIDTH) + ’ and ’ + str(self.IMAGE_HEIGHT))
cam.set(cv2.CAP_PROP_FRAME_WIDTH, self.IMAGE_WIDTH)
cam.set(cv2.CAP_PROP_FRAME_HEIGHT, self.IMAGE_HEIGHT)

cam.set(cv2.CAP_PROP_FOURCC, cv2.VideoWriter_fourcc(*‘MJPG’))
logging.info('camera is ’ + str(cam.get(cv2.CAP_PROP_FRAME_WIDTH)) + ’ ’ +
str(cam.get(cv2.CAP_PROP_FRAME_HEIGHT)))


On the Logitech camera this simply connects and starts working at the required resolution but with a B0196 the resolution is 1280 by 800:

2019-02-14 10:40:34,899 - root - INFO - setting camera 0 to width 1280 and 960
2019-02-14 10:40:34,985 - root - INFO - camera is 1280.0 800.0

Does anyone know why this is happening - note doesn’t happen on windows when running on DirectShow.

Cheers,

Neil

7.What attempts at troubleshooting have you already made?
Tested code and logged output and run on Windows.
8.How would you like us to help you?
Suggest why the resoltuion might be set incorrectly

Hello,

 

Solved it; despite what he manual says when you connect the camera to a RP3 running Raspian and query the formats as follows:

v4l2-ctl --list-formats-ext

ioctl: VIDIOC_ENUM_FMT
Type: Video Capture

Size: Discrete 3264x2448
Interval: Discrete 0.500s (2.000 fps)
Size: Discrete 2592x1944
Interval: Discrete 0.200s (5.000 fps)
Size: Discrete 2048x1536
Interval: Discrete 0.200s (5.000 fps)
Size: Discrete 1920x1080
Interval: Discrete 0.111s (9.000 fps)
Size: Discrete 1600x1200
Interval: Discrete 0.100s (10.000 fps)
Size: Discrete 1280x960
Interval: Discrete 0.100s (10.000 fps)
Size: Discrete 1280x800
Interval: Discrete 0.100s (10.000 fps)
Size: Discrete 1280x720
Interval: Discrete 0.100s (10.000 fps)
Size: Discrete 800x600
Interval: Discrete 0.100s (10.000 fps)
Size: Discrete 640x480
Interval: Discrete 0.100s (10.000 fps)
[1]: ‘MJPG’ (Motion-JPEG, compressed)
Size: Discrete 3264x2448
Interval: Discrete 0.067s (15.000 fps)
Size: Discrete 2592x1944
Interval: Discrete 0.067s (15.000 fps)
Size: Discrete 2048x1536
Interval: Discrete 0.067s (15.000 fps)
Size: Discrete 1920x1080
Interval: Discrete 0.033s (30.000 fps)
Size: Discrete 1600x1200
Interval: Discrete 0.033s (30.000 fps)
Size: Discrete 1280x800
Interval: Discrete 0.033s (30.000 fps)
Size: Discrete 1280x720
Interval: Discrete 0.033s (30.000 fps)
Size: Discrete 800x600
Interval: Discrete 0.033s (30.000 fps)
Size: Discrete 640x480
Interval: Discrete 0.033s (30.000 fps)

Note that the is no MJPG for 1280 * 960 only 1280 * 800. There is for YUV though so you can just use YUV to get that resolution.

Cheers,

Neil

Hello,

Thanks for your great advise. We will add this detail to our document and tell more customers.