use of uk.ac.sussex.gdsc.smlm.data.config.CalibrationProtos.CameraModelSettings in project GDSC-SMLM by aherbert.
the class CameraModelManager method listCameraModels.
/**
* List the camera models with the correct dimensions.
*
* @param includeNone Set to true to include an empty string
* @param width the width
* @param height the height
* @return the list
*/
public static String[] listCameraModels(boolean includeNone, int width, int height) {
final CameraModelSettings settings = CameraModelSettingsHolder.getSettings();
final List<String> list = createList(includeNone);
for (final Map.Entry<String, CameraModelResource> entry : settings.getCameraModelResourcesMap().entrySet()) {
final CameraModelResource resource = entry.getValue();
if (resource.getWidth() == width && resource.getHeight() == height) {
list.add(entry.getKey());
}
}
return list.toArray(new String[0]);
}
use of uk.ac.sussex.gdsc.smlm.data.config.CalibrationProtos.CameraModelSettings in project GDSC-SMLM by aherbert.
the class CameraModelManager method load.
/**
* Load the camera model. Returns null if the named model does not exist. Writes to the ImageJ log
* if a problems occurred loading the model.
*
* @param name the name
* @return the per pixel camera model (or null)
*/
public static PerPixelCameraModel load(String name) {
PerPixelCameraModel model = cameraModels.get(name);
if (model == null) {
final CameraModelSettings settings = CameraModelSettingsHolder.getSettings();
// Try and get the named resource
final CameraModelResource resource = settings.getCameraModelResourcesMap().get(name);
if (resource == null) {
return null;
}
model = loadFromFile(name, resource.getFilename());
// Cache this
cameraModels.put(name, model);
}
return model;
}
use of uk.ac.sussex.gdsc.smlm.data.config.CalibrationProtos.CameraModelSettings in project GDSC-SMLM by aherbert.
the class CameraModelManager method saveResource.
private static void saveResource(PerPixelCameraModel cameraModel, String filename, String name) {
final CameraModelResource.Builder resource = CameraModelResource.newBuilder();
resource.setX(cameraModel.getXOrigin());
resource.setY(cameraModel.getYOrigin());
resource.setWidth(cameraModel.getWidth());
resource.setHeight(cameraModel.getHeight());
resource.setFilename(filename);
final CameraModelSettings settings = CameraModelSettingsHolder.getSettings();
CameraModelSettingsHolder.setSettings(settings.toBuilder().putCameraModelResources(name, resource.build()).build());
// Cache this
cameraModels.put(name, cameraModel);
}
use of uk.ac.sussex.gdsc.smlm.data.config.CalibrationProtos.CameraModelSettings in project GDSC-SMLM by aherbert.
the class CameraModelManager method listCameraModels.
/**
* List the camera models.
*
* @param includeNone Set to true to include an invalid none model string
* @return the list
*/
public static String[] listCameraModels(boolean includeNone) {
final CameraModelSettings settings = CameraModelSettingsHolder.getSettings();
final List<String> list = createList(includeNone);
list.addAll(settings.getCameraModelResourcesMap().keySet());
return list.toArray(new String[0]);
}
use of uk.ac.sussex.gdsc.smlm.data.config.CalibrationProtos.CameraModelSettings in project GDSC-SMLM by aherbert.
the class CameraModelManager method run.
@Override
public void run(String arg) {
SmlmUsageTracker.recordPlugin(this.getClass(), arg);
String[] options = OPTIONS;
final CameraModelSettings settings = CameraModelSettingsHolder.getSettings();
if (settings.getCameraModelResourcesCount() == 0) {
options = Arrays.copyOf(OPTIONS, 2);
}
pluginSettings = readCameraModelManagerSettings();
final ExtendedGenericDialog gd = new ExtendedGenericDialog(TITLE);
gd.addChoice("Option", options, pluginSettings.getOption());
gd.addHelp(HelpUrls.getUrl("camera-model-manager"));
gd.showDialog();
if (gd.wasCanceled()) {
return;
}
pluginSettings.setOption(gd.getNextChoiceIndex());
switch(pluginSettings.getOption()) {
case 5:
runFilterImage();
break;
case 4:
runDeleteCameraModel(settings);
break;
case 3:
runViewCameraModel(settings);
break;
case 2:
runPrintCameraModels(settings);
break;
case 1:
runLoadFromDirectory();
break;
case 0:
default:
runLoadFromFile();
}
writeCameraModelManagerSettings(pluginSettings);
}
Aggregations