zyowo / UVC4UnityAndroid

UVC4UnityAndroid

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

UVC4UnityAndroid

Plugin project and samples to access UVC devices on Unity Android.

Copyright (c) 2014-2019 saki t_saki@serenegiant.com

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

 http://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 under UVC4UnityAndroid/Assets/UVC4UnityAndroidPlugin/Samples/ may have different license. Please read README.md in those folders well.

Features:

  • Supports UVC 1.0/1.1 and 1.5 devices (Most of UVC devices are UVC1.1).
  • Supports armeabi-v7a, arm64-v8a, x86 and x86_64 architectures.
  • Supports H.264, MJPEG and YUV and automatically decode video images into Texture of Unity. Please see sample scenes in Samples folder.
    You can get H.264 stream from Ricoh THETA S(1920x1080@H.264,30fps, dual fisheye video images) and THETA V(3840x1920@H.264,30fps, equirectangular video images), Logitech C920, C922, C930e etc.
  • Supports multiple UVC devices at the same time(Although frame rate, number of UVC devices and video size will be limited by bandwidth and power supply of USB.)
  • Supports both isochronous and bulk transfer.
  • Supports USB2 and USB3(experimental).
  • Support changing video size.

Limitations:

  • Apk with target API level 28 and more never work well on Android 10 devices because of issues on Android 10 itself. Please see details about this on Issue Tracker of Google and My Blog.
  • This project is still in progress and some features are not available now. Ex. Controlling UVC devices is not implemented yet. Ex. controlling contrast, brightness, shutter condition etc. do not work yet.
  • You can get video images only from UVC devices, some devices like EasyCap are not UVC device and can't get from them. Internal cameras on Android devices also are not supported.
  • Backend libraries support UBS3, but USB3 on Android devices are still unstable and it may not work well. In that case please connect your UVC devices over USB2.
  • This plugin can work on only real Android devices, can't work on editor of Unity and on Unity Remote
  • User may need to touch app screen after giving USB permission on some Android devices by limitation os Android OS itself.

Dependancies:

  • This plugin uses System.Text.Json(and related packages) from Microsoft to parse JSON. You can install the package using NuGet(You can use NuGetForUnity)
    If you need to use other package like Json.NET to parse json, you can use it with some modification.

How to use:

  1. Create new project / open existing project by Unity.
  2. Install System.Text.Json if you don't yet.
    1. Install 'NuGet'(NuGetForUnity).
    2. Select Manage NuGet Packages from NuGet menu.
    3. Search System.Text.Json from search box.
    4. Select System.Text.Json and install it.
  3. Import release package of UVC4UnityAndroid
  4. Open one of sample scene from UVC4UnityAndroid/Samples/Scenes folder.
  5. Build and run apk on your real Android device.
  6. Connect UVC device(s) with Android Device. Some UVC devices / some Android devices may need powered USB hub between UVC device and Android device.

Note:

  • The plugin project is for Unity 2018.4.14f1 now and may need modification on other Unity version.
  • This plugin setup AndroidManifest.xml to be able to keep permanent permission for UVC device(s). If you don't want this behavior, please remove following steps. The user need to give permission everytime they connect UVC device(s).
    1. Export your project as project of Android Studio from Build Settings window.
    2. Open the exported project with Android Studio.
    3. Open AndroidManifest.xml under {project root}/src/main
    4. Add <activity android:name="com.serenegiant.uvcplugin.UsbPermissionActivity" tools:node="remove"/> in Application section.
    5. Build apk with Android Studio.

Release Note:

  • r0.1.0 on 24 Dec. 2019
    • First release.

About

UVC4UnityAndroid

License:Apache License 2.0


Languages

Language:C# 91.6%Language:ShaderLab 8.4%