Object tracking: GOTURN - failed to allocate 90 GB cv::OutOfMemoryError

asked 2019-12-09 05:06:55 -0500

Vytau gravatar image

updated 2019-12-09 07:57:41 -0500

Akhil Patel gravatar image

I am trying to implement the GOTURN object tracking algorithm as described in this link. The error occurs as the tracker gets initiallized with the first image is passed over:

bbox = cv2.selectROI(frame, False)
ok, frame = video.read()
ok = tracker.init(frame, bbox)

cv2.error: OpenCV(4.1.2-dev) \opencv\modules\core\src\alloc.cpp:73: error: (-4:Insufficient memory)
Failed to allocate 95588562276 bytes in function 'cv::OutOfMemoryError'

Well, apparently, the algorithm tries to allocate almost 90 GB of memory, which is somehow crazy. I use the caffe model and the prototxt files from here.

Does anyone have any idea?

edit retag flag offensive close merge delete

Comments

I have no idea, but funny things tend to happen with bad data, so I'd check the sanity of the frame and bbox.

mvuori gravatar imagemvuori ( 2019-12-09 09:10:09 -0500 )edit
1

i tried on colab , 25gb ram wasn't enough ;(

edit: it seems to work with 3.4.8, so it's a regression.

i think, you should raise an issue here

berak gravatar imageberak ( 2019-12-11 04:32:05 -0500 )edit
1

we can also reproduce it with a simple:

net = cv2.dnn.readNet("goturn.caffemodel", "goturn.prototxt")
berak gravatar imageberak ( 2019-12-11 05:38:16 -0500 )edit

@berak. The code will work under 3.x.x. Unfortunately doesn't work OpenCV 4.x.x. Fortunaltey, I managed to get it working for merely OpenCV 4.

  • Could not find GOTURN model in current directory.
  • Please ensure goturn.caffemodel and goturn.prototxt are in the current directory.
  • Select a ROI and then press SPACE or ENTER button!
  • Cancel the selection process by pressing c button!

Snippet:

 if not(os.path.isfile('goturn.caffemodel') and os.path.isfile('goturn.prototxt')):
         errorMsg = '''
         Could not find GOTURN model in current directory.
         Please ensure goturn.caffemodel and goturn.prototxt are in the current directory
         '''
         print(errorMsg)
         sys.exit()
supra56 gravatar imagesupra56 ( 2019-12-11 07:41:18 -0500 )edit

@supra56, imho, the problem is a regression in the dnn, not the tracker code (or python specific)

berak gravatar imageberak ( 2019-12-11 07:46:24 -0500 )edit

@berak Thank you. I guess I am gonna have to open the issue...

Vytau gravatar imageVytau ( 2019-12-11 08:58:46 -0500 )edit

any updates on this ? shall i move to a less recent version of opencv?

aya sal gravatar imageaya sal ( 2020-01-16 15:59:19 -0500 )edit

@aya sal -- unfortunately, no updates or fix so far.

berak gravatar imageberak ( 2020-01-17 01:46:25 -0500 )edit