mirror of
https://github.com/PhotonVision/photonvision
synced 2026-06-20 00:51:41 +00:00
added target grouping
This commit is contained in:
@@ -20,15 +20,16 @@ public class CameraProcess implements Runnable{
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
//calling all classes
|
||||
CameraServer cs = CameraServer.getInstance();
|
||||
NetworkTableInstance networkTableInstance = NetworkTableInstance.getDefault();
|
||||
// NetworkTableInstance networkTableInstance = NetworkTableInstance.getDefault();
|
||||
SettingsManager manager = SettingsManager.getInstance();
|
||||
VisionProcess visionProcess = new VisionProcess();
|
||||
manager.CamerasCurrentPipeline.put(CameraName,manager.Cameras.get(CameraName).pipelines.keySet().toArray()[0].toString());
|
||||
//Setting up camera and network table
|
||||
var Table = networkTableInstance.getTable("/Chameleon-Vision/" + CameraName);
|
||||
var PipeLineEntry = Table.getEntry("Pipeline");
|
||||
var DriverModeEntry = Table.getEntry("Driver_Mode");
|
||||
// var Table = networkTableInstance.getTable("/Chameleon-Vision/" + CameraName);
|
||||
// var PipeLineEntry = Table.getEntry("Pipeline");
|
||||
// var DriverModeEntry = Table.getEntry("Driver_Mode");
|
||||
var cv_sink = cs.getVideo(manager.UsbCameras.get(CameraName));
|
||||
int Width = manager.Cameras.get(CameraName).camVideoMode.width;
|
||||
int Height = manager.Cameras.get(CameraName).camVideoMode.heigh;
|
||||
@@ -42,14 +43,20 @@ public class CameraProcess implements Runnable{
|
||||
double VerticalView = FastMath.atan(FastMath.tan(DiagonalView/2) * (VerticalRatio / DiagonalView)) * 2;
|
||||
double H_FOCAL_LENGTH = Width / (2 * FastMath.tan(HorizontalView /2));
|
||||
double V_FOCAL_LENGTH = Width / (2 * FastMath.tan(VerticalView /2));
|
||||
double CenterX = ((double) Width / 2) - 0.5;
|
||||
double CenterY = ((double) Height/2) - 0.5;
|
||||
double CamArea = (double)(Width * Height);
|
||||
VisionProcess visionProcess = new VisionProcess(CenterX,CenterY,CamArea);
|
||||
Mat mat = new Mat();
|
||||
long time;
|
||||
|
||||
while (!Thread.interrupted()){
|
||||
Pipeline pipeline = manager.Cameras.get(CameraName).pipelines.get(manager.CamerasCurrentPipeline.get(CameraName));
|
||||
time = cv_sink.grabFrame(mat);
|
||||
Mat HSVImage = visionProcess.HSVThreshold(pipeline.hue,pipeline.saturation,pipeline.value,mat,pipeline.erode,pipeline.dilate);
|
||||
List<MatOfPoint> Contours = visionProcess.FindContours(HSVImage);
|
||||
// Mat HSVImage = visionProcess.HSVThreshold(pipeline.hue,pipeline.saturation,pipeline.value,mat,pipeline.erode,pipeline.dilate);
|
||||
// List<MatOfPoint> Contours = visionProcess.FindContours(HSVImage);
|
||||
// List<MatOfPoint> FilterdContours = visionProcess.FilterContours(Contours,pipeline.area,pipeline.ratio,pipeline.extent,pipeline.sort_mode,pipeline.target_intersection,pipeline.target_group);
|
||||
cv_publish.putFrame(mat);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user