3

I have coded a script that records a video for a specific time interval through a PiCamera and saves it in a defined Folder. I use the method VideoWriter and the method write. The script works perfectly when I run it on the host but if I containerize it The script does not work. It runs but it does not save anything in the container. I don't understand why. This is the function body that records the video.

        #print(time.time())
        videoLength = time.time() + int(seconds)
        #print(videoLength)
        #while(time.time()<videoLength and int(time.time())<=int(endTime)):
        fourcc = cv2.VideoWriter_fourcc(*'XVID')
        out = cv2.VideoWriter(filename, fourcc, fps, (640,480))
        while(time.time()<videoLength):
            #print("time.time", time.time())
            #print("Length-video", videoLength)
            #print("I'm here!")
            font = cv2.FONT_HERSHEY_SCRIPT_COMPLEX
            dt = str(datetime.datetime.now())
            #print("inside while")
            #print(time.time())
            frame = self.get_frame()
            out.write(frame)

The function get_frame is:

def get_frame(self):
        ret, frame = self.video.read()
        # DO WHAT YOU WANT WITH TENSORFLOW / KERAS AND OPENCV
        #print(ret)
        if ret:
            return frame
        else:
            raise ValueError

  • Why have you removed all your `import` statements and the code that opens the camera for reading? It just makes it harder for people to help you. – Mark Setchell Jun 19 '21 at 21:58

0 Answers0