<jupyter_start><jupyter_text>Image Overlay  This overlays the frame with a small 256 tone image First you download the bit file.<jupyter_code>from pynq.overlays.video import *
from pynq.lib.video import *

base = VideoOverlay("video.bit")
hdmi_in = base.video.hdmi_in
hdmi_out = base.video.hdmi_out<jupyter_output><empty_output><jupyter_text>Then start up the PRControl, the video will not work otherwise. It initailzes the Video Axi Switch so HDMI runs through the VDMA.<jupyter_code>from pynq.overlays.video import PRControl
pr_inst = PRControl()<jupyter_output><empty_output><jupyter_text>The best video sources are computers where you can control the resoltuion.<jupyter_code>hdmi_in.configure()
hdmi_out.configure(hdmi_in.mode,PIXEL_BGR)
hdmi_out.start()
hdmi_in.start()
hdmi_in.tie(hdmi_out)<jupyter_output><empty_output><jupyter_text>Here is a frame in VDMA.<jupyter_code>import PIL.Image
import cv2
frame = hdmi_in.readframe()
frame = cv2.cvtColor(frame,cv2.COLOR_BGR2RGB)
image = PIL.Image.fromarray(frame)
image<jupyter_output><empty_output><jupyter_text>The Image Overlay has to be loaded in.  The image overlay only fits into L0 Connect the HDMI_IN to L0 and L0 to VDMA and VDMA to HDMI_OUT<jupyter_code>pr_inst.connect("HDMI_IN","L0")
pr_inst.connect("L0","VDMA")
pr_inst.connect("VDMA","HDMI_OUT")
PartialBitstream("image_l0.bit").download()
import PIL.Image
import cv2
frame = hdmi_in.readframe()
frame = cv2.cvtColor(frame,cv2.COLOR_BGR2RGB)
image = PIL.Image.fromarray(frame)
image<jupyter_output><empty_output><jupyter_text>Now we can change the settings of the sobel filter Image Overlay Settings * 0 Set X Offset* 1 Set Y Offset* 2 Set Width* 3 Set Height* 4 Write Pixel & increment write index* 5 Set Write Index* 6 Set Transparent Colorpr_inst.filter_cmd("filter name",cmd,data) [256 Colors](http://www.calmar.ws/vim/256-xterm-24bit-rgb-color-chart.html) Try out different images<jupyter_code>pr_inst.filter_cmd("L0",0,400)
pr_inst.filter_cmd("L0",1,300)
pr_inst.filter_cmd("L0",6,0)
pr_inst.filter_cmd("L0",5,0)
filename = "./BYU_Stretch_Y.bin"
with open(filename, "rb") as f:
    width = f.read(1)
    height = f.read(1)
    num_pixels = width[0]*height[0]
    for i in range(0, num_pixels):
            byte = f.read(1)
            x = byte[0];
            pr_inst.filter_cmd("L0",4,x)
import PIL.Image
import cv2
frame = hdmi_in.readframe()
frame = cv2.cvtColor(frame,cv2.COLOR_BGR2RGB)
image = PIL.Image.fromarray(frame)
image
pr_inst.filter_cmd("L0",0,1700)
pr_inst.filter_cmd("L0",1,860)
pr_inst.filter_cmd("L0",6,0)
pr_inst.filter_cmd("L0",5,0)
filename = "./cougar_256.bin"
with open(filename, "rb") as f:
    width = f.read(1)
    height = f.read(1)
    num_pixels = width[0]*height[0]
    for i in range(0, num_pixels):
            byte = f.read(1)
            x = byte[0];
            pr_inst.filter_cmd("L0",4,x)
import PIL.Image
import cv2
frame = hdmi_in.readframe()
frame = cv2.cvtColor(frame,cv2.COLOR_BGR2RGB)
image = PIL.Image.fromarray(frame)
image
pr_inst.filter_cmd("L0",0,400)
pr_inst.filter_cmd("L0",1,400)
pr_inst.filter_cmd("L0",6,0)
pr_inst.filter_cmd("L0",5,0)
filename = "./medallion_256.bin"
with open(filename, "rb") as f:
    width = f.read(1)
    height = f.read(1)
    num_pixels = width[0]*height[0]
    for i in range(0, num_pixels):
            byte = f.read(1)
            x = byte[0];
            pr_inst.filter_cmd("L0",4,x)
import PIL.Image
import cv2
frame = hdmi_in.readframe()
frame = cv2.cvtColor(frame,cv2.COLOR_BGR2RGB)
image = PIL.Image.fromarray(frame)
image
hdmi_out.close()
hdmi_in.close()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1297327394209354, 'fraction_numerical': 0.03507795100222717, 'mean_word_length': 5.038655462184874, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '75758', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 1454, 'n_tokens_neox': 1414, 'n_words': 289, 'path': 'Video_notebooks/Image Overlay.ipynb', 'repo_name': 'kendermag/BYU_PYNQ_PR_Video_Pipeline', 'size': '3592'}