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

VitTracker crush #261

Closed
saghavart opened this issue Jun 12, 2024 · 12 comments
Closed

VitTracker crush #261

saghavart opened this issue Jun 12, 2024 · 12 comments
Assignees
Labels
bug Something isn't working

Comments

@saghavart
Copy link

Hi. I am encountering the problem when some number of pixels from video input are black. The error message is "error: (-4:Insufficient memory) Failed to allocate 39768204675(this number is variable) bytes in function 'OutOfMemoryError". I have tried to manually change the number of black pixels and depending on that the tracker crushes or works correctly. Error is occuring when calling model.infer()

@fengyuentau
Copy link
Member

fengyuentau commented Jun 12, 2024 via email

@saghavart
Copy link
Author

Thank you for quick response. It's (640,480). I've also tried with (1280,720)

@saghavart
Copy link
Author

To reproduce , you can set number of pixels to 0 manually like this

frame[:,:,:] = 122
frame[:-padd, :-padd, :] = 0

@fengyuentau
Copy link
Member

Could you share the minimal reproducer?

@saghavart
Copy link
Author

saghavart commented Jun 12, 2024

Sure. Just insert following 3 lines in line 108 of demo.py file

padd = 70
frame[:,:,:]=122
frame[:-padd, :-padd, :] = 0

and run demo.py file

@fengyuentau
Copy link
Member

fengyuentau commented Jun 12, 2024

I tried with these three lines on my m1 macbook. Things are it did not crash but went very slow with your three lines of code. Also tried commented out frame[:,:,:]=122, it went smooth again. I guess some internal computation has problem with a massive area of pixel value 122. So the problem isn't with black pixels.

@saghavart
Copy link
Author

Maybe this can help to reproduce. Remove those three lines, start camera, select an object and then close the camera with your hand or something black for 2-3 seconds. In my cases it writes target lost and then crushes

@fengyuentau
Copy link
Member

Okay, it can be reproduced on my side. Let me look into the issue tomorrow.

@fengyuentau fengyuentau added the bug Something isn't working label Jun 13, 2024
@fengyuentau fengyuentau self-assigned this Jun 13, 2024
@fengyuentau
Copy link
Member

Okay, the problem is confirmed. Problem is when the target is lost, the bounding box gets larger and larger (the wrong bounding box pattern is recorded regardless of score) and the size of roi grows until out-of-memory error. See crop_image and update:

https://github.com/opencv/opencv/blob/a03b81316782ae30038b288fd3568993fa1e3538/modules/video/src/tracking/tracker_vit.cpp#L75-L93

https://github.com/opencv/opencv/blob/a03b81316782ae30038b288fd3568993fa1e3538/modules/video/src/tracking/tracker_vit.cpp#L199-L203

@fengyuentau
Copy link
Member

I will submit a PR to fix this problem.

@fengyuentau
Copy link
Member

@saghavart I submitted a PR to fix the problem hopefully. Feel free to review and test it opencv/opencv#25760.

@fengyuentau
Copy link
Member

Hello @saghavart , my patch to fix the problem has been merged. Feel free to have a try on your side. Closing this issue for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants