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