According to this Picamera document, Picamera can capturing frame as openCV object. but seems not working . how can i get frames from Picamera and add opencv filters in realtime. Rpi 3b+ . Python 2.7 i need an example code please.
import time
import picamera
import numpy as np
import cv2
with picamera.PiCamera() as camera:
camera.resolution = (320, 240)
camera.framerate = 24
time.sleep(2)
image = np.empty((240 * 320 * 3,), dtype=np.uint8)
camera.capture(image, 'bgr')
image = image.reshape((240, 320, 3))
Edit: 23rd April, 2022. Ok. I'm going back to your previously original coded. I'm using picamera v1. kindly, try to understanding.
while cap.isOpened()
is equivalent tocamera.start_preview()
You need time interval how long do you want to stay. So I set time.sleep(30) for 30 seconds. Do not usedimage.reshape
. You already havecamera.resolution = (320, 240)
. So here is previously coded. So I commented it out. try this:Here another one how to save multiple images.