Skip to content

Commit

Permalink
Upgrade to OpenCV 4.6.0 and minor enhancements
Browse files Browse the repository at this point in the history
  • Loading branch information
Jotschi committed Jan 18, 2023
1 parent ec8fc3d commit 3c3f857
Show file tree
Hide file tree
Showing 12 changed files with 272 additions and 59 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## v1.1.0


* Upgrade to OpenCV 4.6.0-0

## v1.0.0

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ try (Video video = Videos.open(BIG_BUCK_BUNNY2_PATH)) {
video.fps();

// Total frames of the video
video.length()
video.length();

// Seek to specific frame
video.seekToFrame(1020);
Expand All @@ -48,7 +48,7 @@ try (Video video = Videos.open(BIG_BUCK_BUNNY2_PATH)) {
BufferedImage image = video.frameToImage();

// Read the frame and resize it to a width of 256 pixel.
BufferdImage image2 = video.boxedFrameToImage(256);
BufferedImage image2 = video.boxedFrameToImage(256);

// Display the frame in a window
ImageUtils.show(image);
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<dependency>
<groupId>org.openpnp</groupId>
<artifactId>opencv</artifactId>
<version>4.5.1-2</version>
<version>4.6.0-0-contrib</version>
</dependency>
<dependency>
<groupId>org.imgscalr</groupId>
Expand Down
18 changes: 17 additions & 1 deletion src/main/java/io/metaloom/video4j/Video.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ static Video open(String path) {
/**
* Open the video.
*
* @return Fluent APOI
* @return Fluent API
*/
Video open();

Expand Down Expand Up @@ -141,6 +141,22 @@ static Video open(String path) {
*/
String path();

/**
* Return metadata for the video.
*
* @param <T>
* @return
*/
<T> T getMeta();

/**
* Set metadata for the video.
*
* @param <T>
* @param meta
*/
<T> void setMeta(T meta);

/**
* Return a stream of {@link Mat} frames for this video.
*
Expand Down
16 changes: 15 additions & 1 deletion src/main/java/io/metaloom/video4j/impl/VideoImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,17 @@ public class VideoImpl implements Video {

private final String path;
private final ExtendedVideoCapture capture;
private Object meta;

public VideoImpl(String path, ExtendedVideoCapture capture) {
this.path = path;
this.capture = capture;
}

public Video open() {
capture.open(path);
if (!capture.open(path)) {
throw new RuntimeException("Video " + path + " could not be opened.");
}
return this;
}

Expand Down Expand Up @@ -76,6 +79,17 @@ public int width() {
return capture.width();
}

@Override
@SuppressWarnings("unchecked")
public <T> T getMeta() {
return (T) meta;
}

@Override
public <T> void setMeta(T meta) {
this.meta = meta;
}

@Override
public void seekToFrame(long frame) {
assertOpen();
Expand Down
Loading

0 comments on commit 3c3f857

Please sign in to comment.