colinlaney / animal-tracking

Object tracking with OpenCV in open field behavioral test (overhead view maze)
https://youtu.be/GebcshN4OdE
Creative Commons Zero v1.0 Universal
50 stars 23 forks source link

Code not running properly #22

Closed Cruz1946 closed 1 year ago

Cruz1946 commented 1 year ago

Hi! Thank you again for all the help till now. I run the code and it lets me select the ROI, but when i press space ou enter to confirm the window just vanishes. On the console i can see the code running, but it doesnt do anything.

colinlaney commented 1 year ago

Try to reduce the resolution of your video first. The sample video is 600p, 1080p might be too much for your GPU/CPU, so you couldn't wait for the processing to begin. I can't hypothesize smarter without more input.

May I close #20 and #21?

Cruz1946 commented 1 year ago

Yes you may close those ones.

I'd really like to know the way you select your mice to do the tracking, because i have a code of my own and it sometimes works fine except when the tracker gets lost. Im using an CSRT tracker, but surely its not the best way to track a mice since he moves his body on many directions. Im sorry to be bothering you so much lately, but i dont have much support of my project coordinator.

Best regards, Rafael Cruz

colinlaney @.***> escreveu no dia domingo, 11/06/2023 à(s) 00:08:

Try to reduce the resolution of your video. The sample video https://github.com/colinlaney/animal-tracking/blob/b5572529176c4a5467421780111d060832c84f70/rat.avi is 600p, 1080p https://github.com/colinlaney/animal-tracking/issues/20#issue-1731387736 might be too much for your GPU/CPU, so you couldn't wait for the processing to begin. I can't hypothesize smarter without more input.

May I close #20 https://github.com/colinlaney/animal-tracking/issues/20 and #21 https://github.com/colinlaney/animal-tracking/issues/21?

— Reply to this email directly, view it on GitHub https://github.com/colinlaney/animal-tracking/issues/22#issuecomment-1585844810, or unsubscribe https://github.com/notifications/unsubscribe-auth/BAJ5L5ZBLHYC4LDX6YTMLBLXKT47LANCNFSM6AAAAAAY6MH47M . You are receiving this because you authored the thread.Message ID: @.***>

colinlaney commented 1 year ago

CSRT is a learnable method that shows great results when object is overlapped by others, meanwhile, it is unstable when the object is lost for a long time (your case?) as well as my method. There are many other methods in OpenCV, try them as well.

My method is not learnable. Most of the code is serving the user interface whereas the idea is as straightforward as possible.

Since color and light conditions are controllable, all the core do is

  1. Differentiates a light area from a dark area by the threshold. In the most contrast case, the mice were white, the floor was glossy black, so the light area is either the mouse or reflections of the light source
  2. Gets the biggest spot, assuming it is a mouse
  3. Looks for the center of mass of the spot to
  4. track this very point.

If you are familiar with Python and have a GPU, use Detectron, or Yolo, or other state-of-the-art object detectors.

Cruz1946 commented 1 year ago

I ended up using a threshold method also. But i had to edit my video since the mice was black. Thank you for the suggestions to use yolo. I'll try them next, since my project is supose to be about deep learning. Thank you for all your help till now, you may close all our chats. Best regards

A terça, 13/06/2023, 18:22, colinlaney @.***> escreveu:

CSRT is a learnable method that shows great results when object is overlapped by others, meanwhile, it is unstable when the object is lost for a long time (your case?) as well as my method. There are many other methods in OpenCV https://broutonlab.com/blog/opencv-object-tracking, try them as well.

My method is not learnable. Most of the code is serving the user interface whereas the idea is as straightforward as possible.

Since color and light conditions are controllable, all the core do is

  1. Differentiates https://github.com/colinlaney/animal-tracking/blob/9f9fa589e03c49be0f82159844ec6b6a9723c713/track.py#L202-L203 a light area from a dark area by the threshold https://github.com/colinlaney/animal-tracking/blob/9f9fa589e03c49be0f82159844ec6b6a9723c713/track.py#L11. In the most contrast case, the mice were white, the floor was glossy black, so the light area is either the mouse or reflections of the light source
  2. Gets the biggest light spot https://github.com/colinlaney/animal-tracking/blob/9f9fa589e03c49be0f82159844ec6b6a9723c713/track.py#L207-L208, assuming it is a mouse
  3. Looks for the center of mass https://github.com/colinlaney/animal-tracking/blob/9f9fa589e03c49be0f82159844ec6b6a9723c713/track.py#L209-L213 of the spot to
  4. track this very point https://github.com/colinlaney/animal-tracking/blob/9f9fa589e03c49be0f82159844ec6b6a9723c713/track.py#L204-L217

If you are familiar with Python and have a GPU, use Detectron https://github.com/facebookresearch/detectron2, or Yolo https://github.com/WongKinYiu/yolov7, or other state-of-the-art object detectors.

— Reply to this email directly, view it on GitHub https://github.com/colinlaney/animal-tracking/issues/22#issuecomment-1589727739, or unsubscribe https://github.com/notifications/unsubscribe-auth/BAJ5L56CVDMWGK3VP5F244DXLCOVPANCNFSM6AAAAAAY6MH47M . You are receiving this because you authored the thread.Message ID: @.***>