Done by: Mavis & Bridgel
- Jumpy transition of brightness decrease and increase
- Reverse Image (to emulate mirror)
- Max/min limit of brightness depending on face distance
- Auto startup
Solutions in Code:
1. Jumpy transition of brightness decrease and increase
Under p area2brightness patcher, the object ‘line 0 50’ and its connected message ‘$1 100’ is edited in order to make the transition of decrease/increase in brightness smoother. The function of the object line is to generate a timed ramp. The initial value of ‘100’ is in milliseconds, which means that each ramp is generated taking the value of face area from the face recognition and passed every 100 milliseconds. By increasing this value to 1000 milliseconds, the ramp is generated every second, allowing for a smoother transition.
The patcher p-spacebar fullscreen contains the object ‘key’ followed by ‘select 32’. The value 32 is associated on the keyboard as the spacebar. It is followed by toggle and ‘fullscreen $1’, where $1 takes the value of the previous toggle object and releases the output to Jit.window. This patcher combined with Jit-window allows the program to toggle between full-screen and windowed states of the final video output when the spacebar is used.
3. Reverse Image
The object jit.dimmap is added, connected to ‘pak invert 0 0’ connected to two toggle buttons. The toggle button on the left is to inverse the output horizontally while the toggle button on the right inverses the output vertically. Hence, only the left button has to be toggled for the image to inverse to emulate the mirror effect.
4. Max-min limit of brightness depending on face distance
In order to optimise the user experience (based on the space available, for example), the sensitivity related to face size can be adjusted under ‘p area2brightness’. The line ‘scale 0 12345 0. 1.’ can be edited based on testing for this. By checking the approximate area output of the face at the distance you would like the program to start decreasing the brightness of the video output (i.e. furthest distance – check value output of ‘expr (($i3-$i1)*($i4-$i2))’ where you would like the brightness to start decreasing), enter this approximate value into the first value after ‘scale’. In rough terms, the 4 values after ‘scale’ corresponds to minimum input, maximum input, minimum output and maximum output. Hence, take the next approximate value of when you would like the screen to completely blackout (i.e. face close to the camera) and input it as the second value after ‘scale’. This can be easily edited based on the space. Based on our testing, our current ideal minimum and maximum was 500 and 8000. Hence, our final code states ‘scale 500 8000 0. 1.’
The scale function is necessary as the following object after it only takes values from 0 to 1.
5. Auto startup
In order for the program to start automatically in fullscreen mode when the code is opened from the folder, a total of two toggle buttons have to be activated (‘p video in’ and ‘pak invert 0’). Hence, the ‘loadbang’ command was inserted directly above ‘pak invert 0’ to ensure that the output video starts inversed, like a mirror. In order to give the program some time to inverse the output video first, the patcher ‘p initial delay’ is written with ‘loadbang’ followed by ‘delay 2000’ which delays the video input by 2 seconds.