#!/usr/bin/python3
from picamera2 import Picamera2
picam2 = Picamera2()
picam2.set_controls({"AfTrigger":0})
# Record a 5 second video.
picam2.start_and_record_video("test.mp4", duration=5)
But Iâm not sure I totally understand why⌠Which piece of what I was doing caused the issue?? When I tried to remove python3-libcamera it looked like it said that nothing was removed, but at the same time it seemed that after that things started working⌠Why would this be?
The thing is, libcamera itself is written in C and C++. We packaged him as a dynamic link library so that users can use it in python, and python3-libcamera does the same thing.
Installing python3-libcamera will result in an override that prevents the use of our libcamera, and thus our specific functionality.
picamera2 calls the first layer of wrappers and then makes a new one that is more user friendly.
@Edward whats the proper way to get opencv working with this camera? I noticed that if I do this:
sudo pip3 install opencv-contrib-python==4.5.3.56
Then I end up getting this error
python easy_video.py
Could not write header for output file #0 (incorrect codec parameters ?): Immediate exit requested
If I uninstall opencv everything works again. My goal is to do OCR an utilize other tensor flow recognition utilities. Is there a specific version or method of installing opencv recommended?
@Edward Iâm not sure I follow your last answer. If the script you sent me requires opencv to be installed, how can this work when after installing opencv the very simple easy_video.py no longer works?
@Edward I managed to get opencv_python installed. When I try to run python3 real_time.py --model mobilenet_v2.tflite --label coco_labels.txt
I get this error:
[194:16:09.999584747] [85494] WARN RPI raspberrypi.cpp:1274 Mismatch between Unicam and CamHelper for embedded data usage!
[194:16:10.000859887] [85494] ERROR DelayedControls delayed_controls.cpp:87 Delay request for control id 0x009a090a but control is not exposed by device /dev/v4l-subdev0
[194:16:10.001221340] [85494] INFO RPI raspberrypi.cpp:1398 Registered camera /base/soc/i2c0mux/i2c@1/imx519@1a to Unicam device /dev/media3 and ISP device /dev/media0
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib/python3.9/threading.py", line 954, in _bootstrap_inner
self.run()
File "/usr/lib/python3.9/threading.py", line 892, in run
self._target(*self._args, **self._kwargs)
File "/usr/local/lib/python3.9/dist-packages/picamera2/previews/qt_previews.py", line 22, in thread_func
self.qpicamera2 = self.make_picamera2_widget(picam2, width=self.width, height=self.height, transform=self.transform)
File "/usr/local/lib/python3.9/dist-packages/picamera2/previews/qt_previews.py", line 75, in make_picamera2_widget
return QGlPicamera2(picam2, width=self.width, height=self.height, transform=self.transform)
File "/usr/local/lib/python3.9/dist-packages/picamera2/previews/q_gl_picamera2.py", line 106, in __init__
self.init_gl()
File "/usr/local/lib/python3.9/dist-packages/picamera2/previews/q_gl_picamera2.py", line 142, in init_gl
self.create_surface()
File "/usr/local/lib/python3.9/dist-packages/picamera2/previews/q_gl_picamera2.py", line 136, in create_surface
surface = eglCreateWindowSurface(self.egl.display, self.egl.config,
File "/usr/lib/python3/dist-packages/OpenGL/platform/baseplatform.py", line 415, in __call__
return self( *args, **named )
File "/usr/lib/python3/dist-packages/OpenGL/error.py", line 230, in glCheckError
raise self._errorClass(
OpenGL.raw.EGL._errors.EGLError: EGLError(
err = EGL_BAD_ALLOC,
baseOperation = eglCreateWindowSurface,
cArguments = (
<OpenGL._opaque.EGLDisplay_pointer object at 0x7f790017c0>,
<OpenGL._opaque.EGLConfig_pointer object at 0x7f79001d40>,
c_void_p(1),
None,
),
result = <OpenGL._opaque.EGLSurface_pointer object at 0x7f78e09340>
)
Iâve followed all of the steps you have provided for trezero, but I ended up with the following error message:
AttributeError: type object 'libcamera._libcamera.ColorSpace' has no attribute 'Jpeg'
davidplowman whom I believe is a developer for picamera2 has indicated that the fix for this is to install python3-picamera2. When attempting to install it using:
sudo apt install -y python3-picamera2
I get the following message:
python3-picamera2 : Depends: python3-libcamera but it is not going to be installed E: Unmet dependencies. Try âapt --fix-broken installâ with no packages (or specify a solution).
You mentioned to not install python3-libcamera as this can lead to conflict. I want to be able to write Python Script and utilize Arducamâs AutoFocus. Currently it looks like I have to pick one or the other. How should I proceed?