Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork56.4k
Java VideoCapture buffered stream constructor#27284
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes from1 commit
Commits
Show all changes
17 commits Select commitHold shift + click to select a range
1f1cd89 initial commit
dkurt17b2886 dummy java wrapper
dkurtcb2e2a9 Keep jclass in wrapper
dkurt66cc8c5 working test
dkurt8a44f4f Revert unused files
dkurta52ebc9 Remove size argument from read
dkurtb6faec7 Check backend available before test
dkurt4822844 Try print exception
dkurtc499ed2 Revert "Try print exception"
dkurtfaddefc Use NewLocalRef for Java stream object
dkurteed126c Wrap native seek and read
dkurta603bce Try create global ref
dkurt79afad9 Fix long long in Python
dkurtb9b0310 Default IStreamReader constructor
dkurtfeee794 Use JavaVM
dkurtf9cb6d4 Add AttachCurrentThread in case of JNI_EDETACHED error
dkurtc3be053 Add constructor note
dkurtFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
Use JavaVM
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
commitfeee7949253a02a38fa76b62d75ae7890acbc7c2
There are no files selected for viewing
8 changes: 7 additions & 1 deletionmodules/videoio/include/opencv2/videoio.hpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
12 changes: 11 additions & 1 deletionmodules/videoio/misc/java/src/cpp/videoio_converters.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,22 +1,29 @@ | ||
| #include "videoio_converters.hpp" | ||
| JavaStreamReader::JavaStreamReader(JNIEnv*env, jobject _obj) | ||
| { | ||
| obj = env->NewGlobalRef(_obj); | ||
| jclass cls = env->GetObjectClass(obj); | ||
| m_read = env->GetMethodID(cls, "read", "([BJ)J"); | ||
| m_seek = env->GetMethodID(cls, "seek", "(JI)J"); | ||
| env->GetJavaVM(&vm); | ||
| } | ||
| JavaStreamReader::~JavaStreamReader() | ||
| { | ||
| JNIEnv* env; | ||
| if (vm->GetEnv((void**)&env, JNI_VERSION_1_6) != JNI_OK) | ||
| return; | ||
| env->DeleteGlobalRef(obj); | ||
| } | ||
| long long JavaStreamReader::read(char* buffer, long long size) | ||
| { | ||
| if (!m_read) | ||
| return 0; | ||
| JNIEnv* env; | ||
| if (vm->GetEnv((void**)&env, JNI_VERSION_1_6) != JNI_OK) | ||
| return 0; | ||
dkurt marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| jbyteArray jBuffer = env->NewByteArray(static_cast<jsize>(size)); | ||
| if (!jBuffer) | ||
| return 0; | ||
| @@ -28,6 +35,9 @@ long long JavaStreamReader::read(char* buffer, long long size) | ||
| long long JavaStreamReader::seek(long long offset, int way) | ||
| { | ||
| JNIEnv* env; | ||
| if (vm->GetEnv((void**)&env, JNI_VERSION_1_6) != JNI_OK) | ||
| return 0; | ||
| if (!m_seek) | ||
| return 0; | ||
| return env->CallLongMethod(obj, m_seek, offset, way); | ||
2 changes: 1 addition & 1 deletionmodules/videoio/misc/java/src/cpp/videoio_converters.hpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletionsmodules/videoio/misc/java/test/VideoCaptureTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.