Welcome to the CSC Q&A, on our server named in honor of Ada Lovelace. Write great code! Get help and give help!
It is our choices... that show what we truly are, far more than our abilities.


+36 votes

Right now, the ImageView will resize the video based on either the width or height of the video (leaving extra blank space on either the sides or the top and bottom), and this messes up tracking by having a bunch of extra white space being accounted for in the x and y coordinates. How could we use the properties of the video (aspect ratio, width, height, etc.) to adjust the size of the ImageView or the Canvas?

asked in CSC285_Fall2018 by (1 point)

1 Answer

+15 votes
Best answer

Here's what we figured out by using the the image when we grab the frame (our method called grabFrame) which sets the frame as an image, so we can put this code below in a method that take an image as the parameter so then whenever the size of the image changes, to will the ImageView object and the Canvas object

double aspectRatio = image.getWidth() / image.getHeight();
	double realWidth = Math.min(videoView.getFitWidth(), videoView.getFitHeight() * aspectRatio);
	double realHeight = Math.min(videoView.getFitHeight(), videoView.getFitWidth() / aspectRatio);
answered by (1 point)
selected by