canon-sdk-java
canon-sdk-java copied to clipboard
[BUG] CameraAddedEvent do not properly update the cameras
When i receive the CameraAdded event. I expected the CameraManager.getAllCamera() to have it but the list had no elements. So i have no way to actually get the added camera so i can call openSession on it.
In the IDE, if i call refreshCamera before calling getAllCamera it work.. but refreshCamera isn't a public method. Technically, it should have been called if i did setRefreshInterval to 0 but it doesn't look like to be called in reality.
Here what i do,,
private CameraAddedListener cameraAddedListener = event -> {
cameraConnected = true;
Platform.runLater(() -> initializeCameraConnexion());
log.info("Camera added detected: {}", event);
};
then..
public void initializeCameraConnexion() {
log.info("initializeCameraConnexion()");
if (CameraManager.getAllCameras().size() > 0) {
this.camera = CameraManager.getAllCameras().get(0);
}
If i look at the getAllCameras() here the results... https://i.imgur.com/sReHBLC.png
Now if i refresh manually just before here the results... https://i.imgur.com/yMSSwDZ.png
Problem i have is that calling refreshCameras was possible because i am in the IDE but this method is not public. There is no way to instant refresh manually the cameras list.
It will depend on how you initialized the framework, you can see example in DemoFullWithCameraManager in tests.
Also depends on which order you registered the CameraAddedEvent; If you use the CameraManager then better to initialize it first then the logic of your code.