Lucas Kanade Feature Tracking, problem with bounding box and template update - python

I am implementing a Lucas Kanade Pyramidal Tracker in python based on affine transforms of the neighborhood of features chosen with Shi-Tomasi corner detector(as described here) for a video with 600 frames.
The algorithm works good, finds corners in the given Bounding Box in the first frame, and tracks those corners correctly, but there are to problems.
Some of the corners that I detect in the bounding box are not on the object that I want to track but on the background.
I need to transform de Bounding Box accordingly with the movement of the features tracked, but as the frames advance some features get lost and the bounding box starts growing instead of following the object.
To move the bounding box I am estimating a similarity transform between the previous and current corners and multiplying this transform with the corners of the boundingbox
How could I fix these problems?
Thank you very much!

Related

Take the image inside a contour and place the irregular contour at a specific location on another image

I have a rotated object (clips for wires for a motherboard)
which I have then used Thresholding and findContours to get the contour of the region of interest (in green). It is an irregular shape which may not always be a rectangle. I know the coordinates I was to place the center of this image on within the section of the motherboard
but do not know how to do this without using bg[y:y+obj_h, x:x+obj_w] = obj, which would assume rectangular shape and would introduce a large noise perimeter surrounding the rotated image. I have tried using transparency around the object, which does not work with cv2. The target goal is this
Any help would be appreciated.

How to find optical flow only inside bounding box?

I'm using the Lucas-Kanade sparse optical flow method where I'm finding feature points using the Shi-Tomasi corner detector Good Features to Track.
How do I detect feature points only inside the bounding box?
How about cropping the BB from the image, and running the Shi-Tomasi on the cropped image, then adding the offset of the BB (upper left corner coords) to the key-points.

How can I estimate missing bounding box outputs using known bounding box data of a sequence?

I am getting vehicle detections from YOLO with a video input. And I got some missing bounding box outputs for some frames. How can I get bounding box estimations for those missing frames using other known bounding boxes and centers of that sequence just by using coordinate geometry without using any advance tracking method?
Thanks!
One way would be to just interpolate between adjacent frames. When a bounding box is missing in a frame but is present in adjacent frames, you can take the coordinates of the bounding boxes and calculate the average. If you want to make it more eleborate you can even include more frames and add a weight to weigh closer frames heavier.

Finding Circles from Partial Circular Shapes

I am writing a program to analyze microscopy images. I have an edge mapping of an image that looks like this:
The program I have written draws bounding boxes around circular shapes, but when the contours are not closed (like in the image above) it struggles and the resulting bounding box can include multiple circles.
So given this image, is there a way to differentiate between the two circular (or ovular) bodies, so the bounding boxes accurately enclose each shape?
(The image is an example of a bounding box incorrectly drawn around multiple circles)
If all/most your error cases look like the above one, i.e. with bounding boxes that should be further subdivided, you could try to use robustified fitting of ellipses to the edge points.

Why YOLOv3 calculate the offset values for adjusting the anchor boxes, not directly output the dimension of the bounding box?

I'm trying to understand about how YOLOv3 works. And this thing still confuses me: YOLO can determine the bounding box (the coordinates and dimensions), but why it doesn't output these value directly, instead of using them to adjust the anchor boxes?
Most object detection algorithms compute offset (x, y, width, height) for bounding boxes compared to a fixed anchor.
Anchors are generally generated to follow a fix grid: for each location on the grid a set of anchors of different aspect ratios and different areas are created.
It's much easier for the learning algorithm to output an offset from the fixed anchor from which it can deduce the overall coordinate rather than trying to find the overall coordinate directly because it's a local and position-invariant feature.
It means that if there is a dog with a mis-centered bounding box on the top-left of the picture, the algorithm is asked to output the offset as if the dog were on the bottom-right of the picture, which makes it robust to shift and does not require it to learn the global position of the object in the image.

Categories

Resources