Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Emulator: Unable to start webcam to capture picture in emulator

I have created an armeabi API 21 emulator in the AVD manager in Android Studio, set it to use the webcam as a front camera, and launched it. The problem is that it's not able to open it, as I'm getting this error:

emulator: ERROR: camera_device_start_capturing: VIDIOC_STREAMON on camera '/dev/video0' has failed: Timer expired emulator: ERROR: _camera_client_query_start: Cannot start camera '/dev/video0' for NV21[640x480]: Inappropriate ioctl for device 

How can I solve this?

The webcam works normally using other software. The operative system is Ubuntu 14.04.

like image 451
Alessandro Roaro Avatar asked Jan 10 '15 10:01

Alessandro Roaro


2 Answers

In Android Studio, go to AVD Manager, click on edit (pencil) button in Actions. After that, in next appearing window, click on Advance settings, and then scroll down and in Camera options, select webcam for front and back.

like image 160
BST Kaal Avatar answered Sep 22 '22 07:09

BST Kaal


To enable Camera in your Android Emulator, just add following highlighted code in your AVD’s config.ini file. You can find the config.ini file under your <userdirectory>/.android folder.

File: ~/.android/config.ini

hw.lcd.density=160<br> skin.name=HVGA<br> skin.path=platforms\android-9\skins\HVGA<br> hw.cpu.arch=arm<br> abi.type=armeabi<br> vm.heapSize=24<br> image.sysdir.1=platforms\android-9\images\<br> hw.camera=yes<br> sdcard.size=64M<br> 

In case you don’t find the config.ini file or want to enable Camera support through Android SDK and AVD Manager do the following:

Open Android SDK and AVD Manager:

  1. Add SD Card in AVD
    In the SD Card setting, set the value for Size. To enable camera, the SD Card must be enabled in Emulator.
  2. Add Camera Support in Hardware under AVD
    Now under Hardware section, click New button to add Camera hardware. It will open following Dialog box. Select Camera support from the Property dropdown and click Ok.
  3. Enable Camera Support in Hardware
    The new hardware: Camera support is visible under Hardware section. Set its value to yes and save changes by pressing Edit AVD.
  4. Save the changes and launch the emulator.
like image 30
Mayavi Avatar answered Sep 22 '22 07:09

Mayavi