Enable emulator of Android to support web camera

Source: Internet
Author: User

The camera of emulator does not support dynamic image acquisition. What we can use is as follows.

The following describes how to support web camera in a program.

The method we need to use is the introduction of http://www.tomgibara.com/android/camera-source. BasicallySocketOrHTTPTo obtain the image from webcam. Furthermore, if you cannot install webcam, you can use a virtual camera. The following describes the two methods (socket and HTTP) respectively ).

OK. Prepare some resources.

1. JMF

This can provide socket-based image acquisition.

Download from http://www.oracle.com/technetwork/java/javase/tech/index-jsp-140239.html. (The first time I saw this page, it may be a bit dizzy. There is a download link in downloads at the bottom of the page)

2. virtual camera

This is our video image source. You can simulate the camera behavior by playing a local video file.

There should be a lot of resources on the Internet. I use download from http://www.onlinedown.net/softdown/47920_2.htm.

3. Web camera 2000

This software can capture the image of the camera and use the embedded web server to allow the external to obtain the image in http mode, which is very powerful.

4. intellij or eclipse

I have used these two Android ides, but I still think intellij is easier to use. There is no disgusting PEM/GEN error, and the automatic prompt has a good performance in the 10.0 + version. You can use Google/Baidu to create a development environment.

We will use two classes in http://www.tomgibara.com/android/camera-source: httpcameraand socketcamera.

The following describes the installation and configuration points of socket-based software.

My desktop environment is Windows 7 Ultimate. Windows XP/Vista should be simpler. I have explored Linux myself. It should be similar.

1. virtual camera

After installation, select Source-> video/image files. The program comes with a beautiful video to play, so that your camera is ready.

2. JMF

After installation,Run as AdministratorC: \ Program Files \ jmf2.1.1e \ bin \ jmfinit.exe. In this way, your camera should be recognized. You can use the file-> capture function of jmstudio.exe to confirm.

OK. JMF and camera can work together.

3. Use the socket method to obtain the image in your own program

For example, use the following code in a custom control:

Private void capture (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 ();
}

The following describes how to install and configure HTTP.

1. virtual camera

As above, I will not repeat it

2. Web camera 2000

This program can be decompressed without installation. Select a device from the video menu to play the video.

You can also set the Enable Web server and port number.

3. Use http to retrieve images in your own program

For example, use the following code in a custom control:

Private void capture (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 ();
}

TIPS:

You can use invalidate () in ondraw () to repeatedly refresh the interface and simulate the animation effect.

Okay. Have a good time debugging.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.