Added driver mode exposure and brightness

This commit is contained in:
Omer
2019-11-01 11:38:58 +02:00
parent 972df541e9
commit 7ef05e6077
4 changed files with 118 additions and 76 deletions

View File

@@ -17,26 +17,37 @@ import java.util.List;
public class CameraDeserializer implements JsonDeserializer<Camera> {
@Override
public Camera deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext context) throws JsonParseException {
var jsonObj = jsonElement.getAsJsonObject();
var camFOV = jsonObj.get("FOV").getAsDouble();
var camName = jsonObj.get("name").getAsString();
var camNickname = jsonObj.get("nickname").getAsString();
var videoModeIndex = jsonObj.get("resolution").getAsInt();
var divisor = StreamDivisor.values()[jsonObj.get("streamDivisor").getAsInt()];
var pipelines = jsonObj.get("pipelines");
List<Pipeline> actualPipelines = new ArrayList<>();
ObjectMapper mapper = new ObjectMapper();
TypeFactory typeFactory = mapper.getTypeFactory();
JavaType arrayType = typeFactory.constructCollectionType(List.class, Pipeline.class);
try {
actualPipelines = mapper.readValue(pipelines.toString(), arrayType);
} catch (JsonProcessingException e) {
e.printStackTrace();
}
var jsonObj = jsonElement.getAsJsonObject();
var camFOV = jsonObj.get("FOV").getAsDouble();
var camName = jsonObj.get("name").getAsString();
var camNickname = jsonObj.get("nickname").getAsString();
var videoModeIndex = jsonObj.get("resolution").getAsInt();
var driverExposure = jsonObj.get("driverExposure").getAsInt();
var driverBrightness = jsonObj.get("driverBrightness").getAsInt();
var divisor = StreamDivisor.values()[jsonObj.get("streamDivisor").getAsInt()];
var newCamera = actualPipelines != null ? new Camera(camName, camFOV, actualPipelines, videoModeIndex, divisor) : new Camera(camName, camFOV, videoModeIndex, divisor);
newCamera.setNickname(camNickname != null ? camNickname : "");
return newCamera;
var pipelines = jsonObj.get("pipelines");
List<Pipeline> actualPipelines = new ArrayList<>();
ObjectMapper mapper = new ObjectMapper();
TypeFactory typeFactory = mapper.getTypeFactory();
JavaType arrayType = typeFactory.constructCollectionType(List.class, Pipeline.class);
try {
actualPipelines = mapper.readValue(pipelines.toString(), arrayType);
} catch (JsonProcessingException e) {
e.printStackTrace();
}
var newCamera = actualPipelines != null ? new Camera(camName, camFOV, actualPipelines, videoModeIndex, divisor, driverExposure, driverBrightness) : new Camera(camName, camFOV, videoModeIndex, divisor, driverExposure, driverBrightness);
newCamera.setNickname(camNickname != null ? camNickname : "");
return newCamera;
}
catch (NullPointerException e)
{
System.err.println("Error while reading json, value doesnt exist!");
System.err.println("Try to delete the camera settings in settings/cameras/YOURCAMERA.json");
e.printStackTrace();
return null;
}
}
}