Imx298 16 mp opencv python gst-launch-1.0

hello i don’t manage to get opencv work whith your doc helping

1. Where did you get the camera module(s)?
amazon
2. Model number of the product(s)?
arducam pivariety imx298 16MP
3. What hardware/platform were you working on?
raspberry pi 4 4go

4. Instructions you have followed. (link/manual/etc.)

How to access and program the Pivariety Camera using Command Line, Python, OpenCV, and GStreamer

5. Problems you were having?

pi@raspberrypi:~ $ gst-launch-1.0 libcamerasrc ! ‘video/x-raw,width=1920,height=1080’ ! videoconvert ! tee ! v4l2sink device=/dev/video3

Définition du pipeline à PAUSED…
[0:02:20.506805809] [1033] INFO Camera camera_manager.cpp:296 libcamera v0.0.0+2736-579f55b1-dirty (2021-07-01T03:47:30-04:00)
[0:02:20.512779501] [1035] WARN CameraSensor camera_sensor.cpp:197 ‘arducam-pivariety 10-000c’: Recommended V4L2 control 0x009a0922 not supported
[0:02:20.526663732] [1035] WARN CameraSensor camera_sensor.cpp:249 ‘arducam-pivariety 10-000c’: The sensor kernel driver needs to be fixed
[0:02:20.526744335] [1035] WARN CameraSensor camera_sensor.cpp:251 ‘arducam-pivariety 10-000c’: See Documentation/sensor_driver_requirements.rst in the libcamera sources for more information
[0:02:20.530254995] [1035] WARN CameraSensorProperties camera_sensor_properties.cpp:109 No static properties available for ‘arducam-pivariety’
[0:02:20.530340561] [1035] WARN CameraSensorProperties camera_sensor_properties.cpp:111 Please consider updating the camera sensor properties database
[0:02:20.530401389] [1035] WARN CameraSensor camera_sensor.cpp:403 ‘arducam-pivariety 10-000c’: Failed to retrieve the camera location
[0:02:20.777296357] [1035] ERROR IPAProxy ipa_proxy.cpp:149 Configuration file ‘arducam-pivariety.json’ not found for IPA module ‘raspberrypi’
Le pipeline est actif et n’a pas besoin de phase PREROLL…
[0:02:21.170157966] [1038] WARN V4L2 v4l2_pixelformat.cpp:181 Unsupported V4L2 pixel format XB24
Passage du pipeline à la phase PLAYING…
New clock: GstSystemClock

** (gst-launch-1.0:1033): CRITICAL **: 21:45:30.682: gst_video_format_to_string: assertion ‘format != GST_VIDEO_FORMAT_UNKNOWN’ failed
[0:02:21.188266436] [1038] INFO Camera camera.cpp:906 configuring streams: (0) 1920x1080-NV21
[0:02:21.188688358] [1035] INFO RPI raspberrypi.cpp:128 Mode: 4640x3472 fmt RG10 Score: 4102.12 (best 4102.12)
[0:02:21.188802847] [1035] INFO RPI raspberrypi.cpp:128 Mode: 2320x1732 fmt RG10 Score: 3077.86 (best 3077.86)
[0:02:21.188872766] [1035] INFO RPI raspberrypi.cpp:128 Mode: 3264x2464 fmt RG10 Score: 3541.31 (best 3077.86)
[0:02:21.188941000] [1035] INFO RPI raspberrypi.cpp:128 Mode: 3840x2160 fmt RG10 Score: 2250 (best 2250)
[0:02:21.189003661] [1035] INFO RPI raspberrypi.cpp:128 Mode: 2592x1944 fmt RG10 Score: 3217.33 (best 2250)
[0:02:21.189069433] [1035] INFO RPI raspberrypi.cpp:128 Mode: 1920x1080 fmt RG10 Score: 1500 (best 1500)
[0:02:21.189132741] [1035] INFO RPI raspberrypi.cpp:128 Mode: 1280x800 fmt RG10 Score: 3873.33 (best 1500)
[0:02:21.189195902] [1035] INFO RPI raspberrypi.cpp:128 Mode: 1280x720 fmt RG10 Score: 3500 (best 1500)
[0:02:21.189292004] [1035] INFO RPI raspberrypi.cpp:128 Mode: 4640x3472 fmt pRAA Score: 3602.12 (best 1500)
[0:02:21.189357997] [1035] INFO RPI raspberrypi.cpp:128 Mode: 2320x1732 fmt pRAA Score: 2577.86 (best 1500)
[0:02:21.189420121] [1035] INFO RPI raspberrypi.cpp:128 Mode: 3264x2464 fmt pRAA Score: 3041.31 (best 1500)
[0:02:21.189484207] [1035] INFO RPI raspberrypi.cpp:128 Mode: 3840x2160 fmt pRAA Score: 1750 (best 1500)
[0:02:21.189545609] [1035] INFO RPI raspberrypi.cpp:128 Mode: 2592x1944 fmt pRAA Score: 2717.33 (best 1500)
[0:02:21.189609065] [1035] INFO RPI raspberrypi.cpp:128 Mode: 1920x1080 fmt pRAA Score: 1000 (best 1000)
[0:02:21.189669689] [1035] INFO RPI raspberrypi.cpp:128 Mode: 1280x800 fmt pRAA Score: 3373.33 (best 1000)
[0:02:21.189733424] [1035] INFO RPI raspberrypi.cpp:128 Mode: 1280x720 fmt pRAA Score: 3000 (best 1000)
[0:02:21.244174843] [1035] INFO RPI raspberrypi.cpp:625 Sensor: /base/soc/i2c0mux/i2c@1/arducam@0c - Selected mode: 1920x1080-pRAA
[0:02:21.290109973] [1035] INFO RPISTREAM rpi_stream.cpp:122 No buffers available for ISP Output0
[0:02:21.290190558] [1035] INFO RPISTREAM rpi_stream.cpp:122 No buffers available for ISP Output0
[0:02:21.290245997] [1035] INFO RPISTREAM rpi_stream.cpp:122 No buffers available for ISP Output0
[0:02:21.290298659] [1035] INFO RPISTREAM rpi_stream.cpp:122 No buffers available for ISP Output0
[0:02:21.742576704] [1035] INFO RPI raspberrypi.cpp:1671 Dropping frame at the request of the IPA (7 left)
[0:02:21.763751286] [1035] INFO RPI raspberrypi.cpp:1671 Dropping frame at the request of the IPA (6 left)
[0:02:21.789800834] [1035] INFO RPI raspberrypi.cpp:1671 Dropping frame at the request of the IPA (5 left)
[0:02:21.811948454] [1035] INFO RPI raspberrypi.cpp:1671 Dropping frame at the request of the IPA (4 left)
[0:02:21.832797547] [1035] INFO RPI raspberrypi.cpp:1671 Dropping frame at the request of the IPA (3 left)
[0:02:21.853507468] [1035] INFO RPI raspberrypi.cpp:1671 Dropping frame at the request of the IPA (2 left)
[0:02:21.875114343] [1035] INFO RPI raspberrypi.cpp:1671 Dropping frame at the request of the IPA (1 left)
[0:02:21.908638984] [1035] INFO RPI raspberrypi.cpp:1671 Dropping frame at the request of the IPA (0 left)

and when i use your scipt on another console while the first run to test opencv :

import cv2
cap = cv2.VideoCapture(3)
while True:
ret, frame = cap.read()
cv2.imshow(“Arducam”, frame)
key = cv2.waitKey(1)
if key == ord(‘q’):
break

the response is :

VIDEOIO ERROR: V4L2: Pixel format of incoming image is unsupported by OpenCV
OpenCV Error: Assertion failed (size.width>0 && size.height>0) in imshow, file /build/opencv-L65chJ/opencv-3.2.0+dfsg/modules/highgui/src/window.cpp, line 304
Traceback (most recent call last):
File “test.py”, line 5, in
cv2.imshow(“Arducam”, frame)
cv2.error: /build/opencv-L65chJ/opencv-3.2.0+dfsg/modules/highgui/src/window.cpp:304: error: (-215) size.width>0 && size.height>0 in function imshow

I don’t manage to make it work
Could you please explain me what i do wrong and how to solve it ?
thanks a lot

Hi tityann

We encapsulate the Libcamera Python library, you can try to use this library to operate the camera.

Download libcamera python library URL

hello @yang
thanks you it work fine
can you please tell me how to do the same as

libcamera-still -t 0 --autofocus

with libcamera and python ?
thanks

Hi tityann

Sorry, I only see your question now.

You can add the following code in the controls_demo.py example to the place shown in the figure below:

elif key == ord('f'):
        cam.set(libcamera.AfTrigger, 1)

Screenshot from 2021-11-05 09-39-38

In this way, you can press “f” to auto focus.