在 Android 模拟器中使用相机
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2884620/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Using Camera in the Android emulator
提问by Primal Pappachan
I wish to simulate camera in the android emulator using the webcam. Basically I need to only take photos with the camera in the emulator (live preview is not needed i.e if it makes it any easier)
我希望使用网络摄像头在 android 模拟器中模拟相机。基本上我只需要在模拟器中用相机拍照(不需要实时预览,即如果它更容易的话)
I followed the tutorial herewhich is the only one I could find that was close to my requirements
我遵循了这里的教程,这是我能找到的唯一一个接近我的要求的教程
But many of the libraries used in that tutorial(like android.hardware.CameraDevice) are not available in present sdk and are replaced by new libraries(like android.hardware.camera).
但是该教程中使用的许多库(如 android.hardware.CameraDevice)在当前 sdk 中不可用,并被新库(如 android.hardware.camera)取代。
Any help on how to do this in the present sdk(2.1 or 2.2) would be much appreciated.
任何有关如何在当前 sdk(2.1 或 2.2)中执行此操作的帮助将不胜感激。
采纳答案by Paramvir Singh
Update: ICS emulator supports camera.
更新:ICS 模拟器支持相机。
回答by Adam Johns
回答by Curious Lemming
Some elaboration, in the hope of clarifying what has already been said:
一些阐述,希望澄清已经说过的内容:
As stated above, Webcams are supported nativelyin the current SDK, but only on recent android versions (4.0 and higher)
如上所述,当前 SDK本身支持网络摄像头,但仅适用于最新的 android 版本(4.0 及更高版本)
Webcam detection is automatic where present. In 4.0.3, the camera defaults to the front-facing camera so a lot of applications (especially pre-2.3 applications, which can only fetch the default camera, i.e. the back-facing one) will still show you the old checkerbox-with-moving-square stand-in instead.
网络摄像头检测在存在时是自动的。在 4.0.3 中,摄像头默认为前置摄像头,因此很多应用程序(尤其是 2.3 之前的应用程序,只能获取默认摄像头,即后置摄像头)仍然会显示旧的复选框-带-moving-square 替身。
I think some more info is available in the following post: Camera on Android Eclipse emulator:
我认为以下帖子中提供了更多信息:Android Eclipse 模拟器上的相机:
Or at least, that's the most information I've been able to find--aside from the brief, uninformative statements in the release notes for the SDK tools.
或者至少,这是我能找到的最多信息——除了 SDK 工具的发行说明中简短的、无信息的声明。
回答by Ahsan
Update of @param's answer.
更新@param 的答案。
ICS emulator supports camera.
ICS 模拟器支持相机。
I found Simple Android Photo Capture, which supports webcam in android emulator.
我找到了Simple Android Photo Capture,它支持 android 模拟器中的网络摄像头。
回答by Keagan Ladds
Does not seem like it, but android recognises a webcam as a device. Every time I run the emulator my webcam's active light comes on.
看起来不像,但 android 将网络摄像头识别为设备。每次运行模拟器时,我的网络摄像头的活动灯都会亮起。
回答by Solostaran14
There is an updated version of Tom Gibara's tutorial. You can change the Webcam Broadcaster to work with JMyron instead of the old JMF.
有更新版本的 Tom Gibara 教程。您可以更改 Webcam Broadcaster 以使用 JMyron 而不是旧的 JMF。
The new emulator (sdk r15) manage webcams ; but it has some problems with integrated webcams (at least with mine's ^^)
新的模拟器 (sdk r15) 管理网络摄像头;但它在集成网络摄像头方面存在一些问题(至少是我的 ^^)
回答by Ajax
The newest camera2 apis work fine w/ an emulator that has camera support enabled.
最新的camera2 apis在启用了相机支持的模拟器的情况下可以正常工作。
Example for using the newer API:
使用较新 API 的示例:
回答by serv-inc
Just in case you just need to show a picture in response to a camera request, there is image-to-camera.
以防万一您只需要显示图片以响应相机请求,可以使用image-to-camera。
Just download, build, install, copy an image of your choice to the device, and you can select it via the app, which is an alternative to the built-in camera.
只需下载、构建、安装、复制您选择的图像到设备,您就可以通过应用程序选择它,这是内置相机的替代方案。