I'm trying to track a rat in a box from videos that have already been taken. I need the distance the rat has traveled and a heatmap of the box based on where the rat has been. The videos are monochromatic red and the camera refocuses a few times. The rats are multicolored black/brown and white. The floor is white and the walls are black or black and white striped. There are other objects in the box that sometimes fall over. There is an arm that reaches into the box multiple times throughout the video. The rat sometimes holds still in the same place for a long time.
I tried to use the tracking api but it quickly loses the object regardless of the tracker type. I tried using absdiff and thresholding and tracking that but it again loses the object depending on how you draw the ROI.
I tried using absdiff with multiple reference frames that are addWeighted but with the new reference frame, the object is in the frame and is then used as part of the background.
I tried to use background subtraction without learning but when objects fall over or the camera refocuses it causes a lot of noise. I also tried with learning but since the object holds still for a while at times, the object is lost in the background.
Are there any other ways I could do this to make it work?