Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 5825

Troubleshooting • Re: Using Picamera2 With Cv2 / OpenCv

$
0
0
With 4.6 installed via apt, I get the same error as you (black screen) with your code. V3 camera on a Pi 5 with Bookworm.
However, this works to add a timestamp to an image

Code:

# cv2-stamp.py from picamera2 manual 8.2.1#import timefrom picamera2 import Picamera2, MappedArrayimport cv2picam2 = Picamera2()colour = (0, 255, 0)origin = (0, 30)font = cv2.FONT_HERSHEY_SIMPLEXscale = 1thickness = 2def apply_timestamp(request):  timestamp = time.strftime("%Y-%m-%d %X")  with MappedArray(request, "main") as m:    cv2.putText(m.array, timestamp, origin, font, scale, colour, thickness)picam2.pre_callback = apply_timestamppicam2.start(show_preview=True)time.sleep(5)
Does that work for you?

Statistics: Posted by neilgl — Tue Apr 23, 2024 12:54 pm



Viewing all articles
Browse latest Browse all 5825

Trending Articles