You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
MaskRCNN doesnt work using cv::dnn::Net when image resolution changes of input images #14566
Forwarding images using MaskRCNN fails if the image resolution changes over time.
Steps to reproduce
It works for the first few images, but after about 5 images with each a different resolution no results are available anymore.
in the function postprocess(...)
outDetections = outDetections.reshape(1,(int)(outDetections.total() / 7)); always returns the same number for any forwarded image. Its being stuck at the number of the last successful forwarding.
The only thing that is missing is that the example does not habe a loop to always use the same two images.
Image A must have a different resolution than B and should contain RCNN model supported objects. In my case persons.
Forward image A (gives results)
Forward image B (gives results)
Forward image A (gives different results than in A1)
Forward image B (gives different results than in B1)
Forward image A (gives no results anymore)
Forward image B (gives no results anymore)
I can reinitialize each time the resolution changes. I use it to create binary masks for imageregions where humans are visible to improve Structure from Motion pipeline by avoiding matching dynamic scene parts.
@tompollok, But why not to resize each human ROI to specific size, predict on it and then remap to origin size? Anyway if you run network of different sizes it requires reallocation of memory if input size changed.
That i could do, too, but then the inference time scales linear with the number of people. I just reinitialize for now on resolution change. The inference time on CPU is quite slow anyways.
The reason why i reported this bug is because i thought that this bug might be an issue in general, not only for mask_rcnn.
@tompollok, It's not clear for me. How you select image regions and why not to run all the model on entire frame? Why not to resize each image region to specific size?
You dont have to say sorry. Im very thankful for you investigating it, so thank you for the patch! Its really awesome to see how fast the DNN backends have evolved, especcially in the last 12 months!
Activity
tompollok commentedon May 15, 2019
@alalek isn't this rather a bug than a feature?
dkurt commentedon May 18, 2019
Have you tried to use the latest version of OpenCV? I just want to check if this merged changes resolved your problem: #14552.
tompollok commentedon May 18, 2019
No only 4.1. Ill try master on Monday
tompollok commentedon May 20, 2019
Opencv 4.1 master did not resolve the issue.
I checked and the commit was already merged into master from 3.4
#14570
Here a video of the issue, that shows that the output of the forwarding is not deterministic and fails after forwarding the same pair of images after two iterations:
https://www.youtube.com/watch?v=o0uvMSGZskA&feature=youtu.be
dkurt commentedon May 20, 2019
@tompollok, If you want to help us solve it faster please do not make us to reproduce the video - add a fully working example with all the images.
tompollok commentedon May 20, 2019
The code i use is as mentioned in https://github.com/opencv/opencv/blob/48dad1b02ea8f743e6d165e94a5a4842d96c7a7e/samples/dnn/mask_rcnn.cpp
The only thing that is missing is that the example does not habe a loop to always use the same two images.
Image A must have a different resolution than B and should contain RCNN model supported objects. In my case persons.
Forward image A (gives results)
Forward image B (gives results)
Forward image A (gives different results than in A1)
Forward image B (gives different results than in B1)
Forward image A (gives no results anymore)
Forward image B (gives no results anymore)
dkurt commentedon May 21, 2019
What is image A and image B? Attach them please (in
.pngformat). Or we can use any kind on images to reproduce it?tompollok commentedon May 22, 2019
I should be reproducible for any images as long as the resolution is not equal.
dkurt commentedon May 22, 2019
Can confirm the bug:


tompollok commentedon May 23, 2019
Same issue with inference engine backend.
tompollok commentedon Jun 6, 2019
Any ideas how to fix this?
dkurt commentedon Jun 6, 2019
@tompollok, For now you can forward fixed inputs. Do you really need to vary their sizes?
tompollok commentedon Jun 6, 2019
I can reinitialize each time the resolution changes. I use it to create binary masks for imageregions where humans are visible to improve Structure from Motion pipeline by avoiding matching dynamic scene parts.
Im not in a hurry for a fix.
dkurt commentedon Jun 6, 2019
@tompollok, But why not to resize each human ROI to specific size, predict on it and then remap to origin size? Anyway if you run network of different sizes it requires reallocation of memory if input size changed.
tompollok commentedon Jun 6, 2019
That i could do, too, but then the inference time scales linear with the number of people. I just reinitialize for now on resolution change. The inference time on CPU is quite slow anyways.
The reason why i reported this bug is because i thought that this bug might be an issue in general, not only for mask_rcnn.
dkurt commentedon Jun 6, 2019
@tompollok, It's not clear for me. How you select image regions and why not to run all the model on entire frame? Why not to resize each image region to specific size?
Resolve opencv#14566
dkurt commentedon Feb 13, 2020
Sorry for too late fix but here it is: #16580. Thanks for nice catch!
tompollok commentedon Feb 14, 2020
You dont have to say sorry. Im very thankful for you investigating it, so thank you for the patch! Its really awesome to see how fast the DNN backends have evolved, especcially in the last 12 months!
Resolve opencv#14566
bug fix to Inconsistent comment for EXIF issue id opencv#15706 strea…
Resolve opencv#14566