diff --git a/examples/tracking/visual/PyCV_TrackFeaturesFwdBck.jl b/examples/tracking/visual/PyCV_TrackFeaturesFwdBck.jl index 3f98618de..286b7b18e 100644 --- a/examples/tracking/visual/PyCV_TrackFeaturesFwdBck.jl +++ b/examples/tracking/visual/PyCV_TrackFeaturesFwdBck.jl @@ -49,7 +49,7 @@ function goodFeaturesToTrack(im1, feature_params; mask=nothing) cv.goodFeaturesToTrack(collect(reinterpret(UInt8, im1)), mask=collect(reinterpret(UInt8,mask)), feature_params...) end -function goodFeaturesToTrackORB(im1; mask=nothing, orb = cv.ORB_create(), downsample::Int=5, tolerance::Real = 0.1) +function goodFeaturesToTrackORB(im1; mask=nothing, orb = cv.ORB_create(), downsample::Int=1, tolerance::Real = 0.1) # gray = cv2.cvtColor(im1,cv.COLOR_BGR2GRAY) # kypts, decrs = orb.detectAndCompute(gray,None) # https://docs.opencv.org/3.4/d1/d89/tutorial_py_orb.html @@ -57,9 +57,13 @@ function goodFeaturesToTrackORB(im1; mask=nothing, orb = cv.ORB_create(), downsa img = collect(reinterpret(UInt8, im1)) kp = orb.detect(img, collect(reinterpret(UInt8,mask))) - # downselect a better distribution of features - rows, cols = size(img,1), size(img,2) - sel_kp = ssc(kp, orb.getMaxFeatures() ÷ downsample, tolerance, cols, rows) + sel_kp = if 1 < downsample + # downselect a better distribution of features + rows, cols = size(img,1), size(img,2) + ssc(kp, orb.getMaxFeatures() ÷ downsample, tolerance, cols, rows) + else + kp + end # compute the descriptors with ORB kp_, des = orb.compute(img, sel_kp)