getBackgroundImage not in Java version? [closed]

asked 2013-11-28 18:34:02 -0500

Will Stewart gravatar image

updated 2013-11-28 18:34:46 -0500

I may be asking the obvious, but imgproc in C has getBackgroundImage in BackgroundSubtractorMOG, though I can't seem to find it in the Java version;

I'm still relatively new and feeling my way around in OpenCV, so please excuse the novice level question.

edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by sturkmen
close date 2020-10-07 06:08:19.976452



ouch! - it's fixed in master, but not in 2.4 (missing CV_WRAP tag)

if you built from src, you could just add the CV_WRAP, rerun cmake, recompile

berak gravatar imageberak ( 2013-11-29 04:07:13 -0500 )edit

Pardon my novice level, but is there a procedure that details all the required steps to do that?

And is the BackgroundSubtractorMOG2 in the same situation?


Will Stewart gravatar imageWill Stewart ( 2013-11-29 18:29:42 -0500 )edit
  • "Pardon my novice level" - no problem, that 's what this site is for, no ?
  • "is the BackgroundSubtractorMOG2 in the same situation?" - they all inherit from BackgroundSubtractor, so, if it's fixed there, all 3 can use getBackgroundImage
  • "required steps to do that?" - yes, you could fix it, but you'll have to rebuild opencv from src.

change Line 69 to:

 CV_WRAP virtual void getBackgroundImage(OutputArray backgroundImage) const;

and rebuild it as described here.

berak gravatar imageberak ( 2013-11-30 03:31:04 -0500 )edit

but honestly, i'm not certain, if it's worth the trouble. what do you need the bg-image for ? it's just a (very expensive, btw) visualization of the model, not needed for the actual processing.

berak gravatar imageberak ( 2013-11-30 03:33:48 -0500 )edit

@berak - is this present now in the 3.0 version?i am using 2.4.9 but getBackgroundimage is still not there. and i cant build using ndk on my system. please help

Dhara Shah gravatar imageDhara Shah ( 2014-09-03 01:56:09 -0500 )edit

well, it is present in 3.0, unfortunately i can't recommend using alpha/3.0 atm, specially for java, too many things are broken. (java for the ml module, and anything in opencv_contrib is disabled/non-functional) .

and again, i doubt, that you need the Backgroundimage at all. (as a delveloper, sure you want to take a look at it, but it has no practical value for the bg-seperation, and is a very,very expensive operation)

berak gravatar imageberak ( 2014-09-03 02:09:01 -0500 )edit

i was thinking of using the backgroundimage method in order to remove the background from the captured frame(just one frame), so that i could detect objects, i saw the alpha version in the list but then theres no sdk for android

Dhara Shah gravatar imageDhara Shah ( 2014-09-03 02:46:56 -0500 )edit

@Dhara Shah, in that case, you misunderstood the algorithm.

you are supposed to use the foreground-mask to mask out the background in your original image.

also, you need a continuous stream of images for this, it builds a background model over time.

if you only have 1 frame, you can't use it at all, better look at grabcut or similar then

berak gravatar imageberak ( 2014-09-03 02:52:33 -0500 )edit

@berak thank u for the suggestion, i will have a look at grabcut, and get back

Dhara Shah gravatar imageDhara Shah ( 2014-09-03 23:38:07 -0500 )edit