Go to advanced search

by trlaing
Fri Feb 24, 2023 12:37 pm
Forum: Camera board
Topic: Raspberry Pi Python Picamera2 Motion Detection Camera Frame Rate
Replies: 38
Views: 2286

Re: Raspberry Pi Python Picamera2 Motion Detection Camera Frame Rate

Glad that it works! The only minor thing to watch out for is that if you don't start AF immediately you can get metadata with no lens position in it, which can make code fall over. But if you're always enabling it in some way then you should be fine. It's okay, I only used it to find the best lens ...
by trlaing
Fri Feb 24, 2023 11:56 am
Forum: Camera board
Topic: Raspberry Pi Python Picamera2 Motion Detection Camera Frame Rate
Replies: 38
Views: 2286

Re: Raspberry Pi Python Picamera2 Motion Detection Camera Frame Rate

If you want to print the value onto the image I would use the pre_callback method, as shown here . To get hold of the lens position in the pre_callback, use something like this: lens_pos_string = str(request.get_metadata().get('LensPosition')) Thank you! I used the following to round to 2 decimal p...
by trlaing
Fri Feb 24, 2023 11:03 am
Forum: Camera board
Topic: Raspberry Pi Python Picamera2 Motion Detection Camera Frame Rate
Replies: 38
Views: 2286

Re: Raspberry Pi Python Picamera2 Motion Detection Camera Frame Rate

If you're using Picamera2, X-Windows and one of the supplied preview window implementations, then you can do picam2.title_fields = ['LensPosition'] I am not using X-Windows as it is a headless Pi. Can I get the 'LensPosition' into a string? I tried lens_position = picam2.camera_controls["LensP...
by trlaing
Fri Feb 24, 2023 10:05 am
Forum: Camera board
Topic: Raspberry Pi Python Picamera2 Motion Detection Camera Frame Rate
Replies: 38
Views: 2286

Re: Raspberry Pi Python Picamera2 Motion Detection Camera Frame Rate

Is there a way to output the lens position live while it is focusing? In auto focus mode it does sometimes focus where I want, but as the scene changes it goes in and out of focus. If I can get the lens position values live (I can overlay the value on the video to see it), I can pick one that suits ...
by trlaing
Wed Feb 15, 2023 10:24 am
Forum: Camera board
Topic: Raspberry Pi Python Picamera2 Motion Detection Camera Frame Rate
Replies: 38
Views: 2286

Re: Raspberry Pi Python Picamera2 Motion Detection Camera Frame Rate

I can't really share images as there are people in them and they wouldn't like their pictures shared. Is there a way to output the lens position live while it is focusing? In auto focus mode it does sometimes focus where I want, but as the scene changes it goes in and out of focus. If I can get the ...
by trlaing
Wed Feb 15, 2023 9:43 am
Forum: Camera board
Topic: Raspberry Pi Python Picamera2 Motion Detection Camera Frame Rate
Replies: 38
Views: 2286

Re: Raspberry Pi Python Picamera2 Motion Detection Camera Frame Rate

I found the following in the Picamera 2 Library PDF: 5.2.1. Autofocus Modes and State The autofocus (AF) state machine has 3 modes, and its activity in each of these modes can be monitored by reading the "AfState" metadata that is returned with each image. The 3 modes are: • Manual - The l...
by trlaing
Tue Feb 14, 2023 2:12 pm
Forum: Camera board
Topic: Raspberry Pi Python Picamera2 Motion Detection Camera Frame Rate
Replies: 38
Views: 2286

Re: Raspberry Pi Python Picamera2 Motion Detection Camera Frame Rate

I've decided to give up on the auto focus as it is not working well at all, with the focus changing all the time and not actually focusing on where I want it to. picam2.set_controls({ "FrameRate": frame_rate, "AfMode" : controls.AfModeEnum.Manual, "LensPosition": 0.0 })...
by trlaing
Sat Feb 04, 2023 6:09 am
Forum: Camera board
Topic: Raspberry Pi Python Picamera2 Motion Detection Camera Frame Rate
Replies: 38
Views: 2286

Re: Raspberry Pi Python Picamera2 Motion Detection Camera Frame Rate

After fighting with some Python version and dependency issues (I'm not a coder!!!), I've got this far: [0:08:24.285458295] [1990] INFO Camera camera_manager.cpp:299 libcamera v0.0.3+40-9b860a66 [0:08:24.409161126] [1991] INFO RPI raspberrypi.cpp:1425 Registered camera /base/soc/i2c0mux/i2c@1/imx708...
by trlaing
Fri Feb 03, 2023 8:29 am
Forum: Camera board
Topic: Raspberry Pi Python Picamera2 Motion Detection Camera Frame Rate
Replies: 38
Views: 2286

Re: Raspberry Pi Python Picamera2 Motion Detection Camera Frame Rate

Yes, of course. It's not the tidiest code as I've just been tweaking away at it, but here its: #!/usr/bin/python3 import time, os from datetime import datetime from libcamera import controls, Rectangle import numpy as np from picamera2 import Picamera2, MappedArray from picamera2.encoders import H26...
by trlaing
Thu Feb 02, 2023 11:20 am
Forum: Camera board
Topic: Raspberry Pi Python Picamera2 Motion Detection Camera Frame Rate
Replies: 38
Views: 2286

Re: Raspberry Pi Python Picamera2 Motion Detection Camera Frame Rate

I believe the following line achieves the above:

Code: Select all

cur = cur[:w * h].reshape(h, w)[300:428, 300: 540]
This is cropping the 480x640 numpy array to a 128x240 array below and left to the centre of the image. I think it is working...
by trlaing
Thu Feb 02, 2023 9:08 am
Forum: Camera board
Topic: Raspberry Pi Python Picamera2 Motion Detection Camera Frame Rate
Replies: 38
Views: 2286

Re: Raspberry Pi Python Picamera2 Motion Detection Camera Frame Rate

The next thing I would like to do is only focus on motion changes in a small portion of the video. Camera.png I presume that the following lines look for changes in the entire image area resized to 640x480 pixels? Or does it just use the centre 640x480 pixels? video_resolution = (1920, 1080) lsize =...
by trlaing
Tue Jan 31, 2023 12:48 pm
Forum: Python
Topic: Python2 code to Python3 conversion for Ultraship U2 v2 scales
Replies: 6
Views: 440

Re: Python2 code to Python3 conversion for Ultraship U2 v2 scales

I have got it working with Python3 by making the following changes: Line 51 from self._buf = '' to self._buf = ''.encode() Line 98 from self._buf = self._buf[self._buf.find('\x02'):] to self._buf = self._buf[self._buf.find('\x02'.encode()):] Line 105 from return result to return result.decode() New ...
by trlaing
Mon Jan 30, 2023 10:23 am
Forum: Camera board
Topic: Raspberry Pi Python Picamera2 Motion Detection Camera Frame Rate
Replies: 38
Views: 2286

Re: Raspberry Pi Python Picamera2 Motion Detection Camera Frame Rate

Okay. When I start the camera, this is the output: [0:05:34.543091014] [2332] INFO Camera camera_manager.cpp:299 libcamera v0.0.3+40-9b860a66 [0:05:34.564807924] [2333] WARN CameraSensorProperties camera_sensor_properties.cpp:205 No static properties available for 'imx708_wide' [0:05:34.564866868] [...
by trlaing
Sat Jan 28, 2023 7:11 am
Forum: Camera board
Topic: Raspberry Pi Python Picamera2 Motion Detection Camera Frame Rate
Replies: 38
Views: 2286

Re: Raspberry Pi Python Picamera2 Motion Detection Camera Frame Rate

It should be fixed now. Try apt update/upgrade. The fixes are in libcamera0, python3-libcamera. Now the control accepts a list of tuple(s) of four integers: [ (x,y,w,h) ] measured in full-resolution pixels Usually, a single rectangle covering 1/12 - 1/4 of the total area gives best performance. Exa...
by trlaing
Fri Jan 27, 2023 10:16 am
Forum: Camera board
Topic: Raspberry Pi Python Picamera2 Motion Detection Camera Frame Rate
Replies: 38
Views: 2286

Re: Raspberry Pi Python Picamera2 Motion Detection Camera Frame Rate

libcamera-apps, libcamera-tools and python3-libcamera all updated today - is the AfWindows issue likely to be sorted? I'm scared to try it as my Raspberry Pi was crashing and I had to power off at the wall to restart it - don't like doing that!
by trlaing
Thu Jan 26, 2023 1:53 pm
Forum: Python
Topic: Python2 code to Python3 conversion for Ultraship U2 v2 scales
Replies: 6
Views: 440

Python2 code to Python3 conversion for Ultraship U2 v2 scales

Hi have a set of Ultraship U2 v2 scales that I am currently using Python 2 to read successfully, using the following code: #!/usr/bin/python import serial from ultraship_u2v2 import UltrashipU2v2 device = serial.Serial("/dev/ttyUSB0", 9600) scale = UltrashipU2v2(device) while True: print(&...
by trlaing
Wed Jan 25, 2023 7:11 am
Forum: Camera board
Topic: Raspberry Pi Python Picamera2 Motion Detection Camera Frame Rate
Replies: 38
Views: 2286

Re: Raspberry Pi Python Picamera2 Motion Detection Camera Frame Rate

So is there an apt picamera2 version we could go back to temporarily with setting AfWindows working? I looked back in github picamera2 repo history, and the answer seems to be no. I found a bad workkaround, not useful when wanting to change autofocus window from Pyth: execute "libcamera-vid -t...
by trlaing
Tue Jan 24, 2023 11:47 am
Forum: Camera board
Topic: Raspberry Pi Python Picamera2 Motion Detection Camera Frame Rate
Replies: 38
Views: 2286

Re: Raspberry Pi Python Picamera2 Motion Detection Camera Frame Rate

2. The focus in the image is not on the centre of the image, but on a shelf that is closer and makes the image very blurry. How can I make it focus on the centre of the image? That should be possible by setting "AfWindow" control with picamera2. I tried adding the line: picam2.set_control...
by trlaing
Tue Jan 24, 2023 11:06 am
Forum: Camera board
Topic: Raspberry Pi Python Picamera2 Motion Detection Camera Frame Rate
Replies: 38
Views: 2286

Re: Raspberry Pi Python Picamera2 Motion Detection Camera Frame Rate

Hi, thanks for the questions. 1. You can set the framerate to 15fps. I would do this after calling "configure", just before you call "start". picam2.set_controls({"FrameRate": 15}) 2. You might need to start continuous autofocus. In the same place add picam2.set_contro...
by trlaing
Tue Jan 24, 2023 9:50 am
Forum: Camera board
Topic: Raspberry Pi Python Picamera2 Motion Detection Camera Frame Rate
Replies: 38
Views: 2286

Raspberry Pi Python Picamera2 Motion Detection Camera Frame Rate

I am trying to write my own motion detection camera Python program for my Raspberry Pi for recording video when motion is detected. I have the following code using Python Picamera2: #!/usr/bin/python3 import time, os from datetime import datetime import numpy as np from picamera2 import Picamera2 fr...
by trlaing
Wed Jan 18, 2023 12:42 pm
Forum: Camera board
Topic: Raspberry Pi 4 Bullseye Pi Camera Module 3 picamera2 configuration failed
Replies: 15
Views: 829

Re: Raspberry Pi 4 Bullseye Pi Camera Module 3 picamera2 configuration failed

Yes! Fresh install of image (2022-09-22-raspios-bullseye-arm64.img.xz), no further installs of picamera2 as it is included. The Python test code works fine (I do get an error "RuntimeError: Failed to reserve DRM plane", but I guess this is due to it being headless?). The image and video fi...
by trlaing
Wed Jan 18, 2023 12:04 pm
Forum: Camera board
Topic: Raspberry Pi 4 Bullseye Pi Camera Module 3 picamera2 configuration failed
Replies: 15
Views: 829

Re: Raspberry Pi 4 Bullseye Pi Camera Module 3 picamera2 configuration failed

therealdavidp wrote:
Wed Jan 18, 2023 11:57 am
Yes. libcamera and Picamera2 work on 64-bit images.
Good, I'll write the latest 64-bit image and try it.
by trlaing
Wed Jan 18, 2023 11:53 am
Forum: Camera board
Topic: Raspberry Pi 4 Bullseye Pi Camera Module 3 picamera2 configuration failed
Replies: 15
Views: 829

Re: Raspberry Pi 4 Bullseye Pi Camera Module 3 picamera2 configuration failed

I just had a thought - my Raspberry Pi 4 has Bullseye 64-bit on it... Should this work on 64-bit?
by trlaing
Wed Jan 18, 2023 11:21 am
Forum: Camera board
Topic: Raspberry Pi 4 Bullseye Pi Camera Module 3 picamera2 configuration failed
Replies: 15
Views: 829

Re: Raspberry Pi 4 Bullseye Pi Camera Module 3 picamera2 configuration failed

I'm sorry it's proving difficult. But my advice is to install a fresh image, let it do its usual updates when it first boots, then touch/install absolutely nothing else, and it should just work. My original idea was to use it with the motion package, but it I couldn't get it to work with that eithe...
by trlaing
Wed Jan 18, 2023 11:04 am
Forum: Camera board
Topic: Raspberry Pi 4 Bullseye Pi Camera Module 3 picamera2 configuration failed
Replies: 15
Views: 829

Re: Raspberry Pi 4 Bullseye Pi Camera Module 3 picamera2 configuration failed

Hard to know for sure what's happening. pip often installs packages in your home directory, so you may have something lurking there, or somewhere else. Maybe search for every "picamera2" folder on your system and delete anything that isn't the apt one? I don't suppose installing a clean i...

Go to advanced search