bugfix for camera mat 0

This commit is contained in:
ori agranat
2019-09-15 00:46:26 +03:00
parent d6850f73b1
commit 440d68a1f1
2 changed files with 14 additions and 9 deletions

View File

@@ -23,14 +23,16 @@ public class CameraProcess implements Runnable{
//calling all classes
CameraServer cs = CameraServer.getInstance();
// NetworkTableInstance networkTableInstance = NetworkTableInstance.getDefault();
NetworkTableInstance networkTableInstance = NetworkTableInstance.getDefault();
SettingsManager manager = SettingsManager.getInstance();
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;
var cv_publish = cs.putVideo(CameraName,Width,Height);
@@ -53,10 +55,13 @@ public class CameraProcess implements Runnable{
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);
// 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);
if (mat.cols() !=0 && mat.rows() != 0) {
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);
}
}
}