More driverMode tweaks, and StreamDivisor , change port to 5800

This commit is contained in:
Banks Troutman
2019-11-03 14:15:36 -05:00
parent a5477a7e4e
commit 386533a41a
8 changed files with 32 additions and 32 deletions

View File

@@ -22,7 +22,7 @@ public class Main {
private static final String NETWORK_MANAGE_KEY = "--unmanage-network"; // no args for this setting
private static final String IGNORE_ROOT = "--ignore-root"; // no args for this setting
private static final int DEFAULT_PORT = 8888;
private static final int DEFAULT_PORT = 5800;
private static boolean ntServerMode = false;
private static boolean manageNetwork = true;

View File

@@ -147,12 +147,12 @@ public class Camera {
}
private void updateCvSource() {
CameraManager.getVisionProcessByCameraName(name).cameraProcess.updateFrameSize();
synchronized (cvSourceLock) {
var newWidth = camVideoMode.width / streamDivisor.value;
var newHeight = camVideoMode.height / streamDivisor.value;
cvSource = cs.putVideo(name, newWidth, newHeight);
}
CameraManager.getVisionProcessByCameraName(name).cameraProcess.updateFrameSize();
ServerHandler.sendFullSettings();
}

View File

@@ -15,7 +15,7 @@ public class CameraSerializer implements JsonSerializer<Camera> {
var pipelines = context.serialize(camera.getPipelines());
obj.add("pipelines", pipelines);
obj.addProperty("resolution", camera.getVideoModeIndex());
obj.add("camVideoMode", context.serialize(camera.getVideoMode()));
// obj.add("camVideoMode", context.serialize(camera.getVideoMode()));
obj.add("isDriver",context.serialize(camera.getDriverMode()));
obj.add("driverExposure",context.serialize(camera.getDriverExposure()));
obj.add("driverBrightness",context.serialize(camera.getDriverBrightness()));

View File

@@ -10,42 +10,40 @@ import org.opencv.imgproc.Imgproc;
public class CameraProcess implements Runnable {
private final Camera camera;
private final int maxFPS;
private final Object inputFrameLock = new Object();
private final Object outputFrameLock = new Object();
private Mat inputFrame;
private final Object inputFrameLock = new Object();
private int maxFPS;
private Mat outputFrame;
private Mat inputFrame;
private long timestamp;
private StreamDivisor divisor;
CameraProcess(Camera camera) {
this.camera = camera;
maxFPS = camera.getVideoMode().fps;
updateFrameSize();
}
public void updateFrameSize() {
var camVals = camera.getCamVals();
maxFPS = camera.getVideoMode().fps;
divisor = camera.getStreamDivisor();
var newWidth = camVals.ImageWidth / divisor.value;
var newHeight = camVals.ImageHeight / divisor.value;
synchronized (inputFrameLock) {
inputFrame = new Mat(newWidth, newHeight, CvType.CV_8UC3);
}
var camVidMode = camera.getVideoMode();
var newWidth = camVidMode.width / divisor.value;
var newHeight = camVidMode.height / divisor.value;
synchronized (outputFrameLock) {
outputFrame = new Mat(newWidth, newHeight, CvType.CV_8UC3);
}
}
void updateFrame(Mat inputFrame) {
synchronized (inputFrameLock) {
inputFrame.copyTo(this.inputFrame);
void setOutputFrame(Mat inputFrame) {
synchronized (outputFrameLock) {
inputFrame.copyTo(this.outputFrame);
}
}
long getLatestFrame(Mat outputFrame) {
synchronized (outputFrameLock) {
this.outputFrame.copyTo(outputFrame);
long getInputFrame(Mat inputFrame) {
synchronized (inputFrameLock) {
this.inputFrame.copyTo(inputFrame);
return timestamp;
}
}
@@ -53,18 +51,18 @@ public class CameraProcess implements Runnable {
@Override
public void run() {
while (!Thread.interrupted()) {
synchronized (outputFrameLock) {
timestamp = camera.grabFrame(outputFrame);
}
synchronized (inputFrameLock) {
timestamp = camera.grabFrame(inputFrame);
}
synchronized (outputFrameLock) {
if (divisor.value != 1) {
var camVals = camera.getCamVals();
var newWidth = camVals.ImageWidth / divisor.value;
var newHeight = camVals.ImageHeight / divisor.value;
var camVidMode = camera.getVideoMode();
var newWidth = camVidMode.width / divisor.value;
var newHeight = camVidMode.height / divisor.value;
Size newSize = new Size(newWidth, newHeight);
Imgproc.resize(inputFrame, inputFrame, newSize);
Imgproc.resize(outputFrame, outputFrame, newSize);
}
camera.putFrame(inputFrame);
camera.putFrame(outputFrame);
}
var msToWait = (long) 1000 / maxFPS;
try {

View File

@@ -1,7 +1,6 @@
package com.chameleonvision.vision.process;
import com.chameleonvision.settings.SettingsManager;
import com.chameleonvision.vision.CalibrationMode;
import com.chameleonvision.vision.Orientation;
import com.chameleonvision.vision.Pipeline;
import com.chameleonvision.vision.camera.Camera;
@@ -218,7 +217,7 @@ public class VisionProcess implements Runnable {
currentPipeline = camera.getCurrentPipeline();
// start fps counter right before grabbing input frame
timeStamp = cameraProcess.getLatestFrame(cameraInputMat);
timeStamp = cameraProcess.getInputFrame(cameraInputMat);
if (cameraInputMat.cols() == 0 && cameraInputMat.rows() == 0) {
continue;
}
@@ -249,7 +248,7 @@ public class VisionProcess implements Runnable {
ServerHandler.broadcastMessage(WebSend);
}
cameraProcess.updateFrame(streamOutputMat);
cameraProcess.setOutputFrame(streamOutputMat);
cameraInputMat.release();
hsvThreshMat.release();

View File

@@ -191,6 +191,9 @@ public class ServerHandler {
case "driverExposure":
cam.setDriverExposure((Integer) value);
break;
case "isDriver":
cam.setDriverMode((boolean)value);
break;
default:
Field field = obj.getClass().getField(fieldName);
if (field.getType().isEnum()) {