Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit500fd45

Browse files
authored
Merge pull request#24592 from savuor:recorder_android
Android sample for VideoWriter#24592This PR:* adds an Android sample for video recording with MediaNDK and built-in MJPEG.* adds a flag `--no_media_ndk` for `build_sdk.py` script to disable MediaNDK linkage.### Pull Request Readiness ChecklistSee details athttps://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request- [x] I agree to contribute to the project under Apache 2 License.- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV- [x] The PR is proposed to the proper branch- [x] There is a reference to the original bug report and related work- [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name.- [x] The feature is well documented and sample code can be built with the project CMake
1 parent2e37a69 commit500fd45

File tree

9 files changed

+475
-2
lines changed

9 files changed

+475
-2
lines changed

‎platforms/android/build_sdk.py‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ def clean_library_build_dir(self):
215215
fordin ["CMakeCache.txt","CMakeFiles/","bin/","libs/","lib/","package/","install/samples/"]:
216216
rm_one(d)
217217

218-
defbuild_library(self,abi,do_install):
218+
defbuild_library(self,abi,do_install,no_media_ndk):
219219
cmd= [self.cmake_path,"-GNinja"]
220220
cmake_vars=dict(
221221
CMAKE_TOOLCHAIN_FILE=self.get_toolchain_file(),
@@ -260,6 +260,9 @@ def build_library(self, abi, do_install):
260260
ifdo_install:
261261
cmd.extend(["-DBUILD_TESTS=ON","-DINSTALL_TESTS=ON"])
262262

263+
ifno_media_ndk:
264+
cmake_vars['WITH_ANDROID_MEDIANDK']="OFF"
265+
263266
cmake_vars.update(abi.cmake_vars)
264267
cmd+= ["-D%s='%s'"% (k,v)for (k,v)incmake_vars.items()ifvisnotNone]
265268
cmd.append(self.opencvdir)
@@ -370,6 +373,7 @@ def get_ndk_dir():
370373
parser.add_argument('--opencl',action="store_true",help="Enable OpenCL support")
371374
parser.add_argument('--no_kotlin',action="store_true",help="Disable Kotlin extensions")
372375
parser.add_argument('--shared',action="store_true",help="Build shared libraries")
376+
parser.add_argument('--no_media_ndk',action="store_true",help="Do not link Media NDK (required for video I/O support)")
373377
args=parser.parse_args()
374378

375379
log.basicConfig(format='%(message)s',level=log.DEBUG)
@@ -447,7 +451,7 @@ def get_ndk_dir():
447451

448452
os.chdir(builder.libdest)
449453
builder.clean_library_build_dir()
450-
builder.build_library(abi,do_install)
454+
builder.build_library(abi,do_install,args.no_media_ndk)
451455

452456
builder.gather_results()
453457

‎samples/android/CMakeLists.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ add_subdirectory(image-manipulations)
1313
add_subdirectory(camera-calibration)
1414
add_subdirectory(color-blob-detection)
1515
add_subdirectory(mobilenet-objdetect)
16+
add_subdirectory(video-recorder)
1617
add_subdirectory(tutorial-1-camerapreview)
1718
add_subdirectory(tutorial-2-mixedprocessing)
1819
add_subdirectory(tutorial-3-cameracontrol)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
set(sample example-video-recorder)
2+
3+
if(BUILD_FAT_JAVA_LIB)
4+
set(native_deps opencv_java)
5+
else()
6+
set(native_deps videoio)
7+
endif()
8+
9+
add_android_project(${sample}"${CMAKE_CURRENT_SOURCE_DIR}" LIBRARY_DEPS"${OPENCV_ANDROID_LIB_DIR}" SDK_TARGET 11"${ANDROID_SDK_TARGET}" NATIVE_DEPS${native_deps})
10+
if(TARGET${sample})
11+
add_dependencies(opencv_android_examples${sample})
12+
endif()
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
apply plugin: 'com.android.application'
2+
3+
android {
4+
namespace 'org.opencv.samples.recorder'
5+
compileSdkVersion @ANDROID_COMPILE_SDK_VERSION@
6+
defaultConfig {
7+
applicationId "org.opencv.samples.recorder"
8+
minSdkVersion @ANDROID_MIN_SDK_VERSION@
9+
targetSdkVersion @ANDROID_TARGET_SDK_VERSION@
10+
versionCode 301
11+
versionName "3.01"
12+
}
13+
buildTypes {
14+
release {
15+
minifyEnabled false
16+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17+
}
18+
}
19+
sourceSets {
20+
main {
21+
java.srcDirs = @ANDROID_SAMPLE_JAVA_PATH@
22+
aidl.srcDirs = @ANDROID_SAMPLE_JAVA_PATH@
23+
res.srcDirs = @ANDROID_SAMPLE_RES_PATH@
24+
manifest.srcFile '@ANDROID_SAMPLE_MANIFEST_PATH@'
25+
}
26+
}
27+
}
28+
29+
dependencies {
30+
//implementation fileTree(dir: 'libs', include: ['*.jar'])
31+
if (gradle.opencv_source == "sdk_path") {
32+
implementation project(':opencv')
33+
} else if (gradle.opencv_source == "maven_local" || gradle.opencv_source == "maven_cenral") {
34+
implementation 'org.opencv:opencv:@OPENCV_VERSION_PLAIN@'
35+
}
36+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifestxmlns:android="http://schemas.android.com/apk/res/android"
3+
package="org.opencv.samples.recorder"
4+
>
5+
6+
<application
7+
android:label="@string/app_name"
8+
android:icon="@drawable/icon"
9+
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
10+
11+
<activity
12+
android:exported="true"
13+
android:name="RecorderActivity"
14+
android:label="@string/app_name"
15+
android:screenOrientation="landscape"
16+
android:configChanges="keyboardHidden|orientation">
17+
<intent-filter>
18+
<actionandroid:name="android.intent.action.MAIN" />
19+
<categoryandroid:name="android.intent.category.LAUNCHER" />
20+
</intent-filter>
21+
</activity>
22+
</application>
23+
24+
<supports-screensandroid:resizeable="true"
25+
android:smallScreens="true"
26+
android:normalScreens="true"
27+
android:largeScreens="true"
28+
android:anyDensity="true" />
29+
30+
<uses-permissionandroid:name="android.permission.CAMERA"/>
31+
<uses-permissionandroid:name="android.permission.WRITE_EXTERNAL_STORAGE" />
32+
33+
<uses-featureandroid:name="android.hardware.camera"android:required="false"/>
34+
<uses-featureandroid:name="android.hardware.camera.autofocus"android:required="false"/>
35+
<uses-featureandroid:name="android.hardware.camera.front"android:required="false"/>
36+
<uses-featureandroid:name="android.hardware.camera.front.autofocus"android:required="false"/>
37+
38+
</manifest>
1.95 KB
Loading
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<FrameLayoutxmlns:android="http://schemas.android.com/apk/res/android"
2+
xmlns:tools="http://schemas.android.com/tools"
3+
xmlns:opencv="http://schemas.android.com/apk/res-auto"
4+
android:layout_width="match_parent"
5+
android:layout_height="match_parent" >
6+
7+
<Button
8+
android:id="@+id/btn1"
9+
android:layout_width="wrap_content"
10+
android:layout_height="50dp"
11+
android:layout_margin="10dp"
12+
android:text="Start Camera" />
13+
14+
<TextView
15+
android:id="@+id/textview1"
16+
android:layout_width="wrap_content"
17+
android:layout_height="wrap_content"
18+
android:layout_gravity="right"
19+
android:layout_margin="10dp"
20+
android:text="Status: Initialized"
21+
android:textColor="#FF0000" />
22+
23+
<org.opencv.android.JavaCameraView
24+
android:layout_width="fill_parent"
25+
android:layout_height="fill_parent"
26+
android:visibility="gone"
27+
android:id="@+id/recorder_activity_java_surface_view"
28+
opencv:show_fps="true"
29+
opencv:camera_id="any" />
30+
31+
<ImageView
32+
android:id="@+id/image_view"
33+
android:layout_width="fill_parent"
34+
android:layout_height="fill_parent"
35+
android:visibility="gone"
36+
/>
37+
38+
</FrameLayout>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
<stringname="app_name">OpenCV Video Recorder</string>
4+
</resources>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp