@@ -136,16 +136,16 @@ def dense_lucaskanade(R, **kwargs):
136
136
next = np .ndarray .astype (next ,"uint8" )
137
137
138
138
# remove small noise with a morphological operator (opening)
139
- prvs = clean_image (prvs , n = size_opening )
140
- next = clean_image (next , n = size_opening )
139
+ prvs = _clean_image (prvs , n = size_opening )
140
+ next = _clean_image (next , n = size_opening )
141
141
142
142
# Shi-Tomasi good features to track
143
143
# TODO: implement different feature detection algorithms (e.g. Harris)
144
- p0 = ShiTomasi_features_to_track (prvs , max_corners_ST , quality_level_ST ,
144
+ p0 = _ShiTomasi_features_to_track (prvs , max_corners_ST , quality_level_ST ,
145
145
min_distance_ST , block_size_ST )
146
146
147
147
# get sparse u, v vectors with Lucas-Kanade tracking
148
- x0 , y0 , u , v = LucasKanade_features_tracking (prvs , next , p0 , winsize_LK ,
148
+ x0 , y0 , u , v = _LucasKanade_features_tracking (prvs , next , p0 , winsize_LK ,
149
149
nr_levels_LK )
150
150
151
151
# exclude outlier vectors
@@ -173,7 +173,7 @@ def dense_lucaskanade(R, **kwargs):
173
173
v = np .vstack (vStack )
174
174
175
175
# decluster sparse motion vectors
176
- x , y , u , v = declustering (x0 , y0 , u , v , decl_grid , min_nr_samples )
176
+ x , y , u , v = _declustering (x0 , y0 , u , v , decl_grid , min_nr_samples )
177
177
178
178
# append extra vectors if provided
179
179
if extra_vectors is not None :
@@ -183,15 +183,15 @@ def dense_lucaskanade(R, **kwargs):
183
183
v = np .concatenate ((v , extra_vectors [:, 3 ]))
184
184
185
185
# kernel interpolation
186
- X , Y , UV = interpolate_sparse_vectors (x , y , u , v , domain_size , function = function ,
186
+ X , Y , UV = _interpolate_sparse_vectors (x , y , u , v , domain_size , function = function ,
187
187
k = k , epsilon = epsilon , nchunks = nchunks )
188
188
189
189
if verbose :
190
190
print ("--- %s seconds ---" % (time .time () - t0 ))
191
191
192
192
return UV
193
193
194
- def ShiTomasi_features_to_track (R , max_corners_ST , quality_level_ST ,
194
+ def _ShiTomasi_features_to_track (R , max_corners_ST , quality_level_ST ,
195
195
min_distance_ST , block_size_ST ):
196
196
"""Call the Shi-Tomasi corner detection algorithm.
197
197
@@ -234,7 +234,7 @@ def ShiTomasi_features_to_track(R, max_corners_ST, quality_level_ST,
234
234
235
235
return p0
236
236
237
- def LucasKanade_features_tracking (prvs , next , p0 , winsize_LK , nr_levels_LK ):
237
+ def _LucasKanade_features_tracking (prvs , next , p0 , winsize_LK , nr_levels_LK ):
238
238
"""Call the Lucas-Kanade features tracking algorithm.
239
239
240
240
Parameters
@@ -287,7 +287,7 @@ def LucasKanade_features_tracking(prvs, next, p0, winsize_LK, nr_levels_LK):
287
287
288
288
return x0 , y0 , u , v
289
289
290
- def clean_image (R , n = 3 , thr = 0 ):
290
+ def _clean_image (R , n = 3 , thr = 0 ):
291
291
"""Apply a binary morphological opening to filter small isolated echoes.
292
292
293
293
Parameters
@@ -322,7 +322,7 @@ def clean_image(R, n=3, thr=0):
322
322
323
323
return R
324
324
325
- def declustering (x , y , u , v , decl_grid , min_nr_samples ):
325
+ def _declustering (x , y , u , v , decl_grid , min_nr_samples ):
326
326
"""Filter out outliers in a sparse motion field and get more representative
327
327
data points. The method assigns data points to a (RxR) declustering grid
328
328
and then take the median of all values within one cell.
@@ -389,7 +389,7 @@ def declustering(x, y, u, v, decl_grid, min_nr_samples):
389
389
390
390
return x , y , u , v
391
391
392
- def interpolate_sparse_vectors (x , y , u , v , domain_size , function = "inverse" ,
392
+ def _interpolate_sparse_vectors (x , y , u , v , domain_size , function = "inverse" ,
393
393
k = 20 , epsilon = None , nchunks = 5 ):
394
394
395
395
"""Interpolation of sparse motion vectors to produce a dense field of motion
0 commit comments