Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP]Add boosting tracker #20

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/ImageTracking.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ include("core.jl")
include("optical_flow.jl")
include("haar.jl")
include("utility.jl")
include("tracker.jl")

export

Expand Down Expand Up @@ -54,8 +55,10 @@ export

# types that select implementation
ConvolutionImplementation,
MatrixImplementation

MatrixImplementation,

# tracking algorithms
BoxROI,
TrackerBoosting

end
17 changes: 17 additions & 0 deletions src/boosting_tracker/boosting_tracker.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#-----------------------------------
# Implementation of boosting tracker
#-----------------------------------

function init_tracker(tracker::TrackerBoosting, boxRoI::BoxROI)
# sampling

# compute harr haar_features

# model

# Run model estimation and update for initial iterations
end

function update_tracker(tracker::TrackerBoosting, image::AbstractArray)

end
20 changes: 20 additions & 0 deletions src/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,23 @@ function pinv2x2(M::AbstractArray)
D = SMatrix{2,2,Float64}( S[1,1] > tol ? 1/S[1,1] : 0.0 , 0.0, 0.0, S[2,2] > tol ? 1/S[2,2] : 0.0 )
U*D*V'
end

mutable struct TrackerTargetState
#Initialized
position::SVector{2, Float64}
height::Int
width::Int
is_target::Bool

#Uninitialized
responses::Array{T, 2} where T
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the purpose of responses? If it is needed, then you should declare T as part of the struct, for example:
mutable struct BoostingTrackerTargetState{T <: AbstractArray} <: AbstractTrackerTargetState
responses::T
See: https://docs.julialang.org/en/v1/manual/performance-tips/index.html#Avoid-containers-with-abstract-type-parameters-1


TrackerTargetState(position::SVector{2, Float64}, height::Int, width::Int, is_target::Bool) = new(
position, height, width, is_target)
end

mutable struct ConfidenceMap
states::Vector{TrackerTargetState}
Deepank308 marked this conversation as resolved.
Show resolved Hide resolved
confidence::Vector{Float64}
end

69 changes: 69 additions & 0 deletions src/tracker.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
abstract type AbstractTracker end

abstract type AbstractROI end
mutable struct BoxROI{T <: AbstractArray, S <: AbstractArray} <: AbstractROI
img::T
bound::S
end

mutable struct TrackerBoosting{I <: Int, F <: Float64, B <: BoxROI} <: AbstractTracker
Deepank308 marked this conversation as resolved.
Show resolved Hide resolved
# initialized
boxROI::B
num_of_classifiers::I
sampler_overlap::F
sampler_search_factor::F
initial_iterations::I
num_of_features::I

# constructor
function TrackerBoosting{I, F, B}(box::B, num_of_classifiers::I = 100, sampler_overlap::F = 0.99,
sampler_search_factor::F = 1.8, initial_iterations::I = 20,
num_of_features::I = 1050)where {I <: Int, F <: Float64, B <: BoxROI}
Deepank308 marked this conversation as resolved.
Show resolved Hide resolved
if size(box.bound, 1) != 4
error("Invalid bounding box size")
end

if box.bound[1] < 1 && box.bound[1] > size(box.img)[1]
error("Invalid bounding box")
end
if box.bound[2] < 1 && box.bound[2] > size(box.img)[2]
error("Invalid bounding box")
end
if box.bound[3] < 1 && box.bound[3] > size(box.img)[1]
error("Invalid bounding box")
end
if box.bound[4] < 1 && box.bound[4] > size(box.img)[2]
error("Invalid bounding box")
end

if box.bound[1] > box.bound[3]
error("Invalid bounding box")
end
if box.bound[2] > box.bound[4]
error("Invalid bounding box")
end

new(box, num_of_classifiers, sampler_overlap, sampler_search_factor, initial_iterations, num_of_features)
Deepank308 marked this conversation as resolved.
Show resolved Hide resolved
end
end

TrackerBoosting(boxROI::B, num_of_classifiers::I, sampler_overlap::F, sampler_search_factor::F,
initial_iterations::I, num_of_features::I) where {I <: Int, F <: Float64, B <: BoxROI} =
Deepank308 marked this conversation as resolved.
Show resolved Hide resolved
TrackerBoosting{I, F, B}(boxROI, num_of_classifiers, sampler_overlap, sampler_search_factor,
initial_iterations, num_of_features)

#---------------------
# TRACKER COMPONENTS
#---------------------

include("core.jl")
# include("tracker_state_estimator.jl")
# include("tracker_model.jl")
# include("tracker_sampler.jl")
# include("tracker_features.jl")

#------------------
# IMPLEMENTATIONS
#------------------

include("boosting_tracker/boosting_tracker.jl")
Deepank308 marked this conversation as resolved.
Show resolved Hide resolved