Thursday, July 13, 2017

absdiff is not subtracting background image

Leave a Comment

Im trying to subtract background using absdiff.

private Mat applyMatWithAbs(Mat mRgba) {     Mat diffMat = new Mat();     Imgproc.cvtColor(mRgba, mRgba, Imgproc.COLOR_RGBA2GRAY);     Core.absdiff(mFGMask,mRgba,diffMat);     Imgproc.threshold(diffMat,diffMat,80,255,Imgproc.THRESH_BINARY);     Imgproc.GaussianBlur(diffMat, diffMat, new Size(5, 5) ,1 ,1);      Imgproc.cvtColor(diffMat, mRgba, Imgproc.COLOR_GRAY2BGRA, 4);     double otsu_thresh_val = Imgproc.threshold(diffMat, diffMat, 0, 255, Imgproc.THRESH_OTSU);     Imgproc.Canny(diffMat, diffMat, otsu_thresh_val * 0.5, otsu_thresh_val);     return diffMat; } 

mRgba is the grayscale image from camera. mFGMask is the grayscale image from static background image that I have already.

But still the background image is not being subtracted even after absdiff. How do I subtract it exactly? should I use cpp with jni for accuracy?

0 Answers

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment