public static Mat findContours(Mat frame) {

        Mat contoursMat = preproc(frame);

        Mat result = new Mat(contoursMat.size(), CvType.CV_8U, new Scalar(255));
        List<MatOfPoint> contours = new ArrayList<>();
        List<MatOfPoint> contoursGeneral = new ArrayList<>();
        Imgproc.findContours(contoursMat, contours, new Mat(), Imgproc.RETR_LIST, Imgproc.CHAIN_APPROX_SIMPLE);
//        Imgproc.drawContours(result, contours, -1, new Scalar(0), 2);
        
        for(int i = 0; i < contours.size(); i++){
            double area = Imgproc.contourArea(contours.get(i));
            if(MyBooleans.flag){
                System.out.println(area);
            }
            if(area < MyIntegers.minContours || area > MyIntegers.maxContours){
                contours.remove(i);
            }else if(area > MyIntegers.mediumContours && area < MyIntegers.maxContours){
                contoursGeneral.add(contours.get(i));
            }
        }
        
        System.out.println("");
        
        Imgproc.drawContours(result, contours, -1, new Scalar(0), 2);
        
         MyBooleans.flag = false;
         
         //centros de masa
         for(int i = 0; i < contoursGeneral.size(); i++){
             Moments mom = Imgproc.moments(contoursGeneral.get(i));
             Core.circle(result, 
                     new Point(mom.get_m10()/mom.get_m00(), mom.get_m01()/mom.get_m00()), 
                     2, new Scalar(80),2);
         }

//        List<RotatedRect> minRects = new ArrayList<>();
//        for (int i = 0; i < contours.size(); i++) {
//            minRects.add(Imgproc.minAreaRect(new MatOfPoint2f(contours.get(i).toArray())));
//            Point rect_point[] = new Point[4];
//            minRects.get(i).points(rect_point);
//            for (int j = 0; j < 4; j++) {
//                Core.line(result, rect_point[j], rect_point[(j+1)%4], new Scalar(170),2);
//            }
//        }
        
//        Rect r0;
//        for (int i = 0; i < contours.size(); i++) {
//            r0 = Imgproc.boundingRect(contours.get(i));
//            Core.rectangle(result, r0.tl(), r0.br(), new Scalar(20, 250, 0), 2);
//        }
//        Rect r0 = Imgproc.boundingRect(contours.get(0));
//        Core.rectangle(result, r0.tl(), r0.br(), new Scalar(20), 2);

        return result;
    }