Skip to content

Commit

Permalink
Add helper methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Jotschi committed Jan 18, 2022
1 parent 2a78940 commit a1c966d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/main/java/io/metaloom/video4j/opencv/CVUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,15 @@ public static Mat houghLinesP(Mat frame, double rho, double theta, int threshold
return cannyColor;
}

public static BufferedImage blowUp(BufferedImage image, int x, int y) {
/**
* Resize the image to the matching dimensions.
*
* @param image
* @param x
* @param y
* @return
*/
public static BufferedImage scale(BufferedImage image, int x, int y) {
BufferedImage resizedImage = Scalr.apply(image, new ResampleOp(x, y, ResampleOp.FILTER_POINT));
resizedImage.flush();
return resizedImage;
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/io/metaloom/video4j/utils/ImageUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,18 @@ public static void show(Mat mat, int width) {
show(image);
}

/**
* Show a scaled version of the provided image.
*
* @param image
^ * @param width
* New width of the image to be shown
*/
public static void show(BufferedImage image, int width) {
image = Scalr.resize(image, Method.SPEED, width);
show(image);
}

public static void show(BufferedImage image) {
JFrame frame = new JFrame();
frame.getContentPane().setLayout(new FlowLayout());
Expand Down

0 comments on commit a1c966d

Please sign in to comment.