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

IndexError: list index out of range #7

Closed
ghost opened this issue Feb 27, 2019 · 11 comments
Closed

IndexError: list index out of range #7

ghost opened this issue Feb 27, 2019 · 11 comments

Comments

@ghost
Copy link

ghost commented Feb 27, 2019

I used an avi file of Morris water maze (circular arena) and I encountered an error. I attached the video I used.

After lesion.zip

Traceback (most recent call last):
File "track.py", line 266, in
floorCrop(filename)
File "track.py", line 120, in floorCrop
tetragonVertices = tetragons[0]
IndexError: list index out of range

And I would like to know if wanted to use mp4 with h.264 codec what should I change in track.py?

@colinlaney
Copy link
Owner

colinlaney commented Feb 27, 2019

I've fixed the error, but you'll face to another problem: the threshold between animal color and background color is very specific for my lab environment, therefore contour of your animal is corrupted.

So I'll try to make the threshold more adaptive, or at most to replace my detecting algorithm by common one, e.g. GOTURN. Thank you for new video provided with different environment, Shahrukh.

@colinlaney
Copy link
Owner

As to file extension: you just need to replace all .avi by .mp4 in the end of track.py.

@ghost
Copy link
Author

ghost commented Mar 22, 2019

water-maze-lesion.zip
The trajectory of animal is not shown by the animal-tracking app and it shows the distance travelled by the animal is very negligible. How to correct the errors? And how to optimise it for circular arena? Can binary threshold images processed by Fiji used if the animal is not as white as snow in the video? I get some errors like encoder error when binary threshold videos are used

@ghost
Copy link
Author

ghost commented Mar 22, 2019

How much light intensity in lux is needed during video recording for perfect tracking of the animal?

@colinlaney
Copy link
Owner

colinlaney commented Apr 15, 2019

The trajectory of animal is not shown by the animal-tracking app and it shows the distance travelled by the animal is very negligible. How to correct the errors?

Download v0.1.1 and just fill full right half of UI window by the green quad. Your mistake in water-maze-lesion.zip was the highlighting of only the part of arena. Green quad is needed to get rid of perspective effect that is caused by optical aberrations.

And how to optimise it for circular arena?

What you need to fit units of the distance is normalize it by the length of the average side of red quad you've selected as frame in UI measured in meters:

after_lesion_full

E.g. if the length between top right and bottom right points of red frame is 2.1 meters then divide the distance by 2.1.

Can binary threshold images processed by Fiji used if the animal is not as white as snow in the video? I get some errors like encoder error when binary threshold videos are used.

That is exactly what cv2.threshold() does in my code, so you don't need do any preprocessing. Actually, metamarking of your video with orange centroid of an animal and green quadrants of the arena are overly.

How much light intensity in lux is needed during video recording for perfect tracking of the animal?

Everyday working lighting 200–400 lx is enough.

@amirprobuetmir
Copy link

amirprobuetmir commented Apr 15, 2019

im still have a war with trying to count a speed ,
speed = _x =_y = 0
distance += np.sqrt(((x - _x) / float(h))**2 + ((y - _y) / float(h))**2)
speed=(distance)/abs(time.time())
# speed1=str(speed)
from where i can get Time ?) And also your code with last corrections does not work when im pressing python track.py
it just
shows again this
PS C:\users\dark\dev\animal-tracking-master>

@colinlaney
Copy link
Owner

colinlaney commented Apr 15, 2019

im still have a war with trying to count a speed

Are you sure you have read my answer? The item 3 states: there is a variable t that stores elapsed time measured in seconds. How do you think the time appears on the left frame? It is possible due to this variable. So, for elapsed time

speed = distance / t
print(speed)

From where i can get Time?)

From the variable t. I'm not kidding.

And also your code with last corrections does not work when im pressing python track.py

If you don't see red frame on the right side then you have to highlight it manually before you press Enter. Look at the gif above.

@ghost
Copy link
Author

ghost commented May 11, 2019

May I know how you avoided the errors caused by water ripples? I am unable to reproduce the same results for the video I used.

@colinlaney
Copy link
Owner

The only thing I did is average all frames and subtracted the sum from each current frame. It helped for your example, but not in general. Try to decrease THRESHOLD_ANIMAL_VS_FLOOR from 70 to 50: it will increase the area of animal and in the same time will make it possible to take the dark ripples for the animal.

We can introduce Kalman filter if you will continue facing the problem.

@ghost
Copy link
Author

ghost commented May 23, 2019

But what you say is actually the latest commits you did to tracker.py. Did you edit the video to get the results that avoid the errors caused by water ripples. I'm unable to reproduce the same result with the latest release.

@colinlaney
Copy link
Owner

No, I did not. I use raw video you have attached. The only differences between our environments are OS and version of python modules, mine are:

  • macOS
  • opencv-contrib-python==4.0.0.21
  • numpy==1.15.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants