I am new to both OpenCv and Java, I have been doing a bit of reading and research on how I can perform a background subtraction and thanks to sturkmen
I have a piece of code that actually works, except it is in C== and my enviroment is Java, I could have converted the code but there is a few challenging thing, Like in Java Canny only has 4
parameters so its a bit of a challenge for me, here is the code:
Mat src= imread( argv[1] );
Mat original = src.clone();
Mat gray,mask;
cvtColor( src, gray, COLOR_BGR2GRAY );
blur( gray, gray, Size(3,3) );
Canny( gray, mask, 100, 300, 3 );
vector<Point> contours;
vector<Point> convexHull_pts;
findNonZero( mask, contours );
convexHull( contours, convexHull_pts);
fillConvexPoly( mask, convexHull_pts, Scalar(255) );
I tried Converting it based on my knowledge and here is what I got:
Mat src= new Mat();
Utils.bitmapToMat(bitmap, src);
Mat original = src.clone();
Mat gray = new Mat();
Mat mask = new Mat();
Imgproc.cvtColor(src, gray, Imgproc.COLOR_BGR2GRAY);
Imgproc.blur(gray, gray, new Size(3, 3));
//Canny giving a warning only 4 parameters
//are needed
Imgproc.Canny(gray, mask, 100, 300, 3);
//I do not know how to deal with this
vector<Point> contours;
vector<Point> convexHull_pts;
Core.findNonZero(mask, contours);
Imgproc.convexHull(contours, convexHull_pts);
Imgproc.fillConvexPoly(mask, convexHull_pts, Scalar(255));
vector<Point> contours;
vector<Point> convexHull_pts;
findNonZero( mask, contours );
convexHull( contours, convexHull_pts);
fillConvexPoly( mask, convexHull_pts, Scalar(255) );