1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-29 15:23:05 +04:00

Grabcut with frozen models (#11339)

* model is not learned when grabcut is called with GC_EVAL

* fixed test, was writing to wrong file.

* modified patch by Iwan Paolucci; added GC_EVAL_FREEZE_MODEL in addition to GC_EVAL (which semantics is retained)
This commit is contained in:
Vadim Pisarevsky
2018-04-19 15:23:50 +03:00
committed by GitHub
parent 64a6b12114
commit 7ea5029ae5
3 changed files with 21 additions and 6 deletions
+6 -2
View File
@@ -557,7 +557,10 @@ void cv::grabCut( InputArray _img, InputOutputArray _mask, Rect rect,
if( iterCount <= 0)
return;
if( mode == GC_EVAL )
if( mode == GC_EVAL_FREEZE_MODEL )
iterCount = 1;
if( mode == GC_EVAL || mode == GC_EVAL_FREEZE_MODEL )
checkMask( img, mask );
const double gamma = 50;
@@ -571,7 +574,8 @@ void cv::grabCut( InputArray _img, InputOutputArray _mask, Rect rect,
{
GCGraph<double> graph;
assignGMMsComponents( img, mask, bgdGMM, fgdGMM, compIdxs );
learnGMMs( img, mask, compIdxs, bgdGMM, fgdGMM );
if( mode != GC_EVAL_FREEZE_MODEL )
learnGMMs( img, mask, compIdxs, bgdGMM, fgdGMM );
constructGCGraph(img, mask, bgdGMM, fgdGMM, lambda, leftW, upleftW, upW, uprightW, graph );
estimateSegmentation( graph, mask );
}