Initialize mask using rectangular. */
| 343 | Initialize mask using rectangular. |
| 344 | */ |
| 345 | static void initMaskWithRect( Mat& mask, Size imgSize, Rect rect ) |
| 346 | { |
| 347 | mask.create( imgSize, CV_8UC1 ); |
| 348 | mask.setTo( GC_BGD ); |
| 349 | |
| 350 | rect.x = max(0, rect.x); |
| 351 | rect.y = max(0, rect.y); |
| 352 | rect.width = min(rect.width, imgSize.width-rect.x); |
| 353 | rect.height = min(rect.height, imgSize.height-rect.y); |
| 354 | |
| 355 | (mask(rect)).setTo( Scalar(GC_PR_FGD) ); |
| 356 | } |
| 357 | |
| 358 | /* |
| 359 | Initialize GMM background and foreground models using kmeans algorithm. |