001// 002// This file is auto-generated. Please don't modify it! 003// 004package org.opencv.video; 005 006import org.opencv.core.Mat; 007import org.opencv.video.BackgroundSubtractor; 008 009// C++: class BackgroundSubtractorMOG2 010/** 011 * Gaussian Mixture-based Background/Foreground Segmentation Algorithm. 012 * 013 * The class implements the Gaussian mixture model background subtraction described in CITE: Zivkovic2004 014 * and CITE: Zivkovic2006 . 015 */ 016public class BackgroundSubtractorMOG2 extends BackgroundSubtractor { 017 018 protected BackgroundSubtractorMOG2(long addr) { super(addr); } 019 020 // internal usage only 021 public static BackgroundSubtractorMOG2 __fromPtr__(long addr) { return new BackgroundSubtractorMOG2(addr); } 022 023 // 024 // C++: int cv::BackgroundSubtractorMOG2::getHistory() 025 // 026 027 /** 028 * Returns the number of last frames that affect the background model 029 * @return automatically generated 030 */ 031 public int getHistory() { 032 return getHistory_0(nativeObj); 033 } 034 035 036 // 037 // C++: void cv::BackgroundSubtractorMOG2::setHistory(int history) 038 // 039 040 /** 041 * Sets the number of last frames that affect the background model 042 * @param history automatically generated 043 */ 044 public void setHistory(int history) { 045 setHistory_0(nativeObj, history); 046 } 047 048 049 // 050 // C++: int cv::BackgroundSubtractorMOG2::getNMixtures() 051 // 052 053 /** 054 * Returns the number of gaussian components in the background model 055 * @return automatically generated 056 */ 057 public int getNMixtures() { 058 return getNMixtures_0(nativeObj); 059 } 060 061 062 // 063 // C++: void cv::BackgroundSubtractorMOG2::setNMixtures(int nmixtures) 064 // 065 066 /** 067 * Sets the number of gaussian components in the background model. 068 * 069 * The model needs to be reinitalized to reserve memory. 070 * @param nmixtures automatically generated 071 */ 072 public void setNMixtures(int nmixtures) { 073 setNMixtures_0(nativeObj, nmixtures); 074 } 075 076 077 // 078 // C++: double cv::BackgroundSubtractorMOG2::getBackgroundRatio() 079 // 080 081 /** 082 * Returns the "background ratio" parameter of the algorithm 083 * 084 * If a foreground pixel keeps semi-constant value for about backgroundRatio\*history frames, it's 085 * considered background and added to the model as a center of a new component. It corresponds to TB 086 * parameter in the paper. 087 * @return automatically generated 088 */ 089 public double getBackgroundRatio() { 090 return getBackgroundRatio_0(nativeObj); 091 } 092 093 094 // 095 // C++: void cv::BackgroundSubtractorMOG2::setBackgroundRatio(double ratio) 096 // 097 098 /** 099 * Sets the "background ratio" parameter of the algorithm 100 * @param ratio automatically generated 101 */ 102 public void setBackgroundRatio(double ratio) { 103 setBackgroundRatio_0(nativeObj, ratio); 104 } 105 106 107 // 108 // C++: double cv::BackgroundSubtractorMOG2::getVarThreshold() 109 // 110 111 /** 112 * Returns the variance threshold for the pixel-model match 113 * 114 * The main threshold on the squared Mahalanobis distance to decide if the sample is well described by 115 * the background model or not. Related to Cthr from the paper. 116 * @return automatically generated 117 */ 118 public double getVarThreshold() { 119 return getVarThreshold_0(nativeObj); 120 } 121 122 123 // 124 // C++: void cv::BackgroundSubtractorMOG2::setVarThreshold(double varThreshold) 125 // 126 127 /** 128 * Sets the variance threshold for the pixel-model match 129 * @param varThreshold automatically generated 130 */ 131 public void setVarThreshold(double varThreshold) { 132 setVarThreshold_0(nativeObj, varThreshold); 133 } 134 135 136 // 137 // C++: double cv::BackgroundSubtractorMOG2::getVarThresholdGen() 138 // 139 140 /** 141 * Returns the variance threshold for the pixel-model match used for new mixture component generation 142 * 143 * Threshold for the squared Mahalanobis distance that helps decide when a sample is close to the 144 * existing components (corresponds to Tg in the paper). If a pixel is not close to any component, it 145 * is considered foreground or added as a new component. 3 sigma => Tg=3\*3=9 is default. A smaller Tg 146 * value generates more components. A higher Tg value may result in a small number of components but 147 * they can grow too large. 148 * @return automatically generated 149 */ 150 public double getVarThresholdGen() { 151 return getVarThresholdGen_0(nativeObj); 152 } 153 154 155 // 156 // C++: void cv::BackgroundSubtractorMOG2::setVarThresholdGen(double varThresholdGen) 157 // 158 159 /** 160 * Sets the variance threshold for the pixel-model match used for new mixture component generation 161 * @param varThresholdGen automatically generated 162 */ 163 public void setVarThresholdGen(double varThresholdGen) { 164 setVarThresholdGen_0(nativeObj, varThresholdGen); 165 } 166 167 168 // 169 // C++: double cv::BackgroundSubtractorMOG2::getVarInit() 170 // 171 172 /** 173 * Returns the initial variance of each gaussian component 174 * @return automatically generated 175 */ 176 public double getVarInit() { 177 return getVarInit_0(nativeObj); 178 } 179 180 181 // 182 // C++: void cv::BackgroundSubtractorMOG2::setVarInit(double varInit) 183 // 184 185 /** 186 * Sets the initial variance of each gaussian component 187 * @param varInit automatically generated 188 */ 189 public void setVarInit(double varInit) { 190 setVarInit_0(nativeObj, varInit); 191 } 192 193 194 // 195 // C++: double cv::BackgroundSubtractorMOG2::getVarMin() 196 // 197 198 public double getVarMin() { 199 return getVarMin_0(nativeObj); 200 } 201 202 203 // 204 // C++: void cv::BackgroundSubtractorMOG2::setVarMin(double varMin) 205 // 206 207 public void setVarMin(double varMin) { 208 setVarMin_0(nativeObj, varMin); 209 } 210 211 212 // 213 // C++: double cv::BackgroundSubtractorMOG2::getVarMax() 214 // 215 216 public double getVarMax() { 217 return getVarMax_0(nativeObj); 218 } 219 220 221 // 222 // C++: void cv::BackgroundSubtractorMOG2::setVarMax(double varMax) 223 // 224 225 public void setVarMax(double varMax) { 226 setVarMax_0(nativeObj, varMax); 227 } 228 229 230 // 231 // C++: double cv::BackgroundSubtractorMOG2::getComplexityReductionThreshold() 232 // 233 234 /** 235 * Returns the complexity reduction threshold 236 * 237 * This parameter defines the number of samples needed to accept to prove the component exists. CT=0.05 238 * is a default value for all the samples. By setting CT=0 you get an algorithm very similar to the 239 * standard Stauffer&Grimson algorithm. 240 * @return automatically generated 241 */ 242 public double getComplexityReductionThreshold() { 243 return getComplexityReductionThreshold_0(nativeObj); 244 } 245 246 247 // 248 // C++: void cv::BackgroundSubtractorMOG2::setComplexityReductionThreshold(double ct) 249 // 250 251 /** 252 * Sets the complexity reduction threshold 253 * @param ct automatically generated 254 */ 255 public void setComplexityReductionThreshold(double ct) { 256 setComplexityReductionThreshold_0(nativeObj, ct); 257 } 258 259 260 // 261 // C++: bool cv::BackgroundSubtractorMOG2::getDetectShadows() 262 // 263 264 /** 265 * Returns the shadow detection flag 266 * 267 * If true, the algorithm detects shadows and marks them. See createBackgroundSubtractorMOG2 for 268 * details. 269 * @return automatically generated 270 */ 271 public boolean getDetectShadows() { 272 return getDetectShadows_0(nativeObj); 273 } 274 275 276 // 277 // C++: void cv::BackgroundSubtractorMOG2::setDetectShadows(bool detectShadows) 278 // 279 280 /** 281 * Enables or disables shadow detection 282 * @param detectShadows automatically generated 283 */ 284 public void setDetectShadows(boolean detectShadows) { 285 setDetectShadows_0(nativeObj, detectShadows); 286 } 287 288 289 // 290 // C++: int cv::BackgroundSubtractorMOG2::getShadowValue() 291 // 292 293 /** 294 * Returns the shadow value 295 * 296 * Shadow value is the value used to mark shadows in the foreground mask. Default value is 127. Value 0 297 * in the mask always means background, 255 means foreground. 298 * @return automatically generated 299 */ 300 public int getShadowValue() { 301 return getShadowValue_0(nativeObj); 302 } 303 304 305 // 306 // C++: void cv::BackgroundSubtractorMOG2::setShadowValue(int value) 307 // 308 309 /** 310 * Sets the shadow value 311 * @param value automatically generated 312 */ 313 public void setShadowValue(int value) { 314 setShadowValue_0(nativeObj, value); 315 } 316 317 318 // 319 // C++: double cv::BackgroundSubtractorMOG2::getShadowThreshold() 320 // 321 322 /** 323 * Returns the shadow threshold 324 * 325 * A shadow is detected if pixel is a darker version of the background. The shadow threshold (Tau in 326 * the paper) is a threshold defining how much darker the shadow can be. Tau= 0.5 means that if a pixel 327 * is more than twice darker then it is not shadow. See Prati, Mikic, Trivedi and Cucchiara, 328 * Detecting Moving Shadows...*, IEEE PAMI,2003. 329 * @return automatically generated 330 */ 331 public double getShadowThreshold() { 332 return getShadowThreshold_0(nativeObj); 333 } 334 335 336 // 337 // C++: void cv::BackgroundSubtractorMOG2::setShadowThreshold(double threshold) 338 // 339 340 /** 341 * Sets the shadow threshold 342 * @param threshold automatically generated 343 */ 344 public void setShadowThreshold(double threshold) { 345 setShadowThreshold_0(nativeObj, threshold); 346 } 347 348 349 // 350 // C++: void cv::BackgroundSubtractorMOG2::apply(Mat image, Mat& fgmask, double learningRate = -1) 351 // 352 353 /** 354 * Computes a foreground mask. 355 * 356 * @param image Next video frame. Floating point frame will be used without scaling and should be in range \([0,255]\). 357 * @param fgmask The output foreground mask as an 8-bit binary image. 358 * @param learningRate The value between 0 and 1 that indicates how fast the background model is 359 * learnt. Negative parameter value makes the algorithm to use some automatically chosen learning 360 * rate. 0 means that the background model is not updated at all, 1 means that the background model 361 * is completely reinitialized from the last frame. 362 */ 363 public void apply(Mat image, Mat fgmask, double learningRate) { 364 apply_0(nativeObj, image.nativeObj, fgmask.nativeObj, learningRate); 365 } 366 367 /** 368 * Computes a foreground mask. 369 * 370 * @param image Next video frame. Floating point frame will be used without scaling and should be in range \([0,255]\). 371 * @param fgmask The output foreground mask as an 8-bit binary image. 372 * learnt. Negative parameter value makes the algorithm to use some automatically chosen learning 373 * rate. 0 means that the background model is not updated at all, 1 means that the background model 374 * is completely reinitialized from the last frame. 375 */ 376 public void apply(Mat image, Mat fgmask) { 377 apply_1(nativeObj, image.nativeObj, fgmask.nativeObj); 378 } 379 380 381 @Override 382 protected void finalize() throws Throwable { 383 delete(nativeObj); 384 } 385 386 387 388 // C++: int cv::BackgroundSubtractorMOG2::getHistory() 389 private static native int getHistory_0(long nativeObj); 390 391 // C++: void cv::BackgroundSubtractorMOG2::setHistory(int history) 392 private static native void setHistory_0(long nativeObj, int history); 393 394 // C++: int cv::BackgroundSubtractorMOG2::getNMixtures() 395 private static native int getNMixtures_0(long nativeObj); 396 397 // C++: void cv::BackgroundSubtractorMOG2::setNMixtures(int nmixtures) 398 private static native void setNMixtures_0(long nativeObj, int nmixtures); 399 400 // C++: double cv::BackgroundSubtractorMOG2::getBackgroundRatio() 401 private static native double getBackgroundRatio_0(long nativeObj); 402 403 // C++: void cv::BackgroundSubtractorMOG2::setBackgroundRatio(double ratio) 404 private static native void setBackgroundRatio_0(long nativeObj, double ratio); 405 406 // C++: double cv::BackgroundSubtractorMOG2::getVarThreshold() 407 private static native double getVarThreshold_0(long nativeObj); 408 409 // C++: void cv::BackgroundSubtractorMOG2::setVarThreshold(double varThreshold) 410 private static native void setVarThreshold_0(long nativeObj, double varThreshold); 411 412 // C++: double cv::BackgroundSubtractorMOG2::getVarThresholdGen() 413 private static native double getVarThresholdGen_0(long nativeObj); 414 415 // C++: void cv::BackgroundSubtractorMOG2::setVarThresholdGen(double varThresholdGen) 416 private static native void setVarThresholdGen_0(long nativeObj, double varThresholdGen); 417 418 // C++: double cv::BackgroundSubtractorMOG2::getVarInit() 419 private static native double getVarInit_0(long nativeObj); 420 421 // C++: void cv::BackgroundSubtractorMOG2::setVarInit(double varInit) 422 private static native void setVarInit_0(long nativeObj, double varInit); 423 424 // C++: double cv::BackgroundSubtractorMOG2::getVarMin() 425 private static native double getVarMin_0(long nativeObj); 426 427 // C++: void cv::BackgroundSubtractorMOG2::setVarMin(double varMin) 428 private static native void setVarMin_0(long nativeObj, double varMin); 429 430 // C++: double cv::BackgroundSubtractorMOG2::getVarMax() 431 private static native double getVarMax_0(long nativeObj); 432 433 // C++: void cv::BackgroundSubtractorMOG2::setVarMax(double varMax) 434 private static native void setVarMax_0(long nativeObj, double varMax); 435 436 // C++: double cv::BackgroundSubtractorMOG2::getComplexityReductionThreshold() 437 private static native double getComplexityReductionThreshold_0(long nativeObj); 438 439 // C++: void cv::BackgroundSubtractorMOG2::setComplexityReductionThreshold(double ct) 440 private static native void setComplexityReductionThreshold_0(long nativeObj, double ct); 441 442 // C++: bool cv::BackgroundSubtractorMOG2::getDetectShadows() 443 private static native boolean getDetectShadows_0(long nativeObj); 444 445 // C++: void cv::BackgroundSubtractorMOG2::setDetectShadows(bool detectShadows) 446 private static native void setDetectShadows_0(long nativeObj, boolean detectShadows); 447 448 // C++: int cv::BackgroundSubtractorMOG2::getShadowValue() 449 private static native int getShadowValue_0(long nativeObj); 450 451 // C++: void cv::BackgroundSubtractorMOG2::setShadowValue(int value) 452 private static native void setShadowValue_0(long nativeObj, int value); 453 454 // C++: double cv::BackgroundSubtractorMOG2::getShadowThreshold() 455 private static native double getShadowThreshold_0(long nativeObj); 456 457 // C++: void cv::BackgroundSubtractorMOG2::setShadowThreshold(double threshold) 458 private static native void setShadowThreshold_0(long nativeObj, double threshold); 459 460 // C++: void cv::BackgroundSubtractorMOG2::apply(Mat image, Mat& fgmask, double learningRate = -1) 461 private static native void apply_0(long nativeObj, long image_nativeObj, long fgmask_nativeObj, double learningRate); 462 private static native void apply_1(long nativeObj, long image_nativeObj, long fgmask_nativeObj); 463 464 // native support for java finalize() 465 private static native void delete(long nativeObj); 466 467}