Java 类edu.wpi.first.wpilibj.camera.AxisCameraException 实例源码

项目:Robot-Code-2013    文件:CameraSubsystem.java   
protected double returnPIDInput() {
        if(numMisses < 6) {
            try{
                storeTop();
    //           startProcessing();
                System.out.println("Feeding in : "+top.center_mass_x);
                numMisses = 0;
                return top.center_mass_x;
            }
            catch(AxisCameraException e) {
                numMisses++;
                System.out.println("Error (165): "+e.getMessage());
                return 165;
            }
        }
        else {
            System.out.println("Could not process 6 times in a row. Exiting...");
            numMisses = 0;
//            this.disable();
            return 165;
        }
    }
项目:FRCTesting    文件:ImageUtils.java   
/** 
 * ColorImage- getImage/getTarget/refresh/update
 * should filter image and get details
 * http://www.spectrum3847.org/frc2012api/edu/wpi/first/wpilibj/image/ColorImage.html
 */
public ColorImage getImage() throws AxisCameraException, NIVisionException {
  ColorImage image=new HSLImage();
  if (true) {//getImageFn.call1(image.image) == 0) {
    image.free();
    throw new AxisCameraException("No image available");
  }
  return image;
}
项目:RobotCode2013    文件:Vision.java   
public VisionTarget [] processFrame() {
    if (enableVision) {
        lastFrame = System.currentTimeMillis();
        try {
            ColorImage image   = camera.getImage();
            BinaryImage bImage = image.thresholdRGB(
                    redLow, redHigh,
                    greenLow, greenHigh,
                    blueLow, blueHigh);
            BinaryImage fImage = bImage.particleFilter(cc);
            ParticleAnalysisReport [] report = fImage.getOrderedParticleAnalysisReports();
            VisionTarget [] targets = new VisionTarget[report.length];
            for (int i = 0; i < report.length; i++) {
                double centerX = report[i].center_mass_x;
                double centerY = report[i].center_mass_y;
                double width = report[i].boundingRectWidth;
                double height = report[i].boundingRectHeight;
                int area = (int)report[i].particleArea;
                targets[i] = new VisionTarget(centerX, centerY, width, height, area);
            }
            frameProcess = System.currentTimeMillis() - lastFrame;
            image.free();
            bImage.free();
            fImage.free();
            return targets;
        } catch (AxisCameraException e) {
            System.out.println("No Image From Camera: ");
            frameProcess = System.currentTimeMillis() - lastFrame;
            return new VisionTarget[0];
        } catch (Exception ex) {
            System.out.println("Camera Exception Thrown: " + ex.getMessage());
            frameProcess = System.currentTimeMillis() - lastFrame;
            return new VisionTarget[0];
        }
    } else { // Vision is not enabled
        return new VisionTarget[0];
    }
}
项目:Robot-Code-2013    文件:CameraSubsystem.java   
public int getHeightOfTarget() {
    try {
        storeTop();
    } catch (AxisCameraException ex) {
    }
    return top.boundingRectHeight;
}
项目:649code2014    文件:CameraSubsystem.java   
public ColorImage getImage() throws AxisCameraException, NIVisionException {
    return cam.getImage();
}
项目:Robot-Code-2013    文件:CameraSubsystem.java   
private void storeTop() throws AxisCameraException {
        top = null;
        ColorImage ci = getImage();
        ParticleAnalysisReport target = null;
        if(ci != null) {
            try{
                System.out.println("Storing top details...");
                bi = ci.thresholdRGB(RED_LOW, RED_HIGH, GREEN_LOW, GREEN_HIGH, BLUE_LOW, BLUE_HIGH);
//                ci.free();
//                ci.image.clear();
//                ci.image.free();
                bi = bi.convexHull(false);
                bi = bi.particleFilter(cc);
                bi = bi.removeSmallObjects(true, 2);
                System.out.println("Got here.");
                ParticleAnalysisReport[] reports = bi.getOrderedParticleAnalysisReports();
                ParticleAnalysisReport tmp;
                int lastHighest = 321;
                for(int i=0; i<reports.length; i++) {
                    tmp = reports[i];
                    if(tmp.center_mass_y < lastHighest) {
                        lastHighest = tmp.center_mass_y;
                        target = tmp;
                    }
                }
                }
            catch(Exception e) {
                isProcessing = false;
                System.out.println("Error in the processing.");
                throw new AxisCameraException("Error: "+e.getMessage());
            }
                if(target == null) {
                        isProcessing = false;
                        throw new AxisCameraException("No targets found that fit the specified criteria.");
                    }
                    else {
                        System.out.println(target.toString());
                        top = target;
                    }

//            }
//            catch(Exception e) {
//                isProcessing = false;
//                throw new AxisCameraException("Error: "+e.getMessage());
//            }
        }
        else {
            isProcessing = false;
            throw new AxisCameraException("Couldn't get image.");
        }
        isProcessing = false;
        System.out.println("Finished processing.");
    }