I am working with OpenCV4Android version 3.0.0 and I am trying to remove background from video stream "non-static background". i want to do so because i have a problem when i try to detect the edges of a "card", the problem of detecting the edges of a "card" is based on its color and the background color as explained in my question here.
after referring to some posts i wrote the below code, but at run time, when i display the "mask" image i get a completely grey image. and when i display the "output" image after applying the "mask" on it i get the same preview being displayed on the camera
is there any way to remove the non-static background from video stream?
code:
mask = new Mat();
BackgroundSubtractorMOG2 mog2 = Video.createBackgroundSubtractorMOG2();
mog2.apply(mInputFrame,mask,.000005);
output = new Mat();
mInputFrame.copyTo(output, mask);
final Bitmap bitmap = Bitmap.createBitmap(mInputFrame.cols(), mInputFrame.rows(), Bitmap.Config.ARGB_8888);
Utils.matToBitmap(output, bitmap);
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
mIVEdges.setImageBitmap(bitmap);
}
});