Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to write/display video frame into /dev/fb1 with open('/dev/fb1', 'rb+')?

I am trying to write a video frame into Linux framebuffer fb1. My code is

cap = cv2.VideoCapture(0)
while cap.is_Opened():
    ret, frame = cap.read()
    with open('/dev/fb1', 'rb+') as buf:
       buf.write(frame)
cap.release()

so now i can display my video frame on framebuffer fb1, but is not clean please see the output video frame in below picture. I am also open to suggestion if any better(or efficient) way to do it.

  1. I already used mmap.mmap to write into the frame buffer 1, but it is giving me the same output.
  2. I also tried using os.environ['SDL_FBDEV'] = '/dev/fb1' in a different thread so that i can use two framebuffers at a same time. (here I can get a clear image but I can use only one framebuffer which I do not want to do)
  3. I have also tried converting video frame into bytearray()

enter image description here

this is my one of the ideas to solve my problem working with two framebuffers simultaneously. the black area will be used for display GUI by framebuffer 0 by os.environ['SDL_FBDEV'] = '/dev/fb0' for more information please see my old question https://stackoverflow.com/questions/53116843/how-to-use-2-framebuffers-dev-fbx-to-display-gui-and-video-frame-at-same-time

Thank you in advanced