本文介绍了如何在安卓模拟器中使用网络摄像头捕捉实时图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
据我所知,Android 模拟器没有摄像头.要捕获实时图像,我们必须使用网络摄像头.我在这个 网站 中看到了使用 android 模拟器中的网络摄像头进行捕获的代码图片,但我不知道如何使用此代码.
解决方案
- 下载页面上列出的所有源文件:CameraSource、GenuineCamera、HttpCamera、SocketCamera、BitmapCamera 和 WebcamBroadcaster.
- 在您的项目中创建一个名为 com.tomgibara.android.camera 的包,并将前 4 个源文件放入其中.
- 从这里下载 JMF 并安装它.
- 使用以下命令编译 WebcamBroadcaster:"C:Program Files (x86)Javajdk1.6.0_15injavac.exe" -classpath "C:Program Files (x86)JMF2.1.1elib" WebcamBroadcaster.java 或与之等效的文件.
- 使用以下命令运行并保持运行:java "-Djava.library.path=C:Program Files (x86)JMF2.1.1dlib" WebcamBroadcaster
- 在您的程序中使用以下代码:
CameraSource cs = new SocketCamera("192.168.0.100", 9889, 320, 240, true);如果(!cs.open()){/* 处理获取相机失败*/}while(/*某些条件*/) {cs.capture(canvas)//将帧捕捉到画布上}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.
解决方案
- Download all the source files listed on the page: CameraSource, GenuineCamera, HttpCamera, SocketCamera, BitmapCamera, and WebcamBroadcaster.
- Create a package in your project called com.tomgibara.android.camera and place the first 4 source files inside.
- Download JMF from here and install it.
- Compile WebcamBroadcaster using the following command: "C:Program Files (x86)Javajdk1.6.0_15injavac.exe" -classpath "C:Program Files (x86)JMF2.1.1elib" WebcamBroadcaster.java or what's equivalent to it.
- Run it with the following command and keep it running: java "-Djava.library.path=C:Program Files (x86)JMF2.1.1dlib" WebcamBroadcaster
- Use the following code in your program:
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.
这篇关于如何在安卓模拟器中使用网络摄像头捕捉实时图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!