Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

video lags #3

Open
zoldaten opened this issue Apr 13, 2023 · 0 comments
Open

video lags #3

zoldaten opened this issue Apr 13, 2023 · 0 comments

Comments

@zoldaten
Copy link

i see video on page but it is bit too laggy.
so i tried to rewrite two parts of camera.py:

from picamera.array import PiRGBArray
from picamera import PiCamera
class VideoCamera(object):
    def __init__(self, flip = False, file_type = ".jpg", photo_string = "photo-taken"):
        #self.vs = PiVideoStream(resolution=(640, 480), framerate=30)
        self.vs = PiCamera(resolution=(640, 480), framerate=30)
        self.rawCapture = PiRGBArray(self.vs)
        
        #self.vs.start()
        #self.vs = PiVideoStream().start()

and

def get_frame(self):
        #frame = self.flip_if_needed(self.vs.read())
        for frame in self.vs.capture_continuous(self.rawCapture, format="bgr"):
            #ret, jpeg = cv.imencode(self.file_type, frame)
            self.rawCapture.truncate(0) 
            self.image = frame.array
            ret, jpeg = cv.imencode(self.file_type, self.image)            
            #self.previous_frame = jpeg
            return jpeg.tobytes()

dont know if it start working a bit faster...
may be a better solution is io.BytesIO()
https://stackoverflow.com/questions/40065328/picameravalueerror-incorrect-buffer-length-for-resolution-1920x1080

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant