Skip to content

Commit

Permalink
Fixes the CameraSettings arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
CesarCoelho committed Feb 23, 2023
1 parent 6115fde commit 0268bb2
Showing 1 changed file with 16 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
* @author marcel.mikolajko
*/
public class PlatformCommands {

static Logger LOGGER = Logger.getLogger(PlatformCommands.class.getName());

@Command(name = "gps", subcommands = {GetNMEASentence.class})
Expand All @@ -66,6 +67,7 @@ public static class Camera {

@Command(name = "take-picture", description = "Take a picture from the camera")
public static class TakePicture extends BaseCommand implements Runnable {

@Option(names = {"-res", "--resolution"}, paramLabel = "<resolution>", required = true,
description = "Resolution of the image in format widthxheigh. For example 1920x1080")
String resolution;
Expand Down Expand Up @@ -109,17 +111,20 @@ public void run() {
}

String[] res = resolution.split("x");
CameraSettings settings = new CameraSettings(new PixelResolution(new UInteger(Integer.parseInt(res[0])),
new UInteger(Integer.parseInt(res[1]))), PictureFormat.fromString(format.toUpperCase()), new Duration(
Double.parseDouble(exposure)), Float.parseFloat(gainRed), Float.parseFloat(gainGreen), Float
.parseFloat(gainBlue));
CameraSettings settings = new CameraSettings(
new PixelResolution(new UInteger(Integer.parseInt(res[0])), new UInteger(Integer.parseInt(res[1]))),
PictureFormat.fromString(format.toUpperCase()),
new Duration(Double.parseDouble(exposure)),
Float.parseFloat(gainRed), Float.parseFloat(gainGreen), Float.parseFloat(gainBlue),
null
);

final Object lock = new Object();
try {
camera.takePicture(settings, new CameraAdapter() {
@Override
public void takePictureResponseReceived(MALMessageHeader msgHeader, Picture picture,
Map qosProperties) {
Map qosProperties) {
System.out.println("Picture received: " + picture);
try {
filename = filename + "." + format.toLowerCase();
Expand All @@ -136,7 +141,7 @@ public void takePictureResponseReceived(MALMessageHeader msgHeader, Picture pict

@Override
public void takePictureResponseErrorReceived(MALMessageHeader msgHeader, MALStandardError error,
Map qosProperties) {
Map qosProperties) {
LOGGER.log(Level.SEVERE, "Error during takePicture!", error);
synchronized (lock) {
lock.notifyAll();
Expand Down Expand Up @@ -172,6 +177,7 @@ public void takePictureResponseErrorReceived(MALMessageHeader msgHeader, MALStan

@Command(name = "get-status", description = "Gets the provider status")
public static class GetStatus extends BaseCommand implements Runnable {

@Override
public void run() {
if (!super.initRemoteConsumer()) {
Expand Down Expand Up @@ -215,8 +221,9 @@ public void run() {

@Command(name = "get-nmea-sentence", description = "Gets the NMEA sentence")
public static class GetNMEASentence extends BaseCommand implements Runnable {

@Parameters(arity = "1", paramLabel = "<sentenceIdentifier>", index = "0",
description = "Identifier of the sentence")
description = "Identifier of the sentence")
String sentenceId;

@Override
Expand All @@ -239,7 +246,7 @@ public void run() {
gps.getNMEASentence(sentenceId, new GPSAdapter() {
@Override
public void getNMEASentenceResponseReceived(MALMessageHeader msgHeader, String sentence,
Map qosProperties) {
Map qosProperties) {
System.out.println("Sentence received: " + sentence);

synchronized (lock) {
Expand All @@ -249,7 +256,7 @@ public void getNMEASentenceResponseReceived(MALMessageHeader msgHeader, String s

@Override
public void getNMEASentenceResponseErrorReceived(MALMessageHeader msgHeader, MALStandardError error,
Map qosProperties) {
Map qosProperties) {
LOGGER.log(Level.SEVERE, "Error during getNMEASentence!", error);
synchronized (lock) {
lock.notifyAll();
Expand All @@ -266,4 +273,3 @@ public void getNMEASentenceResponseErrorReceived(MALMessageHeader msgHeader, MAL
}
}
}
//------------------------------------------------------------------------------

0 comments on commit 0268bb2

Please sign in to comment.