@@ -0,0 +1,2780 @@
+package com.qualcomm.ftcrobotcontroller.opmodes;%0A%0Aimport android.graphics.Bitmap;%0A%0A/**%0A * TeleOp Mode%0A * %3Cp/%3E%0A * Enables control of the robot via the gamepad%0A */%0Apublic class DetectColor extends OpModeCamera %7B%0A%0A    int ds2 = 2;  // additional downsampling of the image%0A    private int looped = 0;%0A    private long lastLoopTime = 0;%0A    // set to 1 to disable further downsampling%0A%0A    /*%0A     * Code to run when the op mode is first enabled goes here%0A     * @see com.qualcomm.robotcore.eventloop.opmode.OpMode#start()%0A     */%0A    @Override%0A    public void init() %7B%0A        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        super.init(); // inits camera functions, starts preview callback%0A    %7D%0A%0A    /*%0A     * This method will be called repeatedly in a loop%0A     * @see com.qualcomm.robotcore.eventloop.opmode.OpMode#loop()%0A     */%0A%0A    @Override%0A    public void loop() %7B%0A        long startTime = System.currentTimeMillis();%0A%0A        if (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 = convertYuvImageToRgb(yuvImage, width, height, ds2);%0A            for (int x = 0; x %3C width / ds2; x++) %7B%0A                for (int y = 0; y %3C height / ds2; y++) %7B%0A                    int pixel = rgbImage.getPixel(x, y);%0A                    redValue += red(pixel);%0A                    blueValue += blue(pixel);%0A                    greenValue += green(pixel);%0A                %7D%0A            %7D%0A            int color = highestColor(redValue, greenValue, blueValue);%0A            String colorString = %22%22;%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            telemetry.addData(%22Color:%22, %22Color detected is: %22 + colorString);%0A%0A        %7D%0A        long endTime = System.currentTimeMillis();%0A        telemetry.addData(%22Dims%22, Integer.toString(width / ds2) + %22 x %22 + Integer.toString(height / ds2));%0A        telemetry.addData(%22Loop Time%22, Long.toString(endTime - startTime));%0A        telemetry.addData(%22Loop to Loop Time%22, Long.toString(endTime - lastLoopTime));%0A%0A        lastLoopTime = endTime;%0A    %7D%0A%0A    @Override%0A    public void stop() %7B%0A        super.stop(); // stops camera functions%0A    %7D%0A%7D%0A

Create DetectColor.java