PYNQ: PYTHON PRODUCTIVITY

Writing HDMI frames from scratch

I am using a TUL-2 board. I’m trying to display a static image on my HDMI display. I went through the code examples but they are mostly for hdmi-in-to-hdmi-out format. I wanted to be able to generate images from scratch (I know this will be slow).

I tried the following, expecting to make the screen white. It fills the screen but generally with random gibberish:

import time
import numpy as np 
import cv2
from pynq.overlays.base import BaseOverlay
from pynq.lib.video import *

base = BaseOverlay("base.bit")
hdmi_out = base.video.hdmi_out
hdmi_out.configure(VideoMode(640,480,8),pixelformat=PIXEL_BGR)
hdmi_out.start()  
newframe = hdmi_out.newframe() * 0 + [255,255,255]
newframe.coherent = True
hdmi_out.writeframe(newframe) 
time.sleep(5)
hdmi_out.close()

Expecting the newframe’s values to be multiplied by 0 then have 255,255,255 added to each, presumably resulting in a white cell everywhere (as if I’d done a #FFFFFF on a website).

Can someone see what I might be doing wrong and point me to relevant docs? I’d be happy to help improve such docs once I figure it out.

You need make sure that the image you are trying to draw is assigned to the contents of the frame object returned by newframe. So in your example you want to do:

newframe = hdmi_out.new_frame()
newframe[:] = [255,255,255]
hdmi_out.writeframe(newframe)

Peter