Open blue-hope opened 2 years ago
// TODO : Image preprocessing - Find Contour fun findContours(outmat: Mat): ArrayList<MatOfPoint?>? { val hierarchy = Mat() val contours: List<MatOfPoint> = ArrayList<MatOfPoint>() Imgproc.findContours(outmat, contours, hierarchy, Imgproc.RETR_LIST, Imgproc.CHAIN_APPROX_SIMPLE) val maxArea = 100.0 var maxAreaIdx = -1 val contourArray: ArrayList<MatOfPoint?> = ArrayList<MatOfPoint?>() for (idx in contours.indices) { val contour: MatOfPoint = contours[idx] val contourArea = Imgproc.contourArea(contour) if (contourArea > maxArea) { // maxArea = contourArea; maxAreaIdx = idx contourArray.add(contour) // Imgproc.drawContours(image, contours, maxAreaIdx, new Scalar(0,0, 255)); } } return contourArray }
되긴하지만 성능 개선 필요