How to resize stream webcam in Imageview Javafx
Now i steam web cam and i want to extend size but i try and i can't. i don't know how to use command resize. Does anyone know a solution> Thank you
This my stream web cam code
@FXML
protected void startCamera(ActionEvent event)
{
if (!this.cameraActive)
{
// start the video capture
this.capture.open(cameraId);
// is the video stream available?
if (this.capture.isOpened())
{
this.cameraActive = true;
// grab a frame every 33 ms (30 frames/sec)
Runnable frameGrabber = new Runnable() {
@Override
public void run()
{
// effectively grab and process a single frame
Mat frame = grabFrame();
// convert and show the frame
Image imageToShow = Utils.mat2Image(frame);
updateImageView(liveCam, imageToShow);
}
};
this.timer = Executors.newSingleThreadScheduledExecutor();
this.timer.scheduleAtFixedRate(frameGrabber, 0, 66, TimeUnit.MILLISECONDS);
// update the button content
this.button.setText("Stop Camera");
}
else
{
// log the error
System.err.println("Impossible to open the camera connection...");
}
}
else
{
// the camera is not active at this point
this.cameraActive = false;
// update again the button content
this.button.setText("Start Camera");
// stop the timer
this.stopAcquisition();
}
}
private Mat grabFrame()
{
// init everything
Mat frame = new Mat();
// check if the capture is open
if (this.capture.isOpened())
{
try
{
// read the current frame
this.capture.read(frame);
// if the frame is not empty, process it
if (!frame.empty())
{
//Imgproc.cvtColor(frame, frame, Imgproc.COLOR_BGR2GRAY);
}
}
catch (Exception e)
{
// log the error
System.err.println("Exception during the image elaboration: " + e);
}
}
return frame;
}