Don't forget to delete the hdmi_out and hdmi_in when finished

Grayscale Filter Example

In this notebook, we will explore the averaging of RGB values. Each color is made up of some mixture of red, green, and blue (More information in RGB Filter Example). To convert an image to grayscale, the values of red, green, and blue are added together and then divided by three to get the average color value. This averaged value is the new color value that is used for each red, green, and blue values. This creates a "black and white" image which is comprised of different shades of grey.

This diagram shows the conversion of colors to grayscale.

This notebook will use a video filter that will convert any image to a grayscale ("black and white") image.

1. Download base overlay to the board

Ensure that the camera is not connected to the board. Run the following script to provide the PYNQ with its base overlay.

In [1]:
from import HDMI
from pynq import Bitstream_Part
from pynq.board import Register
from pynq import Overlay


2. Connect camera

Physically connect the camera to the HDMI-in port of the PYNQ. Run the following code to instruct the PYNQ to capture the video from the camera and to begin streaming video to your monitor (connected to the HDMI-out port).

In [2]:
hdmi_in = HDMI('in')
hdmi_out = HDMI('out', frame_list=hdmi_in.frame_list)

3. Program board with Grayscale Filter

Run the following script to download the Grayscale Filter to the PYNQ. This will allow us to modify the colors of the video stream.

In [3]:

4. Create HDMI Reset Button

Run the following script to create an HDMI Reset button that can be used to reset the HDMI if there are issues.

In [4]:
import ipywidgets as widgets
from ipywidgets import Button, HBox, VBox, Label

words = ['HDMI Reset']
items = [Button(description=w) for w in words]

def on_hdmi_clicked(b):



5. Clean up

When you are done playing with the Grayscale filter, run the following code to stop the video stream

In [5]:
del hdmi_out
del hdmi_in