@@ -0,0 +1,3144 @@
+package com.qualcomm.ftcrobotcontroller.opmodes;%0A%0Aimport android.graphics.Bitmap;%0A%0Aimport com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;%0Aimport com.qualcomm.robotcore.hardware.DcMotor;%0A%0A/**%0A * TeleOp Mode%0A * %3Cp/%3E%0A * Enables control of the robot via the gamepad%0A */%0Apublic class LinearDetectColor extends LinearOpMode %7B%0A%0A    OpModeCamera cameraOps;%0A    DcMotor motorRight;%0A    DcMotor motorLeft;%0A%0A    int ds2 = 2;  // additional downsampling of the image%0A    // set to 1 to disable further downsampling%0A%0A    @Override%0A    public void runOpMode() throws InterruptedException %7B%0A        String colorString = %22NONE%22;%0A%0A        // linear OpMode, so could do stuff like this too.%0A        /*%0A        motorLeft = hardwareMap.dcMotor.get(%22motor_1%22);%0A        motorRight = hardwareMap.dcMotor.get(%22motor_2%22);%0A        motorLeft.setDirection(DcMotor.Direction.REVERSE);%0A        */%0A%0A        cameraOps.setCameraDownsampling(8);%0A        // parameter determines how downsampled you want your images%0A        // 8, 4, 2, or 1.%0A        // higher number is more downsampled, so less resolution but faster%0A        // 1 is original resolution, which is detailed but slow%0A        // must be called before super.init sets up the camera%0A%0A%0A        cameraOps.startCamera();// can take a while.%0A        // best started before waitForStart%0A        // or in a separate thread.%0A%0A        waitForStart();%0A%0A        // LinearOpMode, so could do stuff like this too.%0A        /*%0A        motorLeft.setPower(1);  // drive forward%0A        motorRight.setPower(1);%0A%0A        sleep(1000);            // for a second.%0A%0A        motorLeft.setPower(0);  // stop drive motors.%0A        motorRight.setPower(0);%0A%0A        sleep(1000);            // wait a second.%0A        */%0A%0A        while (opModeIsActive()) %7B%0A            if (cameraOps.imageReady()) %7B // only do this if an image has been returned from the camera%0A                int redValue = 0;%0A                int blueValue = 0;%0A                int greenValue = 0;%0A%0A                Bitmap rgbImage;%0A                rgbImage = cameraOps.convertYuvImageToRgb(cameraOps.yuvImage, cameraOps.width, cameraOps.height, ds2);%0A                for (int x = 0; x %3C cameraOps.width / ds2; x++) %7B%0A                    for (int y = 0; y %3C cameraOps.height / ds2; y++) %7B%0A                        int pixel = rgbImage.getPixel(x, y);%0A                        redValue += cameraOps.red(pixel);%0A                        blueValue += cameraOps.blue(pixel);%0A                        greenValue += cameraOps.green(pixel);%0A                    %7D%0A                %7D%0A                int color = cameraOps.highestColor(redValue, greenValue, blueValue);%0A%0A                switch (color) %7B%0A                    case 0:%0A                        colorString = %22RED%22;%0A                        break;%0A                    case 1:%0A                        colorString = %22GREEN%22;%0A                        break;%0A                    case 2:%0A                        colorString = %22BLUE%22;%0A                %7D%0A%0A            %7D%0A%0A            telemetry.addData(%22Color:%22, %22Color detected is: %22 + colorString);%0A            waitOneHardwareCycle();%0A        %7D%0A%0A        cameraOps.stopCamera();%0A    %7D%0A%7D%0A

Create LinearDetectColor.java