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:
@@ -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 );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user