oylz / DS

cpp deep_sort: C++ implementation of Simple Online Realtime Tracking with a Deep Association Metric
https://github.com/nwojke/deep_sort
GNU General Public License v3.0
250 stars 78 forks source link

Memory issues #10

Open DinoHubber opened 5 years ago

DinoHubber commented 5 years ago

Hi, thank you for providing a c++ implementation of DS. I am facing some issues with memory during the execution of the program. I am using opencv to read frames from the camera, pass it through a yolo object detector, then pass the bounding boxes to DS through UpdateAndGet.

However, sometimes while tracking, the program will crash out with the error msgs:

Error in `./DeepSort': free(): invalid next size (fast): 0x00000000021209b0 ======= Backtrace: ========= /lib/x86_64-linux-gnu/libc.so.6(+0x777e5)[0x7f63e050c7e5] /lib/x86_64-linux-gnu/libc.so.6(+0x8037a)[0x7f63e051537a] /lib/x86_64-linux-gnu/libc.so.6(cfree+0x4c)[0x7f63e051953c] ./DeepSort[0x42ac07] ./DeepSort[0x42e070] ./DeepSort[0x419c01] ./DeepSort[0x41a06d] ./DeepSort[0x41b8f6] ./DeepSort[0x41e0de] ./DeepSort[0x4361c4] ./DeepSort[0x411153] ./DeepSort[0x405f3d] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0)[0x7f63e04b5830] ./DeepSort[0x406719] ........

I dumb-ed down the program by removing the object detection part, and just giving deep sort a random bounding box that jitters around with each incoming frame (such that the tracker would still initiate and track a track). In fact, at a jitter of 0 pixels, aka a random FIXED bounding box, the memory error will not occur even after a long time. However, given a large enough jitter (like 10+ pixels), after awhile the memory error will throw. We suspect it's because of a memory leak issue.

Tracing where the program throws through print statements: UpdateAndGet -> FDSSTTracker::init -> FDSSTTracker::dsstInit -> FDSSTTracker::train_scale, FDSSTTracker::get_scale_sample, fhog, and it throws around here.

Any ideas? Thanks!

DinoHubber commented 5 years ago

I found out that in the error stated above, it was due to sz being 0 in bool fhog( float *M, float *O, float *H, int h, int w, int binSize, int nOrients, int softBin, float clip ) function which results in a return false. And somehow that throws the memory erorr.

In another experiment, I have an overarching main.cpp, and include NT.h and link deep sort as a shared library (compiled it as shared). Running this throws a very similar error at certain points during tracking:

Error in `./Rambu': double free or corruption (!prev): 0x0000000077a01220 ======= Backtrace: ========= /lib/x86_64-linux-gnu/libc.so.6(+0x777e5)[0x7f5f25f2c7e5] /lib/x86_64-linux-gnu/libc.so.6(+0x8037a)[0x7f5f25f3537a] /lib/x86_64-linux-gnu/libc.so.6(cfree+0x4c)[0x7f5f25f3953c] DeepSort/libdeepsort.so(_Z4fhogPfS_S_iiiiif+0xc19)[0x7f5f26bf57f9] DeepSort/libdeepsort.so(_Z4fhogPfiiiPiS0_S0_iifb+0x1ed)[0x7f5f26bf62dd] DeepSort/libdeepsort.so(_Z4fhogRKN2cv3MatEiifb+0x6d5)[0x7f5f26bf7395] DeepSort/libdeepsort.so(_ZN12FDSSTTracker16get_scale_sampleERKN2cv3MatE+0x517)[0x7f5f26be2ff7] DeepSort/libdeepsort.so(_ZN12FDSSTTracker11train_scaleEN2cv3MatEb+0x44)[0x7f5f26be6714] DeepSort/libdeepsort.so(_ZN12FDSSTTracker8dsstInitERKN2cv5Rect_IiEENS0_3MatE+0x1096)[0x7f5f26be8586] DeepSort/libdeepsort.so(_ZN12FDSSTTracker4initERKN2cv5Rect_IiEENS0_3MatE+0x1f7)[0x7f5f26bea8a7] DeepSort/libdeepsort.so(_ZN2NT12UpdateAndGetERKN2cv3MatERKSt6vectorINS0_5Rect_IiEESaIS6_EEiRS8_RKS4_IiSaIiEE+0x90f)[0x7f5f26bff85f] ./Rambu[0x40bab3] ./Rambu(main+0x63b)[0x40880b] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0)[0x7f5f25ed5830] ./Rambu[0x408f99]

Tracing this error, it seems like this error happens when it is trying to wrFree R1 in that said fhog function. Not sure if this is related to the previous issue, but seems like all these memory errors are occurring around the fhog stage.

zhangyanabc commented 5 years ago

Hi, thank you for providing a c++ implementation of DS. I am facing some issues with memory during the execution of the program. I am using opencv to read frames from the camera, pass it through a yolo object detector, then pass the bounding boxes to DS through UpdateAndGet.

However, sometimes while tracking, the program will crash out with the error msgs:

Error in `./DeepSort': free(): invalid next size (fast): 0x00000000021209b0 ======= Backtrace: ========= /lib/x86_64-linux-gnu/libc.so.6(+0x777e5)[0x7f63e050c7e5] /lib/x86_64-linux-gnu/libc.so.6(+0x8037a)[0x7f63e051537a] /lib/x86_64-linux-gnu/libc.so.6(cfree+0x4c)[0x7f63e051953c] ./DeepSort[0x42ac07] ./DeepSort[0x42e070] ./DeepSort[0x419c01] ./DeepSort[0x41a06d] ./DeepSort[0x41b8f6] ./DeepSort[0x41e0de] ./DeepSort[0x4361c4] ./DeepSort[0x411153] ./DeepSort[0x405f3d] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0)[0x7f63e04b5830] ./DeepSort[0x406719] ........

I dumb-ed down the program by removing the object detection part, and just giving deep sort a random bounding box that jitters around with each incoming frame (such that the tracker would still initiate and track a track). In fact, at a jitter of 0 pixels, aka a random FIXED bounding box, the memory error will not occur even after a long time. However, given a large enough jitter (like 10+ pixels), after awhile the memory error will throw. We suspect it's because of a memory leak issue.

Tracing where the program throws through print statements: UpdateAndGet -> FDSSTTracker::init -> FDSSTTracker::dsstInit -> FDSSTTracker::train_scale, FDSSTTracker::get_scale_sample, fhog, and it throws around here.

Any ideas? Thanks!

Hi, thank you for providing a c++ implementation of DS. I am facing some issues with memory during the execution of the program. I am using opencv to read frames from the camera, pass it through a yolo object detector, then pass the bounding boxes to DS through UpdateAndGet.

However, sometimes while tracking, the program will crash out with the error msgs:

Error in `./DeepSort': free(): invalid next size (fast): 0x00000000021209b0 ======= Backtrace: ========= /lib/x86_64-linux-gnu/libc.so.6(+0x777e5)[0x7f63e050c7e5] /lib/x86_64-linux-gnu/libc.so.6(+0x8037a)[0x7f63e051537a] /lib/x86_64-linux-gnu/libc.so.6(cfree+0x4c)[0x7f63e051953c] ./DeepSort[0x42ac07] ./DeepSort[0x42e070] ./DeepSort[0x419c01] ./DeepSort[0x41a06d] ./DeepSort[0x41b8f6] ./DeepSort[0x41e0de] ./DeepSort[0x4361c4] ./DeepSort[0x411153] ./DeepSort[0x405f3d] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0)[0x7f63e04b5830] ./DeepSort[0x406719] ........

I dumb-ed down the program by removing the object detection part, and just giving deep sort a random bounding box that jitters around with each incoming frame (such that the tracker would still initiate and track a track). In fact, at a jitter of 0 pixels, aka a random FIXED bounding box, the memory error will not occur even after a long time. However, given a large enough jitter (like 10+ pixels), after awhile the memory error will throw. We suspect it's because of a memory leak issue.

Tracing where the program throws through print statements: UpdateAndGet -> FDSSTTracker::init -> FDSSTTracker::dsstInit -> FDSSTTracker::train_scale, FDSSTTracker::get_scale_sample, fhog, and it throws around here.

Any ideas? Thanks!

Hello,I'm new to the multi object tracking field.I also want to change deepsort by using the yolov3 as the detector,and the fdsst as the tracker .Could I refer to your code and learn something?Thanks very much!

honggexiao commented 5 years ago

The same issue