惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
Docker
U
Unit 42
Google DeepMind News
Google DeepMind News
B
Blog RSS Feed
S
SegmentFault 最新的问题
阮一峰的网络日志
阮一峰的网络日志
雷峰网
雷峰网
Microsoft Security Blog
Microsoft Security Blog
爱范儿
爱范儿
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园_首页
Apple Machine Learning Research
Apple Machine Learning Research
罗磊的独立博客
GbyAI
GbyAI
Stack Overflow Blog
Stack Overflow Blog
Martin Fowler
Martin Fowler
宝玉的分享
宝玉的分享
L
LangChain Blog
Engineering at Meta
Engineering at Meta
量子位
有赞技术团队
有赞技术团队
博客园 - 【当耐特】
A
About on SuperTechFans
Y
Y Combinator Blog

博客园 - sayo.net

website the breakpoint will not currently be hit. no symbols have been loaded for this document How to add MS Test to post build 在WCF中使用REST时,如何去掉URL中的.svc后缀 Resolve Error: The service cannot be activated because it does not support ASP.NET compatibility. Resolve Error: Service has zero application (non-infrastructure) endpoints. WCF Could not establish trust relationship for the SSL/TLS secure channel with authority Could not find a base address that matches scheme http for the endpoint with binding MetadataExchangeHttpBinding. Resolve error: Could Not Load Type ‘System.ServiceModel.Activation.HttpModule’ 在IIS7.5上运行Message Security with UserName的WCF Service WCF部署问题两则 SQL Server Mangement Studio无法创建Database Dagrams的简单解决办法 一些有用的WCF相关链接 [Android开发]如何自定义ArrayAdapter 如何旋转Android Emulator HTC Hero Android 2.1 真机调试 HTC Hero Android 2.1 真机调试 CouchDB系列 - 安装CouchDB Test from Windows Live Writer Silverlight Toolkit初探
让Android的emulator支持web camera
sayo.net · 2010-12-30 · via 博客园 - sayo.net

emulator的camera没有支持动态获取图像的功能。所能用到的是像下面那样的,很不爽。

image

下面介绍如何在程序中支持web camera。

我们要用到的方法是http://www.tomgibara.com/android/camera-source介绍的。基本上就是利用socket或者http的方式从webcam中获取图像。更进一步,如果你连webcam都不方便安装的话,可以使用虚拟摄像头。下面我们分别介绍这两种方法(socket和http)。

OK,请准备一下一些资源。

1. JMF

这个可以提供socket方式的图像获取。

http://www.oracle.com/technetwork/java/javase/tech/index-jsp-140239.html下载。(第一次看到这个页面可能有点晕,页面最下面Downloads里面有下载链接Download JMF

2. Virtual Camera

这个就是我们的视频图像源了,可以通过播放本地视频文件等方式模拟摄像头的行为。

网上应该有很多,我使用的是从http://www.onlinedown.net/softdown/47920_2.htm下载的。

3. Web Camera 2000

这个软件可以抓取摄像头的图像并用内嵌的web server让外部以http的方式获取图像,好强大。

4. IntelliJ或者Eclipse

目前用过这两个android的IDE,还是觉得IntelliJ好用些。没有恶心的Pem/Gen error,并且自动提示在10.0+版本有很好的表现。关于如何建立开发环境可以google/baidu一下子。

我们要用到http://www.tomgibara.com/android/camera-source里面的两个类:HttpCamera和SocketCamera。

下面介绍一下Socket方式的软件安装配置要点。

我的桌面环境是windows 7 Ultimate。windows xp/vista应该更简单一些。Linux的自己摸索一下了,应该类似。

1. Virtual Camera

安装好以后选择Source->Video/Image Files,程序自带了一个美女视频播放起来,这样你的摄像头就建好了。

image

2. JMF

装好以后,以管理员权限运行C:\Program Files\JMF2.1.1e\bin\jmfinit.exe。这样你的摄像头就应该能被识别了。可以用jmstudio.exe的File->Capture功能确认一下。

image

image

image

OK,JMF和Camera可以连起来工作了。

3. 在自己的程序中使用Socket方式获取图像

比如在自定义控件中使用以下代码:

private void capture(Canvas canvas) {
        CameraSource cs = new SocketCamera("192.168.1.27", 9889, 320, 240, true);
        if (!cs.open()) {
            // give some error message here….
        }

        //capture the frame onto the canvas
        if(!cs.capture(canvas)) {
            // give some error message here….
        }

        cs.close();
    }

下面介绍一下HTTP方式的安装配置要点。

1. Virtual Camera

跟上面一样,不赘述

2. Web Camera 2000

这个程序不用安装,直接解压缩就可以了。从Video菜单选择设备就可以播放了。

image

还可以设置Enable Web Server以及端口号。

image

3. 在自己的程序中使用Http方式获取图像

比如在自定义控件中使用以下代码:

private void capture(Canvas canvas) {
        CameraSource cs = new HttpCamera(http://192.168.1.27:8080, 320, 240, true);
        if (!cs.open()) {
            // give some error message here….
        }

        //capture the frame onto the canvas
        if(!cs.capture(canvas)) {
            // give some error message here….
        }

        cs.close();
    }

小提示:

可以在onDraw()中使用invalidate()来反复刷新界面,模拟动画效果。

好的,祝各位调试愉快。