This commit is contained in:
gobbo_a
2017-06-09 16:14:51 +02:00
parent 2bec0f441e
commit b0d319b209
2 changed files with 31 additions and 31 deletions

View File

@@ -600,12 +600,6 @@ public class ScreenPanelDev extends Panel {
System.out.println("Setting camera: " + cameraName + " [" + (buttonCamtool.isSelected() ? "camtool" : "direct") + "]");
parseUserOverlays();
errorOverlay = null;
checkBackground.setEnabled(false);
spinnerThreshold.setVisible(false);
spinnerGrThreshold.setVisible(false); labelGrThreshold.setVisible(false);
spinnerGrScale.setVisible(false); labelGrScale.setVisible(false);
checkThreshold.setEnabled(false);
checkGoodRegion.setEnabled(false);
if (dataTableDialog!=null){
dataTableDialog.dispose();
@@ -618,10 +612,10 @@ public class ScreenPanelDev extends Panel {
calibrationDialolg = null;
}
boolean was_camtool = false;
//boolean was_camtool = false;
if (camera != null) {
//camera.removeAllListeners();
was_camtool = camera instanceof Camtool;
//was_camtool = camera instanceof Camtool;
camera.close();
camera = null;
}
@@ -636,8 +630,16 @@ public class ScreenPanelDev extends Panel {
boolean changed = !String.valueOf(cameraName).equals(this.cameraName);
this.cameraName = cameraName;
if (changed || buttonDirect.isSelected()) {
spinnerThreshold.setVisible(false);
spinnerGrThreshold.setVisible(false); labelGrThreshold.setVisible(false);
spinnerGrScale.setVisible(false); labelGrScale.setVisible(false);
checkThreshold.setEnabled(false);
checkGoodRegion.setEnabled(false);
}
if (changed) {
checkBackground.setEnabled(false);
if ((devicesInitTask != null) && (devicesInitTask.isAlive())) {
devicesInitTask.interrupt();
}
@@ -676,27 +678,25 @@ public class ScreenPanelDev extends Panel {
camera.assertInitialized();
System.out.println("Camera initialization OK");
if (camera instanceof Camtool) {
//Managing no background exception. Can be done in a better way?
checkBackground.setEnabled(true);
if (changed || !was_camtool) {
((Camtool) camera).startPipeline(cameraName, null);
//Managing no background exception. Can be done in a better way?
//if (changed || !was_camtool) {
((Camtool) camera).startPipeline(cameraName, null);
((Camtool) camera).setBackgroundSubtraction(checkBackground.isSelected());
updateCamtoolControls();
} else {
HashMap<String, Object> gr = null;
if (goodRegion){
gr = new HashMap<>();
gr.put("threshold", spinnerGrThreshold.getValue());
gr.put("gfscale", spinnerGrScale.getValue());
}
((Camtool) camera).startPipeline(cameraName, null, checkBackground.isSelected(), null, checkThreshold.isSelected() ? (Double) spinnerThreshold.getValue() : null, gr);
}
//} else {
// HashMap<String, Object> gr = null;
// if (goodRegion){
// gr = new HashMap<>();
// gr.put("threshold", spinnerGrThreshold.getValue());
// gr.put("gfscale", spinnerGrScale.getValue());
// }
// ((Camtool) camera).startPipeline(cameraName, null, checkBackground.isSelected(), null, checkThreshold.isSelected() ? (Double) spinnerThreshold.getValue() : null, gr);
//}
checkThreshold.setEnabled(true);
checkGoodRegion.setEnabled(true);
((Camtool) camera).startReceiver();
} else {
checkBackground.setEnabled(true);
checkBackground.setSelected(false);
} else {
checkThreshold.setSelected(false);
checkGoodRegion.setSelected(false);
if (polling <= 0) {
@@ -773,7 +773,7 @@ public class ScreenPanelDev extends Panel {
onTimer();
}
onChangeColormap(null);
checkBackground.setEnabled(true);
if (changed) {
comboScreen.setModel(new DefaultComboBoxModel());
comboFilter.setModel(new DefaultComboBoxModel());
@@ -913,8 +913,7 @@ public class ScreenPanelDev extends Panel {
void updateCamtoolControls() {
if ((camera != null) && (camera instanceof Camtool)) {
updatingCamtoolControls = true;
try {
checkBackground.setSelected(((Camtool) camera).getBackgroundSubtraction());
try {
Double threshold = ((Camtool) camera).getThreshold();
checkThreshold.setSelected(threshold != null);
spinnerThreshold.setValue((threshold == null) ? 0 : threshold);
@@ -924,6 +923,7 @@ public class ScreenPanelDev extends Panel {
spinnerGrThreshold.setValue(gr.get("threshold"));
spinnerGrScale.setValue(gr.get("gfscale"));
}
checkBackground.setSelected(((Camtool) camera).getBackgroundSubtraction());
} catch (Exception ex) {
}
goodRegion = checkGoodRegion.isSelected();