GrabCut Implementation in JAVA
Hi everyone, Im new using OPENCV, also Do you know how to apply the grabcut but instead using INIT_WITH_RECT, use INTI_WITH_MASK? so far what I got is this, probably with Images you can see my real problem:
First you can select the part you want as your ROI in this case the part selected is mark with a gray rectangle :
Applying grabcut with INIT_WITH_RECT the algorithm show this:
As you can see the grabcut select a part that is not wanted so Im trying to enhance the selection with doing some touchups in the parts you want as foreground and as a background, in this example foreground is mark with blue and background with red as below:
Here comes the problem, how to apply again the grabcut algorithm but now indicating that the blue lines are foreground and the red lines are background? I have read about it and saw the python examples but in python the use of arrays is far different from java. What I know and correct me if I'm wrong, i have to modify the mask and reapply the grabcut algorithm, but when I try this I found this error:
Error:
OpenCV Error: Assertion failed (!bgdSamples.empty() && !fgdSamples.empty()) in initGMMs, file C:\builds\master_PackSlaveAddon-win64-vc12-static\opencv\modules\imgproc\src\grabcut.cpp, line 379 Exception in thread "AWT-EventQueue-0" CvException [org.opencv.core.CvException: cv::Exception: C:\builds\master_PackSlaveAddon-win64-vc12-static\opencv\modules\imgproc\src\grabcut.cpp:379: error: (-215) !bgdSamples.empty() && !fgdSamples.empty() in function initGMMs ]
Could you give me a hand with this?
Thanks in advance