Merge remote-tracking branch 'origin/Java' into Java

# Conflicts:
#	Main/src/main/java/com/chameleonvision/vision/process/CVProcess.java
This commit is contained in:
Banks Troutman
2019-09-22 02:51:44 -04:00
6 changed files with 56 additions and 33 deletions

View File

@@ -24,13 +24,17 @@ public class NetworkSettings {
}
executeCommand("hostnamectl set-hostname " + this.hostname);
}
//TODO add windows networking commands
// else
// if (SystemUtils.IS_OS_WINDOWS)
// {
// executeCommand("cmd /c COMMAND HERE");
// }
//TODO check windows commands
else if (SystemUtils.IS_OS_WINDOWS) {
if (!adapter.equals("")) {
if (connectionType.equals("DHCP"))
executeCommand("cmd /c interface ip set address \"" + adapter + "\" dhcp");
else if (connectionType.equals("Static")) {
executeCommand("cmd /c netsh interface ip set address \"" + adapter + "\" static " + this.ip + " " + this.netmask + " " + this.gateway + "1");
}
}
//TODO find a way to change hostname in windows
}
}
private void executeCommand(String command) {
@@ -51,7 +55,7 @@ public class NetworkSettings {
Enumeration<InetAddress> ee = netint.getInetAddresses();
for (InetAddress addr : Collections.list(ee))
if (addr instanceof Inet4Address)
if ((addr.getAddress()[0] & 0xFF) == 10 && (addr.getAddress()[1] & 0xFF) == SettingsManager.GeneralSettings.team_number) {
if ((addr.getAddress()[0] & 0xFF) == 10 && (addr.getAddress()[1] & 0xFF) == SettingsManager.GeneralSettings.team_number) {
System.out.println("found robot network interface at " + netint.getName() + " ip: " + addr.getHostAddress());
return netint.getName();
}

View File

@@ -53,29 +53,33 @@ public class CVProcess {
return FoundContours;
}
List<MatOfPoint> FilterContours(List<MatOfPoint> InputContours, List<Integer> area, List<Integer> ratio, List<Integer> extent) {
for (MatOfPoint Contour : InputContours) {
try {
var contourArea = Imgproc.contourArea(Contour);
double targetArea = FastMath.round((contourArea / CamVals.ImageArea) * 100);
if (targetArea <= area.get(0) || targetArea >= area.get(1)) {
continue;
}
var rect = Imgproc.minAreaRect(new MatOfPoint2f(Contour.toArray()));
var targetFullness = (contourArea / rect.size.area()) * 100;
if (targetFullness <= extent.get(0) || targetArea >= extent.get(1)) {
continue;
}
var aspectRatio = rect.size.width / rect.size.height;
if (aspectRatio <= ratio.get(0) || aspectRatio >= ratio.get(1)) {
continue;
}
FilteredContours.add(Contour);
} catch (Exception ignored) {
}
}
return FilteredContours;
}
List<MatOfPoint> FilterContours(List<MatOfPoint> InputContours, List<Integer> area, List<Integer> ratio, List<Integer> extent) {
for (MatOfPoint Contour : InputContours){
try{
var contourArea = Imgproc.contourArea(Contour);//TODO change scaling
int targetArea = (int) ((((float) contourArea) / CamVals.ImageArea) * 100);
if (targetArea < area.get(0) || targetArea > area.get(1)){
continue;
}
var rect = Imgproc.minAreaRect(new MatOfPoint2f(Contour.toArray()));
var targetFullness = (contourArea / rect.size.area()) * 100;
if (targetFullness < extent.get(0) || targetArea > extent.get(1)){
continue;
}
double aspectRatio = rect.size.width / rect.size.height;//TODO i think aspectRatio is inverted
if (aspectRatio < ratio.get(0) || aspectRatio > ratio.get(1)){
continue;
}
FilteredContours.add(Contour);
}
catch (Exception e)
{
System.err.println("Error while filtering contours");
e.printStackTrace();
}
}
return FilteredContours;
}
private double calcDistance(RotatedRect rect) {
return FastMath.sqrt(FastMath.pow(CamVals.CenterX - rect.center.x, 2) + FastMath.pow(CamVals.CenterY - rect.center.y, 2));