diff --git a/FXHelloCV/src/it/polito/elite/teaching/cv/FXHelloCVController.java b/FXHelloCV/src/it/polito/elite/teaching/cv/FXHelloCVController.java index c28953a..5c3f983 100644 --- a/FXHelloCV/src/it/polito/elite/teaching/cv/FXHelloCVController.java +++ b/FXHelloCV/src/it/polito/elite/teaching/cv/FXHelloCVController.java @@ -55,7 +55,7 @@ protected void startCamera(ActionEvent event) if (this.mainApp != null) { // get the ImageView object for showing the video stream - final ImageView frameView = (ImageView) mainApp.getRootElement().lookup("#currentFrame"); + ImageView frameView = (ImageView) mainApp.getRootElement().lookup("#currentFrame"); // bind an image property with the container for frames final ObjectProperty imageProp = new SimpleObjectProperty<>(); frameView.imageProperty().bind(imageProp); @@ -77,7 +77,15 @@ public void run() { // update the image property => update the frame // shown in the UI - imageProp.set(grabFrame()); + final Image imageToShow = grabFrame(); + Platform.runLater(new Runnable() + { + @Override + public void run() + { + imageProp.setValue(imageToShow); + } + }); } }; this.timer = new Timer();