【问题标题】:Android webcam enable in emulator在模拟器中启用 Android 网络摄像头
【发布时间】:2012-08-08 02:52:50
【问题描述】:

嘿,我是 Android 新手。我正在使用 Android4 sdk。我无法在 Android 模拟器中启用网络摄像头。谁能告诉如何启用它。 谢谢。

【问题讨论】:

  • @Tim 你可以在模拟器上使用相机。这是添加到 Android SDK 的功能。但是,我自己从未使用过它。
  • 这个答案可能有你要找的东西:stackoverflow.com/a/8443673/211292
  • @ThomasW 很高兴知道,感谢您的更正 =)

标签: android emulation


【解决方案1】:

有一种方法可以使用 Android 虚拟设备管理器来完成这项工作。您需要编辑您的 AVD,以便在硬件部分“配置正面摄像头”或“配置背面摄像头”可用。这些属性的一个(但不是两个)值应设置为“webcam0”(或任何可用的值)。然后启动您的虚拟设备并将您的网络摄像头用作模拟摄像头。

如果您将这两个属性都设置为“webcam0”,那么当您启动虚拟设备时会收到警告,并且相机应用程序中将无法使用前/后控件。

【讨论】:

  • 我正在设置“配置面向前方的摄像头:webcam0”。但是,如果我检查模拟器中可用的前置摄像头,它会返回 false。这里frontcam返回false,rearCam返回true。(即)PackageManager pm = getPackageManager(); frontCam = pm.hasSystemFeature("android.hardware.camera.front");后置摄像头 = pm.hasSystemFeature(PackageManager.FEATURE_CAMERA);可能是什么问题?
  • @Manoj 我不知道问题可能是什么。告诉我们有关您的 AVD 设置(目标、CPU/ABI 等)的更多信息。
  • @ThomasW 感谢您的回复。我在以下帖子中附上了我的 AVD 屏幕截图:stackoverflow.com/questions/15522686/…
  • 我为前后设置了 webcam0,这导致了问题。我只将背面设置为 webcam0 并且它有效。谢谢emulator: WARNING: Camera name 'webcam0' is not found in the list of connected cameras. Use '-webcam-list' emulator option to obtain the list of connected camera names.
【解决方案2】:

使用模拟器帮助探索可用选项

$ emulator -help 2>&1 | grep cam
    -camera-back <mode>            set emulation mode for a camera facing back
    -camera-front <mode>           set emulation mode for a camera facing front
    -webcam-list                   lists web cameras available for emulation

例如,使用-webcam-list 列出已识别的摄像头

$ emulator -webcam-list @4.1
List of web cameras connected to the computer:
 Camera 'webcam0' is connected to device '/dev/video0' on channel 0 using pixel format 'YUYV'

查看相机的模拟选项

$ emulator -camera-front help @4.1
emulator: ERROR: Invalid value for -camera-front <mode> parameter: help
Valid values are: 'emulated', 'webcam<N>', or 'none'

【讨论】:

  • 我使用 avd config.ini 文件中的可用摄像头使其正常工作,行:hw.camera.back=webcam0 hw.camera.front=none
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-12-10
  • 1970-01-01
  • 2019-09-01
  • 1970-01-01
  • 2015-03-08
相关资源
最近更新 更多