plstcharles / litiv

C++ implementation pool for computer vision R&D projects.
http://www.polymtl.ca/litiv/en/
Other
101 stars 30 forks source link

How to set the learningRateOverride? #17

Closed Adwardyang closed 5 years ago

Adwardyang commented 5 years ago

Hello~ I want to use your algorithm to detect stationary obj(like the cargo that fell from truck to the ground ),so I make the learningRateOverride=0(not update the bg model at all) to detect the stationary foreground.But the staionary foreground still get into the bg model which lead the stationary foreground can't be detect.So sincerely hope you to help me,can you give me some advice about stationary objection?

                                                                                                                Thanks!
                                                                                                                Kind regard.
plstcharles commented 5 years ago

Hello!

I'll have to go back in the code and dig a bit, but depending on the method, setting the rate to zero might mean it is automatically adjusted via feedback loops. It's not super intuitive, but that's how it was initially implemented...

Let me know which method you're looking at, and I'll look into the easiest way to freeze model adaptation internally.

Adwardyang commented 5 years ago

Thanks!I appreciate you answering my question again! I‘m looking at PAWCS. Now the problem is the object that from motion to stillness(like the cargo fell from truck to the ground ) will get into the background model quickly, so I can't detect them. My idea is to make the learning rate be a small one, which can let the object exist for while. Maybe it is not the best way for this need, but it is my Intuitive thinking. So look forward your reply!

plstcharles commented 5 years ago

Alright: for PAWCS, if you want to slow down model adaptation, you actually have to increase the "learning rate override" value (yeah that's pretty counter-intuitive, I admit). The line that converts the learning rate to a sampling rate is here:

https://github.com/plstcharles/litiv/blob/master/modules/video/src/BackgroundSubtractorPAWCS.cpp#L659

Using an 'infinite' value as input will pretty much freeze the model in time. Any other (non-zero) value is interpreted as a 1/T chance of updating.

I hope this helps!

Adwardyang commented 5 years ago

Thanks for your answer! I follow your advice to give the learningrate override in "BackgroundSubtractorPAWCS.h" like this:

1 and the foreground just exist for a while(about 3000 frames),the results of different stage are as follows: 2 at begin 3 after 3000 frames

my method doesn't seem to work, can you teach how to make the model in time?

plstcharles commented 5 years ago

PAWCS is designed so that background elements that are observed constantly over a long period will be very "persistent" inside the model, no matter how often the model is actually updated. This means that the learning rate has a smaller role to play in the maintenance of the model than in other background subtraction methods.

I see two possible solutions to keep detecting the foreground for a longer duration at this point: first, you could try running PAWCS over even more images without the foreground present to build a more "persistent" background. Then, after switching the learning rate to the higher value, new foreground objects should be detected for much longer. The second solution is to switch to a more straightforward modelling solution (like SuBSENSE) where the background model updates are truly only controlled by the update rate.

I hope this helps!

PS: I see you used "DBL_MAX" for the learning rate override value --- I have not tested that value myself in the past, and I think it might overflow or cause other issues when it is converted to an integer (size_t). Try to use something like 10e6 (it should be plenty!), and let me know if you see any changes!

Adwardyang commented 5 years ago

Thanks for your patient answer! I make simple statistic by using different learning rate override as follow:

learning rate override = 10e6 , the rectangle existing about 700 frames; learning rate override = 0 , the rectangle existing about 700 frames; learning rate override = -1 , the rectangle existing about 1200 frames;

My project aim to detect the abandoned object on the highway based on roadside camera . So far I haven't found a way to make the bg model stop update..... I also try the SuBSENSE , but it not performed very well on my project(because the foreground object to split) .

plstcharles commented 5 years ago

Oh wow, nice tests! The behavior for "-1" surprised me, but I guess it makes sense since the value is converted to an integer and it overflows to SIZE_MAX when converted to size_t (which is the value we wanted).

I'm afraid I do not have any more tips for you at this point --- there are many code paths that might lead to model updates, and the methods were not really designed to freeze the update process completely. Reimplementing the method with a global flag that must be checked on sample assignment might do the trick, but it might be a bit of extra work...

Good luck with your project!

Adwardyang commented 5 years ago

Thanks!It's benefited for me to communicate with you , I will on the way.