// Load the library
System.loadLibrary("opencv_java249");
// Consider the image for processing
Mat image1 = Highgui.imread("C:/Users/omega/workspace/Plankton/src/com/plankton/0.jpg", Imgproc.COLOR_BGR2GRAY);
Mat imageHSV = new Mat(image1.size(), Core.DEPTH_MASK_8U);
Mat imageBlurr = new Mat(image1.size(), Core.DEPTH_MASK_8U);
Mat imageA = new Mat(image1.size(), Core.DEPTH_MASK_ALL);
Imgproc.cvtColor(image1, imageHSV, Imgproc.COLOR_BGR2GRAY);
Imgproc.GaussianBlur(imageHSV, imageBlurr, new Size(5,5), 0);
Imgproc.adaptiveThreshold(imageBlurr, imageA, 255,Imgproc.ADAPTIVE_THRESH_MEAN_C, Imgproc.THRESH_BINARY,7, 5);
// Highgui.imwrite("C:/Users/omega/workspace/KaggleExtraction/src/com/hello/0.jpg",imageBlurr);
ArrayList contours = new ArrayList();
Imgproc.findContours(imageA, (List) contours, new Mat(), Imgproc.RETR_LIST,Imgproc.CHAIN_APPROX_SIMPLE);
//Imgproc.drawContours(imageBlurr, contours, 1, new Scalar(0,0,255));
System.out.println("" + contours.size());
for(int i=0; i
↧