Please i need your help. Very much appreciated I don't know what to do with this error. I am new to [OpenCV] and I hope you will help me solve this.
[3]: Source Code:
Caused by: java.lang.NullPointerException at opencv.OpenCV.start(OpenCV.java:49)
exitButton.setOnAction((ActionEvent event)->{
System.exit(0);
});
[Edited]: I try this, the errors gone but no buttons display and no camera frame display:
exitButton = new Button();
exitButton.setOnAction((ActionEvent event)->{
System.exit(0);
});
videoButton = new Button();
videoButton.setOnAction((ActionEvent event)->{
Any suggestions with this code?
Source Code:
if(!isStart){
frame.setFitWidth(640);
frame.setFitWidth(480);
frame.setPreserveRatio(true);
capture.open(0);
capture.set(Videoio.CAP_PROP_FRAME_WIDTH, 640);
capture.set(Videoio.CAP_PROP_FRAME_HEIGHT, 480);
if (capture.isOpened()){
isStart = true;
Runnable frameGrabber = new Runnable() {
@Override
public void run() {
Image imageToShow = grabFrame();
frame.setImage(imageToShow);
}
};
timer = Executors.newSingleThreadScheduledExecutor();
timer.scheduleAtFixedRate(frameGrabber, 0, 33, `TimeUnit.MILLISECONDS);`
videoButton.setText("Stop");
}else {
System.err.println("Open Camera Error!");
}
}
else {
isStart = false;
videoButton.setText("Start");
try{
timer.shutdown();
timer.awaitTermination(33, TimeUnit.MILLISECONDS);
}catch(InterruptedException e){
System.err.println(e);
}
capture.release();
frame.setImage(null);
}
});