diff --git a/ext/CaesarImagesExt.jl b/ext/CaesarImagesExt.jl index 839830e78..81175f9a1 100644 --- a/ext/CaesarImagesExt.jl +++ b/ext/CaesarImagesExt.jl @@ -38,7 +38,7 @@ import Caesar: PackedScatterAlignPose2, PackedScatterAlignPose3 import Caesar: ImageTracks, FEATURE_VIA, FeatTrackValue, FeaturesDict, FeatureTracks, FeatureMountain, PIXELTRACK, MANYTRACKS import Caesar: addFeatureTracks_Frame1_Q!, addFeatureTracks_Frame2_PfwdQ!, addFeatureTracks_Frame2_QbckR! import Caesar: addFeatureTracks, consolidateFeatureTracks!, summarizeFeatureTracks!, buildFeatureMountain, buildFeatureMountainDistributed -import Caesar: unionFeatureMountain, sortKeysMinSighting +import Caesar: unionFeatureMountain, unionFeatureMountain!, sortKeysMinSighting # NOTE usage requires ImageFeatures.jl import Caesar: curateFeatureTracks diff --git a/ext/Images/FeatureMountain.jl b/ext/Images/FeatureMountain.jl index dac2d6416..cbfe50ad6 100644 --- a/ext/Images/FeatureMountain.jl +++ b/ext/Images/FeatureMountain.jl @@ -411,8 +411,6 @@ end ## union features - - function unionFeatureMountain( fMa::Dict{Tuple{Symbol,Int},MANYTRACKS}, fMb::Dict{Tuple{Symbol,Int},MANYTRACKS}, @@ -437,7 +435,27 @@ function unionFeatureMountain( return rM end - +function unionFeatureMountain!( + fMa::Dict{Tuple{Symbol,Int},MANYTRACKS}, + fMb::Dict{Tuple{Symbol,Int},MANYTRACKS}, +) + # Modify fMa by adding everything from fMb + for (ka,va) in fMb + # @info ka + # union if already exists + if haskey(fMa, ka) + # @info "CHECK TYPES" typeof(fMb[ka]) typeof(fMa[ka]) + for (kr,vr) in va + if !haskey(fMa[ka], kr) + fMa[ka][kr] = vr # union(fMb[ka], fMa[ka]) + end + end + else + fMa[ka] = va + end + end + return fMa +end function sortKeysMinSighting( featM::Dict{Tuple{Symbol,Int},<:Any}; @@ -492,10 +510,10 @@ function buildFeatureMountainDistributed( featM = deepcopy(featM_1[1]) # union other tracks into featM for fM in featM_1[2:end] - featM = Caesar.unionFeatureMountain(featM, fM) + featM = Caesar.unionFeatureMountain!(featM, fM) end for fM in featM_2 - featM = Caesar.unionFeatureMountain(featM, fM) + featM = Caesar.unionFeatureMountain!(featM, fM) end return featM diff --git a/ext/WeakdepsPrototypes.jl b/ext/WeakdepsPrototypes.jl index 8fd9df17a..3c23b0876 100644 --- a/ext/WeakdepsPrototypes.jl +++ b/ext/WeakdepsPrototypes.jl @@ -96,6 +96,7 @@ function buildFeatureMountain end function buildFeatureMountainDistributed end function unionFeatureMountain end +function unionFeatureMountain! end function sortKeysMinSighting end ## ==============================================