Last active
August 29, 2015 14:10
-
-
Save sylvia43/d9978595284dd30dd728 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package edu.wpi.first.wpilibj.templates; | |
import edu.wpi.first.wpilibj.SimpleRobot; | |
import edu.wpi.first.wpilibj.camera.AxisCamera; | |
import edu.wpi.first.wpilibj.camera.AxisCameraException; | |
import edu.wpi.first.wpilibj.image.BinaryImage; | |
import edu.wpi.first.wpilibj.image.ColorImage; | |
import edu.wpi.first.wpilibj.image.CriteriaCollection; | |
import edu.wpi.first.wpilibj.image.NIVision; | |
import edu.wpi.first.wpilibj.image.NIVisionException; | |
import edu.wpi.first.wpilibj.image.ParticleAnalysisReport; | |
public class RobotTemplate extends SimpleRobot { | |
AxisCamera camera; | |
public void robotInit() { | |
camera = AxisCamera.getInstance(); | |
} | |
public void operatorControl() { | |
try { | |
CriteriaCollection cc = new CriteriaCollection(); | |
cc.addCriteria(NIVision.MeasurementType.IMAQ_MT_AREA, 200, 65536, false); // Filter small particles | |
ColorImage colorImage = camera.getImage(); | |
BinaryImage colorThreshold = colorImage.thresholdHSV(105, 137, 230, 255, 133, 183); // Filter only bright green | |
BinaryImage particleFiltered = colorThreshold.particleFilter(cc); // Apply small particle filter | |
int numParticles = particleFiltered.getNumberParticles(); | |
for (int i=0;i<numParticles;i++) { | |
ParticleAnalysisReport report = particleFiltered.getParticleAnalysisReport(i); // Go through each particle | |
// These particles should only be the reflective tape | |
} | |
} catch (AxisCameraException e) { | |
e.printStackTrace(); | |
} catch (NIVisionException e) { | |
e.printStackTrace(); | |
} | |
} | |
public void test() { | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment