I was convinced that in order to use the picamera V2 with openCV I needed to pass by picamera module in python or libraries such as raspicam in C++. However today I saw the following code working in a Raspberry Pi 4 with Raspbian Buster, which left me confused..

import cv2
import numpy as np

cap = cv2.VideoCapture(0, cv2.CAP_V4L)
if not cap.isOpened():
    raise IOError("Error")
while True:
    ret, frame = cap.read()
    filename = "img.jpg"
    cv2.imwrite(filename, frame)

Has this changed lately? Just curious..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.