如何使用网络摄像头的Andr​​oid模拟器捕获实时图像? [英] How to use web camera in android emulator to capture a live image?

查看:161
本文介绍了如何使用网络摄像头的Andr​​oid模拟器捕获实时图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据我所知,Android模拟器不会有一个摄像头。要捕获实时图像,我们必须使用网络摄像头。我见过code在此网站使用网络摄像头的Andr​​oid模拟器捕获图像,但我不知道如何使用这个code。

解决方案
  1. 下载所有网页上列出的源文件:CameraSource,GenuineCamera,HttpCamera,SocketCamera,BitmapCamera和WebcamBroadcaster
  2. 创建一个包在您的项目称为com.tomgibara.android.camera和内部发生的前4个源文件。
  3. 这里并安装它。
  4. 在编译WebcamBroadcaster使用以下命令:C:\ Program Files文件(x86)的\的Java \ jdk1.6.0_15 \斌\器javac.exe-classpathC:\ Program Files文件(x86)的\ JMF2.1.1e \ LIBWebcamBroadcaster.java或什么是等同于它。
  5. 用下面的命令来运行它,并保持运行:java的-Djava.library.path = C:\ Program Files文件(x86)的\ JMF2.1.1d \ lib目录WebcamBroadcaster
  6. 使用以下code程序中的:

  CameraSource CS =新SocketCamera(192.168.0.100,9889,320,240,真正的);
如果(!cs.open()){
/ *处理未能获得摄像头* /
}
而(/ *某些情况* /){
cs.capture(画布)//帧捕捉到画布
}
cs.close();
 

PS:我一直没能对此进行测试,因为我得到一个错误,当我运行 WebcamBroadcaster

PPS:我刚开始与Android尝试,所以今天这一切都可能是错误的。

As far as i know, Android emulator doesn't have a camera. To capture a live image we have to use the web camera. I have seen code in this web site to use the web camera in the android emulator to capture an image, but I don't know how to use this code.

解决方案

  1. Download all the source files listed on the page: CameraSource, GenuineCamera, HttpCamera, SocketCamera, BitmapCamera, and WebcamBroadcaster.
  2. Create a package in your project called com.tomgibara.android.camera and place the first 4 source files inside.
  3. Download JMF from here and install it.
  4. Compile WebcamBroadcaster using the following command: "C:\Program Files (x86)\Java\jdk1.6.0_15\bin\javac.exe" -classpath "C:\Program Files (x86)\JMF2.1.1e\lib" WebcamBroadcaster.java or what's equivalent to it.
  5. Run it with the following command and keep it running: java "-Djava.library.path=C:\Program Files (x86)\JMF2.1.1d\lib" WebcamBroadcaster
  6. Use the following code in your program:

CameraSource cs = new SocketCamera("192.168.0.100", 9889, 320, 240, true);
if (!cs.open()) { 
/* deal with failure to obtain camera */ 
} 
while(/*some condition*/) {   
cs.capture(canvas) //capture the frame onto the canvas
}
cs.close();

PS: I haven't been able to test this because I'm getting an error when I run WebcamBroadcaster.

PPS: I just started experimenting with Android today so all this could be wrong.

这篇关于如何使用网络摄像头的Andr​​oid模拟器捕获实时图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆