- Home /
USB Camera to Android
Hi there! I got a problem connecting my USB Camera to my tablet(ASUS K10A) The device reads only the front and back camera I'm searching for answers but still no luck, I need help. Thanks in advance!
I put this line in my AndroidManifest to use an external camera device if one is connected.
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera.external" android:required="true"/>
My working code:
#pragma strict
private var devices : WebCamDevice[];
public var deviceName : String;
private var wct : WebCamTexture;
private var resultString : String;
function Start() {
yield Application.RequestUserAuthorization (UserAuthorization.WebCam);
if (Application.HasUserAuthorization(UserAuthorization.WebCam)) {
devices = WebCamTexture.devices;
deviceName = devices[0].name;
wct = new WebCamTexture(deviceName, 640, 480, 30);
renderer.material.mainTexture = wct;
wct.Play();
resultString = "no problems";
} else {
resultString = "no permission!";
}
}
function OnGUI() {
for (var i = 0; i < devices.length; i++) {
GUI.Box(Rect(100, 100+(i*25), 300, 25),devices[i].name);
}
GUI.Box(Rect(100, 100+(i*25), 400, 25),resultString);
}
I am also looking for a way to get external USB cameras into the webcamtexture on android, have you found a solution yet?
Try this one bro -> https://droidperception.wordpress.com/simplewebcam-app/
@jericmiana Were you able to figure this out?
Not sure how you were able to integrate the SImpleWebCam into Unity. I'd love to be able to get some help with this.
Thanks!
Answer by philc · Sep 21, 2016 at 02:17 PM
It seems that from Camera module 2.4 androids support external camera. See https://source.android.com/devices/camera/versioning.html#module_version
External camera (e.g. USB hot-plug camera) support. The API updates specify the camera static info is available only when camera is connected and ready to use for external hot-plug cameras. Calls to get static info will be invalid calls when camera status is not CAMERA_DEVICE_STATUS_PRESENT. The framework counts solely on device status change callbacks to manage the available external camera list.
I just have no idea what devices comes with such a camera module version...
Philippe ,Seems that Android introduced with Camera module version 2.4 support for external camera. See https://source.android.com/devices/camera/versioning.html#module_version that writes:
External camera (e.g. USB hot-plug camera) support. The API updates specify the camera static info is available only when camera is connected and ready to use for external hot-plug cameras. Calls to get static info will be invalid calls when camera status is not CAMERA_DEVICE_STATUS_PRESENT. The framework counts solely on device status change callbacks to manage the available external camera list.
Your answer
Follow this Question
Related Questions
Activating multiple external programs via Unity 1 Answer
WebCamTexture.devices.Length returning 0 in Unity 2020.3.8f1 0 Answers
Accessing camera torch/flash issues - Torch works but can't access while streaming webcamtexture 0 Answers
WebCamTexture and VSync (iPhone 4) 3 Answers
Switching to two different cameras with Vuforia ARCamera 0 Answers