Skip to content

Commit

Permalink
* Add FrameGrabber.videoSideData/audioSideData properties and `FFm…
Browse files Browse the repository at this point in the history
…pegFrameGrabber.getDisplayRotation()` for convenience (issue bytedeco#1361)

 * Upgrade dependencies for Tesseract 5.2.0
  • Loading branch information
saudet committed Jul 23, 2022
1 parent d05adb8 commit d1b1f4e
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 4 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@

* Add `FrameGrabber.videoSideData/audioSideData` properties and `FFmpegFrameGrabber.getDisplayRotation()` for convenience ([issue #1361](https://github.com/bytedeco/javacv/issues/1361))
* Add to `FFmpegFrameGrabber` and `FFmpegFrameRecorder` constructors taking a `URL` for convenience and clarity
* Fix incorrect call to `opencv_calib3d.stereoRectify()` in `ProjectiveDevice` ([issue #1802](https://github.com/bytedeco/javacv/issues/1802))
* Retry after 10 ms when `av_read_frame()` returns `EAGAIN` in `FFmpegFrameGrabber.grabFrame()` ([issue #1784](https://github.com/bytedeco/javacv/issues/1784))
* Append `frame_rate=%d/%d` input parameter in `FFmpegFrameFilter` as required by `xfade` ([issue #1776](https://github.com/bytedeco/javacv/issues/1776))
* Update `FFmpegStreamingTimeout` sample to use `timeout` instead of `stimeout` for RTSP ([pull #1758](https://github.com/bytedeco/javacv/pull/1758))
* Restore static calls to `FFmpegFrameGrabber.tryLoad()` and `FFmpegFrameRecorder.tryLoad()` ([issue #1756](https://github.com/bytedeco/javacv/issues/1756))
* Enable by default on `RealSense2FrameGrabber.start()` all color, depth, and IR streams as `videoStream` ([pull #1750](https://github.com/bytedeco/javacv/pull/1750))
* Upgrade dependencies for OpenBLAS 0.3.20, OpenCV 4.6.0, FFmpeg 5.0.1, Leptonica 1.82.0 ([pull #1791](https://github.com/bytedeco/javacv/pull/1791)), Tesseract 5.1.0
* Upgrade dependencies for OpenBLAS 0.3.20, OpenCV 4.6.0, FFmpeg 5.0.1, Leptonica 1.82.0 ([pull #1791](https://github.com/bytedeco/javacv/pull/1791)), Tesseract 5.2.0

### February 11, 2022 version 1.5.7
* Fix accuracy and latency issues with `FFmpegFrameGrabber.setVideoFrameNumber()` ([pull #1734](https://github.com/bytedeco/javacv/pull/1734))
Expand Down
2 changes: 1 addition & 1 deletion platform/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
<dependency>
<groupId>org.bytedeco</groupId>
<artifactId>tesseract-platform</artifactId>
<version>5.1.0-${javacpp.version}</version>
<version>5.2.0-${javacpp.version}</version>
</dependency>

<dependency>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@
<dependency>
<groupId>org.bytedeco</groupId>
<artifactId>tesseract</artifactId>
<version>5.1.0-${javacpp.version}</version>
<version>5.2.0-${javacpp.version}</version>
</dependency>

<dependency>
Expand Down
42 changes: 42 additions & 0 deletions src/main/java/org/bytedeco/javacv/FFmpegFrameGrabber.java
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,48 @@ public double getVideoFrameRate() {
return entry == null || entry.value() == null ? null : entry.value().getString(charset);
}

@Override public Map<String, Buffer> getVideoSideData() {
if (video_st == null) {
return super.getVideoSideData();
}
videoSideData = new HashMap<String, Buffer>();
for (int i = 0; i < video_st.nb_side_data(); i++) {
AVPacketSideData sd = video_st.side_data().position(i);
String key = av_packet_side_data_name(sd.type()).getString();
Buffer value = sd.data().capacity(sd.size()).asBuffer();
videoSideData.put(key, value);
}
return videoSideData;
}

@Override public Buffer getVideoSideData(String key) {
return getVideoSideData().get(key);
}

/** Returns the rotation in degrees from the side data of the video stream, or 0 if unknown. */
public double getDisplayRotation() {
ByteBuffer b = (ByteBuffer)getVideoSideData("Display Matrix");
return b != null ? av_display_rotation_get(new IntPointer(new BytePointer(b))) : 0;
}

@Override public Map<String, Buffer> getAudioSideData() {
if (audio_st == null) {
return super.getAudioSideData();
}
audioSideData = new HashMap<String, Buffer>();
for (int i = 0; i < audio_st.nb_side_data(); i++) {
AVPacketSideData sd = audio_st.side_data().position(i);
String key = av_packet_side_data_name(sd.type()).getString();
Buffer value = sd.data().capacity(sd.size()).asBuffer();
audioSideData.put(key, value);
}
return audioSideData;
}

@Override public Buffer getAudioSideData(String key) {
return getAudioSideData().get(key);
}

/** default override of super.setFrameNumber implies setting
* of a frame close to a video frame having that number */
@Override public void setFrameNumber(int frameNumber) throws Exception {
Expand Down
33 changes: 32 additions & 1 deletion src/main/java/org/bytedeco/javacv/FrameGrabber.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2009-2019 Samuel Audet
* Copyright (C) 2009-2022 Samuel Audet
*
* Licensed either under the Apache License, Version 2.0, or (at your option)
* under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -27,6 +27,7 @@
import java.io.File;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.nio.Buffer;
import java.nio.charset.Charset;
import java.util.Arrays;
import java.util.HashMap;
Expand Down Expand Up @@ -200,6 +201,8 @@ public static enum SampleMode {
protected Map<String, String> metadata = new HashMap<String, String>();
protected Map<String, String> videoMetadata = new HashMap<String, String>();
protected Map<String, String> audioMetadata = new HashMap<String, String>();
protected Map<String, Buffer> videoSideData = new HashMap<String, Buffer>();
protected Map<String, Buffer> audioSideData = new HashMap<String, Buffer>();
protected int frameNumber = 0;
protected long timestamp = 0;
protected int maxDelay = -1;
Expand Down Expand Up @@ -485,6 +488,34 @@ public void setAudioMetadata(String key, String value) {
audioMetadata.put(key, value);
}

public Map<String, Buffer> getVideoSideData() {
return videoSideData;
}
public void setVideoSideData(Map<String, Buffer> videoSideData) {
this.videoSideData = videoSideData;
}

public Buffer getVideoSideData(String key) {
return videoSideData.get(key);
}
public void setVideoSideData(String key, Buffer value) {
videoSideData.put(key, value);
}

public Map<String, Buffer> getAudioSideData() {
return audioSideData;
}
public void setAudioSideData(Map<String, Buffer> audioSideData) {
this.audioSideData = audioSideData;
}

public Buffer getAudioSideData(String key) {
return audioSideData.get(key);
}
public void setAudioSideData(String key, Buffer value) {
audioSideData.put(key, value);
}

public int getFrameNumber() {
return frameNumber;
}
Expand Down

0 comments on commit d1b1f4e

Please sign in to comment.