Refactor member variables and functions to start with lowercase letters

This commit is contained in:
Matt
2019-10-02 22:12:52 -07:00
parent 645e3ed360
commit b618b7f897
2 changed files with 60 additions and 61 deletions

View File

@@ -3,7 +3,6 @@ package com.chameleonvision.vision.process;
import com.chameleonvision.settings.SettingsManager;
import com.chameleonvision.vision.Pipeline;
import com.chameleonvision.vision.camera.Camera;
import com.chameleonvision.web.Server;
import com.chameleonvision.web.ServerHandler;
import edu.wpi.cscore.VideoException;
import edu.wpi.first.networktables.*;
@@ -31,14 +30,14 @@ public class VisionProcess implements Runnable {
private Pipeline currentPipeline;
private CVProcess cvProcess;
// pipeline process items
private List<MatOfPoint> FoundContours = new ArrayList<>();
private List<MatOfPoint> FilteredContours = new ArrayList<>();
private List<RotatedRect> GroupedContours = new ArrayList<>();
private List<MatOfPoint> foundContours = new ArrayList<>();
private List<MatOfPoint> filteredContours = new ArrayList<>();
private List<RotatedRect> groupedContours = new ArrayList<>();
private Mat cameraInputMat = new Mat();
private Mat hsvThreshMat = new Mat();
private Mat streamOutputMat = new Mat();
private Scalar contourRectColor = new Scalar(255, 0, 0);
private long TimeStamp = 0;
private long timeStamp = 0;
public VisionProcess(Camera processCam) {
camera = processCam;
@@ -53,8 +52,8 @@ public class VisionProcess implements Runnable {
ntDistanceEntry = ntTable.getEntry("distance");
ntTimeStampEntry = ntTable.getEntry("timestamp");
ntValidEntry = ntTable.getEntry("is_valid");
ntDriverModeEntry.addListener(this::DriverModeListener, EntryListenerFlags.kUpdate);
ntPipelineEntry.addListener(this::PipelineListener, EntryListenerFlags.kUpdate);
ntDriverModeEntry.addListener(this::driverModeListener, EntryListenerFlags.kUpdate);
ntPipelineEntry.addListener(this::pipelineListener, EntryListenerFlags.kUpdate);
ntDriverModeEntry.setBoolean(false);
ntPipelineEntry.setNumber(camera.getCurrentPipelineIndex());
@@ -63,7 +62,7 @@ public class VisionProcess implements Runnable {
cameraProcess = new CameraProcess(camera);
}
private void DriverModeListener(EntryNotification entryNotification) {
private void driverModeListener(EntryNotification entryNotification) {
if (entryNotification.value.getBoolean()) {
camera.setExposure(25);
camera.setBrightness(15);
@@ -74,7 +73,7 @@ public class VisionProcess implements Runnable {
}
}
private void PipelineListener(EntryNotification entryNotification) {
private void pipelineListener(EntryNotification entryNotification) {
var ntPipelineIndex = (int) entryNotification.value.getDouble();
if (camera.getPipelines().containsKey(ntPipelineIndex)) {
// camera.setEntryNotification.value.getString());
@@ -117,7 +116,7 @@ public class VisionProcess implements Runnable {
ntDistanceEntry.setNumber(pipelineResult.Area);
NetworkTableInstance.getDefault().flush();
}
ntTimeStampEntry.setNumber(TimeStamp);
ntTimeStampEntry.setNumber(timeStamp);
}
private PipelineResult runVisionProcess(Mat inputImage, Mat outputImage) {
@@ -136,20 +135,20 @@ public class VisionProcess implements Runnable {
Scalar hsvLower = new Scalar(currentPipeline.hue.get(0), currentPipeline.saturation.get(0), currentPipeline.value.get(0));
Scalar hsvUpper = new Scalar(currentPipeline.hue.get(1), currentPipeline.saturation.get(1), currentPipeline.value.get(1));
cvProcess.HSVThreshold(inputImage, hsvThreshMat, hsvLower, hsvUpper, currentPipeline.erode, currentPipeline.dilate);
cvProcess.hsvThreshold(inputImage, hsvThreshMat, hsvLower, hsvUpper, currentPipeline.erode, currentPipeline.dilate);
if (currentPipeline.is_binary == 1) {
Imgproc.cvtColor(hsvThreshMat, outputImage, Imgproc.COLOR_GRAY2BGR, 3);
} else {
inputImage.copyTo(outputImage);
}
FoundContours = cvProcess.FindContours(hsvThreshMat);
if (FoundContours.size() > 0) {
FilteredContours = cvProcess.FilterContours(FoundContours, currentPipeline.area, currentPipeline.ratio, currentPipeline.extent);
if (FilteredContours.size() > 0) {
GroupedContours = cvProcess.GroupTargets(FilteredContours, currentPipeline.target_intersection, currentPipeline.target_group);
if (GroupedContours.size() > 0) {
var finalRect = cvProcess.SortTargetsToOne(GroupedContours, currentPipeline.sort_mode);
foundContours = cvProcess.findContours(hsvThreshMat);
if (foundContours.size() > 0) {
filteredContours = cvProcess.filterContours(foundContours, currentPipeline.area, currentPipeline.ratio, currentPipeline.extent);
if (filteredContours.size() > 0) {
groupedContours = cvProcess.groupTargets(filteredContours, currentPipeline.target_intersection, currentPipeline.target_group);
if (groupedContours.size() > 0) {
var finalRect = cvProcess.sortTargetsToOne(groupedContours, currentPipeline.sort_mode);
// System.out.printf("Largest Contour Area: %.2f\n", finalRect.size.area());
pipelineResult.RawPoint = finalRect;
pipelineResult.IsValid = true;
@@ -188,9 +187,9 @@ public class VisionProcess implements Runnable {
while (!Thread.interrupted()) {
startTime = System.nanoTime();
if ((startTime - lastFrameEndNanosec) * 1e-6 >= 1000.0 / maxFps + 3) { // 3 additional fps to allow for overhead
FoundContours.clear();
FilteredContours.clear();
GroupedContours.clear();
foundContours.clear();
filteredContours.clear();
groupedContours.clear();
// update FPS for ui only every 0.5 seconds
if ((startTime - fpsLastTime) * 1e-6 >= 500) {
@@ -204,7 +203,7 @@ public class VisionProcess implements Runnable {
currentPipeline = camera.getCurrentPipeline();
// start fps counter right before grabbing input frame
TimeStamp = cameraProcess.getLatestFrame(cameraInputMat);
timeStamp = cameraProcess.getLatestFrame(cameraInputMat);
if (cameraInputMat.cols() == 0 && cameraInputMat.rows() == 0) {
continue;
}