opencv_trail_effect.cpp: make the window resizeable
[experiments/opencv_trail_effect.git] / README
1 opencv_trail_effect is an experiment about recreating the "trail effect"[1],
2 which can be seen in some cool music videos, automatically and in real-time,
3 and even without the use of a green-screen.
4
5 [1] http://dailypsychedelicvideo.com/tag/trail-effect/
6
7 Some examples of it are:
8
9   The Jacksons - Blame It On The Boogie - https://www.youtube.com/watch?v=mkBS4zUjJZo
10   OK Go - WTF? - https://www.youtube.com/watch?v=12zJw9varYE
11   Elisa - L'Anima Vola - https://www.youtube.com/watch?v=MqhxIQD16EA
12   Kool & The Gang - Get Down On It - https://www.youtube.com/watch?v=qchPLaiKocI
13   Kool & The Gang - Steppin' Out - https://www.youtube.com/watch?v=KRuiVyq2Akc
14   Earth, Wind & Fire - September - https://www.youtube.com/watch?v=Gs069dndIYk
15
16 opencv_trail_effect draws a trail after performing foreground segmentation
17 using OpenCV.
18
19 Segmentation in opencv_trail_effect can done using either thresholding or
20 background subtraction.
21
22 A few conditions are required to create a decent effect:
23
24   1. the camera should not move;
25   2. the lighting in the scene should be quite stable (when doing background
26      subtraction it is recommended to disable auto-gain in the camera, and
27      avoid any artifact introduced by the power line frequency);
28   3. the subject should enter the scene only after the background learning
29      phase has finished, i.e. after opencv_trail_effect has shown the preview
30      window.
31
32
33 Examples of use
34 ---------------
35
36 The effect in "Blame It On The Boogie" could be described as a short faded
37 trail and can be achieved with this command line:
38
39   $ ./opencv_trail_effect -l 12 -s background -d fadeaccumulate
40
41
42 The effect in "WTF?" is equivalent to an infinite trail in which the isolated
43 foreground is copied on the background and stays there, it can be achieved
44 with this command line:
45
46   $ ./opencv_trail_effect -l -1 -s background -d copy
47
48
49 The effect in "L'Anima Vola" seems to have a "catch-up" behavior; that one can
50 be done by drawing the trail in reverse, with this command line:
51
52   $ ./opencv_trail_effect -l 30 -s background -d copy -r
53
54
55 Another effect seen in movies can be obtained by doing the average of the
56 frames in the trail, possibly with the most recent frame drawn on top:
57
58   $ ./opencv_trail_effect -l 10 -s background -d average -B
59
60 Here is a video showing the examples from above:
61 https://www.youtube.com/watch?v=X3oRozxt2O4
62
63 Side note
64 -------------------
65
66 These effects can bring to mind other cool effects in music videos, like the
67 frame shuffling effect in Peter Gabriel's Sledgehammer
68 (https://www.youtube.com/watch?v=OJWJE0x7T4Q), that one can be done with the
69 nervousTV plugin from effectv
70 (https://fukuchi.org/research/effectv/index.html.en) or frei0r filters
71 (https://www.dyne.org/software/frei0r/), for example with:
72
73   $ gst-launch-1.0 -v v4l2src ! videoconvert ! frei0r-filter-nervous ! videoconvert ! autovideosink