Blob tracking via GoCV package
Important notice: It is better to use mot-go now for tracking tasks.
This small package implements basics of blob tracking: simple centroid and Kalman filter-based tracking
There are additional functions for checking if blob crossed horizontal (or even oblique) line.
First of all you need OpenCV to be installed on your operation system. Also you need GoCV package to be installed too. Please see ref. here https://github.com/hybridgroup/gocv#how-to-install
Then you are good to go with:
go get github.com/LdDl/gocv-blob/v2
## or (if you want to use legacy version):
## go get github.com/LdDl/gocv-blob
p.s. do not be worried when you see can't load package: package github.com/LdDl/gocv-blob: no Go files.... - this is just warning.
It's pretty straightforward (pseudocode'ish).
// 1. Define global set of blobs
global_blobs = blob.NewBlobiesDefaults()
// 2. Define new blob objects
new_blob1 = blob.NewSimpleBlobie(image.Rectangle, how many points to store in track, class ID of object , class name of object)
new_blob2 = blob.NewSimpleBlobie(image.Rectangle, how many points to store in track, class ID of object , class name of object)
// You can use NewKalmanBlobie if needed
// 3. Append data to temporary set of blobs
tmp_blobs = []*blob.Blobie{new_blob1, new_blob2}
// 4. Compare blobs ()
global_blobs.MatchToExisting(tmp_blobs)
// 5. Repeat steps 2-4 every time when you find new objects on images. MatchToExisting() will update existing blobs and register new ones.
More informative example is here: v2/array_tracker_test.go
FOR LEGACY v1:
Click to expand
// 1. Define global set of blobs
global_blobs = blob.NewBlobiesDefaults()
// 2. Define new blob objects
new_blob1 = blob.NewBlobie(image.Rectangle, how many points to store in track, class ID of object , class name of object)
new_blob2 = blob.NewBlobie(image.Rectangle, how many points to store in track, class ID of object , class name of object)
// 3. Append data to temporary set of blobs
tmp_blobs = []*blob.Blobie{}
tmp_blobs = append(tmp_blobs, new_blob1)
tmp_blobs = append(tmp_blobs, new_blob2)
// 4. Compare blobs ()
global_blobs.MatchToExisting(tmp_blobs)
// 5. Repeat steps 2-4 every time when you find new objects on images. MatchToExisting() will update existing blobs and register new ones.
If you have troubles or questions please open an issue.
Big thanks to creators and developers of GoCV for providing bindings to OpenCV