# [Interactive 2] Exercise 1 – Mirror

A magic mirror that reflects yourself only at a certain distant range. The closer you are, the darker the mirror gets.

The Original
Electronic Mirror

How It Works
Sensing
Firstly, I need to retrieve frame from the camera by using jit.grab and add in an ‘Open’ and ‘Close’ to open the camera. Since it should be a mirror, it has to be inverted either using jit.matrix but I used jit.dimmap instead. However it also converted my camera from 4-plane char ARGB into 1-plane char monochrome (jit.rgb2luma) so I should keep in mind to convert it back later.
Computing
Next, the brightness of the reflected image would be affected by the values of the bounding box created around the face. The bounding box has 2 corners (top left and bottom right) as shown below.
Let’s say the (x,y) values of top corner is (x1, y1) while the bottom corner is (x2, y2). Therefore the width is x2 – x1 and height is y2-y1. Then, the size of the box is w x h (x2-x1) x (y2-y1). Scale is applied to map an input range of float values to an output range of float.

Effecting
Lastly, I need to find the faces on the image captured by the camera earlier by using cv.jit.faces. To draw in the bounding box (or face tracking),  cv.jit.faces.draw is used. cv.jit.resize @resize 160 120 is an option to resize that box.

Challenges
One of the challenges I encountered in this assignment was to get the proper range of values to manipulate the brightness of the reflection. Another challenge that I did not manage to solve was to have a smooth transition when the face appear or disappear abruptly. Some limitations when using face tracking include jerking when more than one face  were detected.

The Interaction