RP Zero with new system and caemra module 3 - camera libs incompatibility

22 views Asked by At

I am trying to refactor old camera code in my RP Zero. It looks like everything's changed in new version of the OS and old libs are no longer there or incompatible.

In the old code I could do this to create the stream:

import cv2
from imutils.video.pivideostream import PiVideoStream
import imutils
import time
import numpy as np

class VideoCamera(object):
    def __init__(self, flip = False):
        self.vs = PiVideoStream().start()
        self.flip = flip
        time.sleep(2.0)

    def __del__(self):
        self.vs.stop()

    def flip_if_needed(self, frame):
        if self.flip:
            return np.flip(frame, 0)
        return frame

    def get_frame(self):
        frame = self.flip_if_needed(self.vs.read())
        ret, jpeg = cv2.imencode('.jpg', frame)
        return jpeg.tobytes()

In new reality it seems no longer valid.

First thing I tried: I noticed that "imutils" lib is no longer installed together with cv2 so I have installed it manually with pip. I guess this lib is old version and it's not compatible any more. It is calling "picamera" lib where this lib is now "picamera2" I guess. I tried to create symlink to change it's name but it failed either.

Second try was to install imutils2 instead but this lib is completely different and I don't really understand why it has the same name.

So at this stage I got stuck with the code, I don't know how to make it working again. Any advice would be very appreciated.

0

There are 0 answers