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

Mirror Filter Example

In this notebook, we will demonstrate how to use the mirror filter. We utilize Pynq’s ability to buffer HDMI signals in order to perform a filter. The mirror filter is relatively simple. The image is flip horizontally, this mimics the reflection of a mirror

In order to perform this function, we need to buffer a row of RBG values. During the first row the HDMI signals are stalled. During the rest of the frame the previous row is displayed backwards while the current row is buffered. The delay cause by this buffering is very small and not noticeable to the human eye.

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 pynq.drivers.video import HDMI
from pynq import Bitstream_Part
from pynq.board import Register
from pynq import Overlay

Overlay("demo.bit").download()

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)
hdmi_out.mode(3)
hdmi_out.start()
hdmi_in.start()

3. Program board

Run the following script to download the Mirror Filter to the PYNQ.


In [3]:
Bitstream_Part("mirror_p.bit").download()

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):
    hdmi_out.stop()
    hdmi_in.stop()
    hdmi_out.start()
    hdmi_in.start()

items[0].on_click(on_hdmi_clicked)

widgets.VBox([items[0]])

4. User interface

Do to the simplisity of this filter there is no need for a user interface.

5. Exploration

As you can see the image has been flipped. This demostrates that the pynq is able to do image processing in real time.

6. Clean up

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


In [4]:
hdmi_out.stop()
hdmi_in.stop()
del hdmi_out
del hdmi_in