mirror of
https://github.com/PhotonVision/photonvision
synced 2026-06-20 00:51:41 +00:00
Fix for ratio in decimal number
This commit is contained in:
@@ -12,9 +12,9 @@ public class Pipeline {
|
||||
public List<Integer> value = Arrays.asList(50, 255);
|
||||
public boolean erode = false;
|
||||
public boolean dilate = false;
|
||||
public List<Double> area = Arrays.asList(0.0, 100.0);
|
||||
public List<Double> ratio = Arrays.asList(0.0, 20.0);
|
||||
public List<Double> extent = Arrays.asList(0.0, 100.0);
|
||||
public List<Integer> area = Arrays.asList(0, 100);
|
||||
public List<Double> ratio = Arrays.asList(0D, 20D);
|
||||
public List<Integer> extent = Arrays.asList(0, 100);
|
||||
public int is_binary = 0;
|
||||
public String sort_mode = "Largest";
|
||||
public String target_group = "Single";
|
||||
|
||||
@@ -53,7 +53,7 @@ public class CVProcess {
|
||||
return FoundContours;
|
||||
}
|
||||
|
||||
List<MatOfPoint> FilterContours(List<MatOfPoint> InputContours, List<Double> area, List<Double> ratio, List<Double> extent) {
|
||||
List<MatOfPoint> FilterContours(List<MatOfPoint> InputContours, List<Integer> area, List<Double> ratio, List<Integer> extent) {
|
||||
for (MatOfPoint Contour : InputContours) {
|
||||
try {
|
||||
double contourArea = Imgproc.contourArea(Contour); //TODO change scaling
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.chameleonvision.settings.SettingsManager;
|
||||
import com.chameleonvision.vision.Pipeline;
|
||||
import com.chameleonvision.vision.camera.Camera;
|
||||
import com.chameleonvision.vision.camera.CameraManager;
|
||||
import com.google.gson.JsonArray;
|
||||
import edu.wpi.cscore.VideoException;
|
||||
import io.javalin.websocket.WsCloseContext;
|
||||
import io.javalin.websocket.WsConnectContext;
|
||||
@@ -52,9 +53,7 @@ public class ServerHandler {
|
||||
Object value = jsonObject.get(key);
|
||||
System.out.printf("Got websocket json data: [%s, %s]\n", key, value);
|
||||
if (hasField(CameraManager.getCurrentPipeline(), key)) {
|
||||
setField(CameraManager.getCurrentPipeline(), key, value);
|
||||
//Special cases for exposure and brightness
|
||||
//TODO maybe add listener for value changes instead of this special case
|
||||
//Special cases for exposure and brightness and aspect ratio
|
||||
switch (key) {
|
||||
case "exposure":
|
||||
int newExposure = (int) value;
|
||||
@@ -64,13 +63,24 @@ public class ServerHandler {
|
||||
} catch (VideoException e) {
|
||||
System.out.println("Exposure changes is not supported on your webcam/webcam's driver");
|
||||
}
|
||||
//TODO check if this crash occurs on linux
|
||||
break;
|
||||
case "brightness":
|
||||
int newBrightness = (int) value;
|
||||
System.out.printf("Changing brightness to %d\n", newBrightness);
|
||||
CameraManager.getCurrentCamera().setBrightness(newBrightness);
|
||||
break;
|
||||
case "ratio":
|
||||
//If there is any better to convert Integer to Double you're welcome to change it
|
||||
List<Double> doubleRatio = CameraManager.getCurrentPipeline().ratio;
|
||||
List<Object> newRatio = ((JSONArray) value).toList();
|
||||
for (int i = 0; i < newRatio.size(); i++) {
|
||||
doubleRatio.set(i, Double.parseDouble(newRatio.get(i).toString()));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
//Any other field in CameraManager that doesn't need anything special
|
||||
setField(CameraManager.getCurrentPipeline(), key, value);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
switch (key) {
|
||||
@@ -84,8 +94,8 @@ public class ServerHandler {
|
||||
String newCamera = (String) value;
|
||||
System.out.printf("Changing camera to %s\n", newCamera);
|
||||
CameraManager.setCurrentCamera(newCamera);
|
||||
HashMap<String,Integer> portMap = new HashMap<String, Integer>();
|
||||
portMap.put("port",CameraManager.getCurrentCamera().getStreamPort());
|
||||
HashMap<String, Integer> portMap = new HashMap<String, Integer>();
|
||||
portMap.put("port", CameraManager.getCurrentCamera().getStreamPort());
|
||||
broadcastMessage(portMap);
|
||||
broadcastMessage(CameraManager.getCurrentCamera()); //TODO CHECK JSON FOR CAMERA CHANGE
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user