Library and sample to access to UVC web camera on non-rooted Android device.
Works with latest Android versions! (API level 33 - Android 13 at the time of writing).
Please see and test sample projects usbCameraTest*
.
Copyright (c) 2014-2017 saki [email protected]
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
All files in the folder are under this Apache License, Version 2.0. Files in the jni/libjpeg, jni/libusb and jin/libuvc folders may have a different license, see the respective files.
The Gradle build system will build the entire project, including the NDK parts. If you want to build with Gradle build system,
- make directory on your favorite place (this directory is parent directory of
UVCCamera
project). - change directory into the directory.
- clone this repository with
git clone https://github.com/saki4510t/UVCCamera.git
- change directory into
UVCCamera
directory withcd UVCCamera
- build library with all sample projects using
gradle build
It will takes several minutes to build. Now you can see apks in each {sample project}/build/outputs/apks
directory.
Or if you want to install and try all sample projects on your device, run gradle installDebug
.\
Note: Just make sure that local.properties
contains the paths for sdk.dir
and ndk.dir
. Or you can set them as enviroment variables of you shell. On some system, you may need add JAVA_HOME
envairoment valiable that points to JDK directory.\
If you want to use Android Studio(unfortunately NDK supporting on Android Studio is very poor though),
- make directory on your favorite place (this directory is parent directory of
UVCCamera
project). - change directory into the directory.
- clone this repository with
git clone https://github.com/saki4510t/UVCCamera.git
- start Android Studio and open the cloned repository using
Open an existing Android Studio project
- Android Studio raise some errors but just ignore now. Android Studio generate
local.properties
file. Please openlocal.properties
and addndk.dir
key to the end of the file. The contents of the file looks like this.
sdk.dir={path to Android SDK on your storage}
ndk.dir={path to Android SDK on your storage}
Please replace actual path to SDK and NDK on your storage.
Of course you can make local.properties
by manually instead of using automatically generated ones by Android Studio.
6. Synchronize project
7. execute Make project
from Build
menu.
If you want to use build-in VCS on Android Studio, use Check out project from Version Control
from https://github.com/saki4510t/UVCCamera.git
. After cloning, Android Studio ask you open the project but don't open now. Instead open the project using Open an existing Android Studio project
. Other procedures are same as above.
If you still need to use Eclipse or if you don't want to use Gradle with some reason, you can build suing ndk-build
command.
- make directory on your favorite place.
- change directory into the directory.
- clone this repository with
git clone https://github.com/saki4510t/UVCCamera.git
- change directory into
{UVCCamera}/libuvccamera/build/src/main/jni
directory. - run
ndk-build
- resulted shared libraries are available under
{UVCCamera}/libuvccamera/build/src/main/libs
directory and copy them into your project with directories by manually. - copy files under
{UVCCamera}/libuvccamera/build/src/main/java
into your project source directory by manually.
Please see sample project and/or our web site(but sorry web site is Japanese only). These sample projects are IntelliJ projects, as is the library. This library works on at least Android 3.1 or later(API >= 12), but Android 4.0(API >= 14) or later is better. USB host function must be required. If you want to try on Android 3.1, you will need some modification(need to remove setPreviewTexture method in UVCCamera.java etc.), but we have not confirm whether the sample project run on Android 3.1 yet. Some sample projects need API>=18 though.
Add some modification to the library and new sample project named "USBCameraTest2". This new sample project demonstrate how to capture movie using frame data from UVC camera with MediaCodec and MediaMuxer. New sample requires at least Android 4.3(API>=18). This limitation does not come from the library itself but from the limitation of MediaMuxer and MediaCodec#createInputSurface.
Add new sample project named USBCameraTest3
This new sample project demonstrate how to capture audio and movie simultaneously
using frame data from UVC camera and internal mic with MediaCodec and MediaMuxer.
This new sample includes still image capturing as png file.(you can easily change to
save as jpeg) This sample also requires at least Android 4.3(API>=18).
This limitation does not come from the library itself but from the limitation of
MediaMuxer and MediaCodec#createInputSurface.
Add new sample project named USBCameraTest4
This new sample project mainly demonstrate how to use offscreen rendering
and record movie without any display.
The communication with camera execute as Service and continue working
even if you stop app. If you stop camera communication, click "stop service" button.
Add bulk transfer mode and update sample projects.
Add wiki page, HowTo
Add method to adjust preview resolution and frame data mode.
Add IFrameCallback interface to get frame data as ByteArray
and new sample project USBCameraTest5
to demonstrate how to use the callback method.
Add libUVCCamera
as a library project(source code is almost same as previous release except Android.mk).
All files and directories under library
directory is deprecated.
libraryProject branch merged to master.
Fixed the issue that DeviceFilter class could not work well when providing venderID, productID etc.
Add new sample project named USBCameraTest6
This new sample project mainly demonstrate how to show video images on two TextureView simultaneously, side by side.
Fixed the issue of pixel format is wrong when NV21 mode on calling IFrameCallback#onFrame(U and V plane was swapped) and added YUV420SP mode.
Improve the issue of USBCameraTest4
that fails to connect/disconnect.
Add new methods to get/set camera features like brightness, contrast etc.
Add new method to get supported resolution from camera as json format.\
Add new sample project USBCameraTest7
to demonstrate how to use two camera at the same time.\
Fixed the issue that building native libraries fail on Windows.
Merge pull request(add status and button callback). Thanks Alexey Pelykh.
Add feature so that user can request fps range from Java code when negotiating with camera. Actual resulted fps depends on each UVC camera. Currently there is no way to get resulted fps(will add on future).
update minoru001 branch, experimentaly support streo camera.
replace libjpeg-turbo 1.4.0 with 1.5.0
apply bandwidth factor setting of usbcameratest7 on master branch
Now this repository supports Android N(7.x) and dynamic permission model of Android N and later.
Add new sample app usbCameraTest8
to show how to set/get uvc control like brightness
Add new sample app on OpenCVwithUVC repository.
This shows the way to pass video images from UVC into cv::Mat
(after optional applying video effect by OpenGL|ES) and execute image processing by OpenCV
.
- 添加根据摄像头自身角度选择图像处理
- 添加水平镜像处理
- 添加垂直镜像处理
- 添加是否丢弃不完整帧
- 添加可设置帧缓存大小
- 修复颜色转换出错问题
- 添加回调帧支持BGR24
- gitee地址 https://gitee.com/dengly/UVCCamera
- github地址 https://github.com/dengly/UVCCamera