mirror of
https://github.com/PhotonVision/photonvision
synced 2026-07-05 03:21:40 +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 List<Integer> value = Arrays.asList(50, 255);
|
||||||
public boolean erode = false;
|
public boolean erode = false;
|
||||||
public boolean dilate = false;
|
public boolean dilate = false;
|
||||||
public List<Double> area = Arrays.asList(0.0, 100.0);
|
public List<Integer> area = Arrays.asList(0, 100);
|
||||||
public List<Double> ratio = Arrays.asList(0.0, 20.0);
|
public List<Double> ratio = Arrays.asList(0D, 20D);
|
||||||
public List<Double> extent = Arrays.asList(0.0, 100.0);
|
public List<Integer> extent = Arrays.asList(0, 100);
|
||||||
public int is_binary = 0;
|
public int is_binary = 0;
|
||||||
public String sort_mode = "Largest";
|
public String sort_mode = "Largest";
|
||||||
public String target_group = "Single";
|
public String target_group = "Single";
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ public class CVProcess {
|
|||||||
return FoundContours;
|
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) {
|
for (MatOfPoint Contour : InputContours) {
|
||||||
try {
|
try {
|
||||||
double contourArea = Imgproc.contourArea(Contour); //TODO change scaling
|
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.Pipeline;
|
||||||
import com.chameleonvision.vision.camera.Camera;
|
import com.chameleonvision.vision.camera.Camera;
|
||||||
import com.chameleonvision.vision.camera.CameraManager;
|
import com.chameleonvision.vision.camera.CameraManager;
|
||||||
|
import com.google.gson.JsonArray;
|
||||||
import edu.wpi.cscore.VideoException;
|
import edu.wpi.cscore.VideoException;
|
||||||
import io.javalin.websocket.WsCloseContext;
|
import io.javalin.websocket.WsCloseContext;
|
||||||
import io.javalin.websocket.WsConnectContext;
|
import io.javalin.websocket.WsConnectContext;
|
||||||
@@ -52,9 +53,7 @@ public class ServerHandler {
|
|||||||
Object value = jsonObject.get(key);
|
Object value = jsonObject.get(key);
|
||||||
System.out.printf("Got websocket json data: [%s, %s]\n", key, value);
|
System.out.printf("Got websocket json data: [%s, %s]\n", key, value);
|
||||||
if (hasField(CameraManager.getCurrentPipeline(), key)) {
|
if (hasField(CameraManager.getCurrentPipeline(), key)) {
|
||||||
setField(CameraManager.getCurrentPipeline(), key, value);
|
//Special cases for exposure and brightness and aspect ratio
|
||||||
//Special cases for exposure and brightness
|
|
||||||
//TODO maybe add listener for value changes instead of this special case
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case "exposure":
|
case "exposure":
|
||||||
int newExposure = (int) value;
|
int newExposure = (int) value;
|
||||||
@@ -64,13 +63,24 @@ public class ServerHandler {
|
|||||||
} catch (VideoException e) {
|
} catch (VideoException e) {
|
||||||
System.out.println("Exposure changes is not supported on your webcam/webcam's driver");
|
System.out.println("Exposure changes is not supported on your webcam/webcam's driver");
|
||||||
}
|
}
|
||||||
//TODO check if this crash occurs on linux
|
|
||||||
break;
|
break;
|
||||||
case "brightness":
|
case "brightness":
|
||||||
int newBrightness = (int) value;
|
int newBrightness = (int) value;
|
||||||
System.out.printf("Changing brightness to %d\n", newBrightness);
|
System.out.printf("Changing brightness to %d\n", newBrightness);
|
||||||
CameraManager.getCurrentCamera().setBrightness(newBrightness);
|
CameraManager.getCurrentCamera().setBrightness(newBrightness);
|
||||||
break;
|
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 {
|
} else {
|
||||||
switch (key) {
|
switch (key) {
|
||||||
@@ -84,8 +94,8 @@ public class ServerHandler {
|
|||||||
String newCamera = (String) value;
|
String newCamera = (String) value;
|
||||||
System.out.printf("Changing camera to %s\n", newCamera);
|
System.out.printf("Changing camera to %s\n", newCamera);
|
||||||
CameraManager.setCurrentCamera(newCamera);
|
CameraManager.setCurrentCamera(newCamera);
|
||||||
HashMap<String,Integer> portMap = new HashMap<String, Integer>();
|
HashMap<String, Integer> portMap = new HashMap<String, Integer>();
|
||||||
portMap.put("port",CameraManager.getCurrentCamera().getStreamPort());
|
portMap.put("port", CameraManager.getCurrentCamera().getStreamPort());
|
||||||
broadcastMessage(portMap);
|
broadcastMessage(portMap);
|
||||||
broadcastMessage(CameraManager.getCurrentCamera()); //TODO CHECK JSON FOR CAMERA CHANGE
|
broadcastMessage(CameraManager.getCurrentCamera()); //TODO CHECK JSON FOR CAMERA CHANGE
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user