Masters/src/main/java/org/firstinspires/ftc/masters/MultipleCameraCV.java
@Override
        public Mat processFrame(Mat input) {
            inputToLAB(input);

//            Declare list of regions
            ArrayList<Mat> region = new ArrayList<Mat>();


//            Put the necessary data from the frame to each region
            for (int i = 0; i<33; i++) {
                region.add(B.submat(new Rect(topLeftPoints.get(i), bottomRightPoints.get(i))));
            }

            ArrayList<Integer> regionAvgs = new ArrayList<Integer>();

            for (int i = 0; i<33; i++) {
                regionAvgs.add((int) Core.mean(region.get(i)).val[0]);
            }

//              This is what displays the rectangles to the camera stream on the drive hub
            for (int i = 0; i<33; i++) {
                Imgproc.rectangle(
                        input, // Buffer to draw on
                        topLeftPoints.get(i), // First point which defines the rectangle
                        bottomRightPoints.get(i), // Second point which defines the rectangle
                        BLUE, // The color the rectangle is drawn in
                        2); // Thickness of the rectangle lines

            }

//            The next several lines determine which region has the highest B average.
            int indexOfMaximumBAvg = 0;

            for (int i = 0; i<33; i++) {
                if (regionAvgs.get(i) >= regionAvgs.get(indexOfMaximumBAvg)) {
                    indexOfMaximumBAvg = i;
                }
            }

//            Display telemetry
            telemetry.addData("B Averages", regionAvgs);
            telemetry.addData("Index of highest likelihood.", indexOfMaximumBAvg);

//            Fix indexes (Regions are stacked 11 to a row)
            if (regionAvgs.get(indexOfMaximumBAvg) >= DUCK_PRESENT_THRESHOLD) {
                if (indexOfMaximumBAvg > 21) {
                    indexOfMaximumBAvg -= 22;
                } else if (indexOfMaximumBAvg > 10) {
                    indexOfMaximumBAvg -= 11;
                }
                position = DuckPosition.values()[indexOfMaximumBAvg];
            } else {
                position = DuckPosition.SHRUG_NOISES; // Default enum result. Aptly named
            }


            telemetry.addData("Position", position);
            telemetry.update();


            return input;
        }
//        Process frame, takes a matrix input and processes it. I still have no idea WHERE this is called, but it is absolutly essential to CV functioning
Process frame, takes a matrix input and processes it. I still have no idea WHERE this is called, but it is absolutly essential to CV functioning
Process frame takes a matrix input and processes it . I still have no idea WHERE this is called but it is absolutly essential to CV functioning
@Override
        public Mat processFrame(Mat input) {
            inputToLAB(input);
            ArrayList<Mat> region = new ArrayList<Mat>();
            for (int i = 0; i<33; i++) {
                region.add(B.submat(new Rect(topLeftPoints.get(i), bottomRightPoints.get(i))));
            }
            ArrayList<Integer> regionAvgs = new ArrayList<Integer>();
            for (int i = 0; i<33; i++) {
                regionAvgs.add((int) Core.mean(region.get(i)).val[0]);
            }
            for (int i = 0; i<33; i++) {
                Imgproc.rectangle(
                        input, 
                        topLeftPoints.get(i), 
                        bottomRightPoints.get(i), 
                        BLUE, 
                        2); 
            }
            int indexOfMaximumBAvg = 0;
            for (int i = 0; i<33; i++) {
                if (regionAvgs.get(i) >= regionAvgs.get(indexOfMaximumBAvg)) {
                    indexOfMaximumBAvg = i;
                }
            }
            telemetry.addData("B Averages", regionAvgs);
            telemetry.addData("Index of highest likelihood.", indexOfMaximumBAvg);
            if (regionAvgs.get(indexOfMaximumBAvg) >= DUCK_PRESENT_THRESHOLD) {
                if (indexOfMaximumBAvg > 21) {
                    indexOfMaximumBAvg -= 22;
                } else if (indexOfMaximumBAvg > 10) {
                    indexOfMaximumBAvg -= 11;
                }
                position = DuckPosition.values()[indexOfMaximumBAvg];
            } else {
                position = DuckPosition.SHRUG_NOISES; 
            }
            telemetry.addData("Position", position);
            telemetry.update();
            return input;
        }
@ Override public Mat processFrame ( Mat input ) { inputToLAB ( input ) ; ArrayList < Mat > region = new ArrayList < Mat > ( ) ; for ( int i = 0 ; i < 33 ; i ++ ) { region . add ( B . submat ( new Rect ( topLeftPoints . get ( i ) , bottomRightPoints . get ( i ) ) ) ) ; } ArrayList < Integer > regionAvgs = new ArrayList < Integer > ( ) ; for ( int i = 0 ; i < 33 ; i ++ ) { regionAvgs . add ( ( int ) Core . mean ( region . get ( i ) ) . val [ 0 ] ) ; } for ( int i = 0 ; i < 33 ; i ++ ) { Imgproc . rectangle ( input , topLeftPoints . get ( i ) , bottomRightPoints . get ( i ) , BLUE , 2 ) ; } int indexOfMaximumBAvg = 0 ; for ( int i = 0 ; i < 33 ; i ++ ) { if ( regionAvgs . get ( i ) >= regionAvgs . get ( indexOfMaximumBAvg ) ) { indexOfMaximumBAvg = i ; } } telemetry . addData ( "B Averages" , regionAvgs ) ; telemetry . addData ( "Index of highest likelihood." , indexOfMaximumBAvg ) ; if ( regionAvgs . get ( indexOfMaximumBAvg ) >= DUCK_PRESENT_THRESHOLD ) { if ( indexOfMaximumBAvg > 21 ) { indexOfMaximumBAvg -= 22 ; } else if ( indexOfMaximumBAvg > 10 ) { indexOfMaximumBAvg -= 11 ; } position = DuckPosition . values ( ) [ indexOfMaximumBAvg ] ; } else { position = DuckPosition . SHRUG_NOISES ; } telemetry . addData ( "Position" , position ) ; telemetry . update ( ) ; return input ; }
Process frame, takes a matrix input and processes it.
Process frame takes a matrix input and processes it .
//            Declare list of regions //            Put the necessary data from the frame to each region //              This is what displays the rectangles to the camera stream on the drive hub // Buffer to draw on // First point which defines the rectangle // Second point which defines the rectangle // The color the rectangle is drawn in // Thickness of the rectangle lines //            The next several lines determine which region has the highest B average. //            Display telemetry //            Fix indexes (Regions are stacked 11 to a row) // Default enum result. Aptly named