Skip to content

Commit 78c99c9

Browse files
committed
update doc
1 parent 5086d67 commit 78c99c9

File tree

3 files changed

+95
-10
lines changed

3 files changed

+95
-10
lines changed

README.md

+75
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,55 @@ Dependencies:
8080
This demo uses [pygame](https://www.pygame.org/) for visualization and
8181
[PyAudio](http://people.csail.mit.edu/hubert/pyaudio/) for microphone recording.
8282

83+
## Real time 2D FFT of webcam
84+
85+
In this demonstration we perform online 2D fft of a webcam input. Both the
86+
absolute value and the log of the absolute values are displayed and the 0
87+
frequency is centered on the window (fftshift).
88+
89+
Screenshot:
90+
91+
![screenshot](data/screen_fft.png "screenshot")
92+
93+
Shortcuts:
94+
95+
* <kbd>q</kbd> : Quit demo
96+
* <kbd>s</kbd> : Save screen to png
97+
* <kbd>Space</kbd> : Pause FFT
98+
* <kbd>w</kbd> : Active or deactivate windowing
99+
100+
101+
Dependencies:
102+
103+
This demo uses [opencv-python](https://github.com/skvark/opencv-python) for
104+
webcam access and visualization.
105+
106+
107+
108+
## Real time 2D filtering of webcam
109+
110+
In this demonstration we perform online 2D filtering of a webcam input. Both the
111+
original, filtered and FFT of the filtered video with 0
112+
frequency centered on the window (fftshift) are displayed.
113+
114+
Screenshot:
115+
116+
![screenshot](data/screen_2dfilter.png "screenshot")
117+
118+
Shortcuts:
119+
120+
* <kbd>q</kbd> : Quit demo
121+
* <kbd>s</kbd> : Save screen to png
122+
* <kbd>Space</kbd> : Apply/deactivate filter
123+
* <kbd>f</kbd> : Change filter (average, high pass, Prewitt, Sobel, median, ...)
124+
* <kbd>+</kbd> <kbd>-</kbd> : Change cutoff frequency of filter (or its size)
125+
* <kbd>w</kbd> : Active or deactivate windowing
126+
127+
Dependencies:
128+
129+
This demo uses [opencv-python](https://github.com/skvark/opencv-python) for
130+
webcam access and visualization.
131+
83132
## 2D classification demo
84133

85134
In this demonstration we illustrate the decision function and update of 2D
@@ -103,6 +152,32 @@ Dependencies:
103152
This demo uses [pygame](https://www.pygame.org/) for visualization and
104153
[Scikit-learn](https://scikit-learn.org/) for classification.
105154

155+
## 2D Dictionary learning demo
156+
157+
In this demonstration we illustrate dictionary learning on 2D data. The user cla
158+
click on the window to add samples (left click) and to remove samples (right
159+
click). The dictionary is learned in real time and the atoms are displayed.
160+
161+
162+
163+
![screenshot](data/screen_dico_2D.png "screenshot")
164+
165+
* <kbd>q</kbd> : Quit demo
166+
* <kbd>left click</kbd> : Add sample
167+
* <kbd>right click</kbd> : Remove sample
168+
* <kbd>c</kbd> : Clear training data
169+
* <kbd>Space</kbd> : Show/hide dictionary atoms and color samples wrt their representation
170+
* <kbd>m</kbd> : Change method (PCA, ICA KMeans, NMF, SparsePCA, DictionaryLearning)
171+
* <kbd>p</kbd> : Show projected and reconstructed samples
172+
* <kbd>Up</kbd> : Increment the number of atoms
173+
* <kbd>Down</kbd> : Decrement the number of atoms
174+
* <kbd>s</kbd> : save screenshot
175+
176+
Dependencies:
177+
178+
This demo uses [pygame](https://www.pygame.org/) for visualization and
179+
[Scikit-learn](https://scikit-learn.org/) for classification.
180+
106181

107182
## Style Transfer Demo
108183

demos.ini

+15
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,16 @@ text=Real time Total Variation demo on webcam
99
depends=opencv-python\nprox_tv
1010
file=demos/demo_tv.py
1111

12+
[fft]
13+
text=Real time FFT of webcam
14+
depends=opencv-python
15+
file=demos/demo_fft.py
16+
17+
[2dfilter]
18+
text=Real time 2D filtering of webcam
19+
depends=opencv-python
20+
file=demos/demo_2d_filter.py
21+
1222
[ot]
1323
text=Demo of Optimal Transport between discrete dstributions
1424
depends=pygame>1.9.1\nPOT\nnumpy\nscipy
@@ -19,6 +29,11 @@ text=Demo of 2D classification (LDA, SVM)
1929
depends=numpy\nscipy\nscikit-learn
2030
file=demos/demo_classif_2D.py
2131

32+
[dicolearn_2D]
33+
text=Demo of 2D Dictionary learning (PCA, ICA, NMF, Sparse DL, KMeans)
34+
depends=numpy\nscipy\nscikit-learn
35+
file=demos/demo_dicolearn_2D.py
36+
2237
[style_transfer]
2338
text=Demo style transfer between images
2439
depends=numpy\ntorch\ntorchvision\nopencv-python

demos/demo_2d_filter.py

+5-10
Original file line numberDiff line numberDiff line change
@@ -101,17 +101,17 @@ def apply(x):
101101
def apply(x):
102102
h=np.array([[-1,0,1],[-1,0,1],[-1,0,1]])/3
103103
return np.maximum(np.minimum(sp.signal.convolve(x,h,'same'),1),0)
104-
txt= 'Prewit Horiz. Abs.'
104+
txt= 'Prewitt Horiz. Abs.'
105105
if idfilt==5:
106106
def apply(x):
107107
h=h=np.array([[-1,0,1],[-1,0,1],[-1,0,1]]).T/3
108108
return np.maximum(np.minimum(sp.signal.convolve(x,h,'same'),1),0)
109-
txt= 'Prewit Vert. Abs.'
109+
txt= 'Prewitt Vert. Abs.'
110110
if idfilt==6:
111111
def apply(x):
112112
h=h=np.array([[-1,0,1],[-1,0,1],[-1,0,1]]).T/3
113113
return abs(sp.signal.convolve(x,h,'same'))**.5+abs(sp.signal.convolve(x,h.T,'same'))**.5
114-
txt= 'Prewit Both Abs.'
114+
txt= 'Prewitt Both Abs.'
115115
if idfilt==7:
116116
def apply(x):
117117
h=np.array([[-1,0,1],[-2,0,2],[-1,0,1]])/4
@@ -228,13 +228,8 @@ def apply(x):
228228
cut=0.5
229229
if (key & 0xFF) in [ ord('F')]:
230230
idfilt-=1
231-
if (key & 0xFF) in [ ord('h')]:
232-
if not half:
233-
do_tv=True
234-
half=True
235-
else:
236-
half=False
237-
231+
s=1
232+
cut=0.5
238233

239234
# When everything done, release the capture
240235
cap.release()

0 commit comments

Comments
 (0)