I’m trying to test an Android app that makes use of OpenCV for object detection. I have an Android virtual device (AVD) in Android Studio (on Ubuntu) – this device can use a webcam as a camera, and it works fine.
To speed up testing, I’ve recorded all of the objects using the webcam – these recordings are in MP4 files that I’ve imported into OBS 26.1.1 (which adds Virtual Camera support for Linux/Ubuntu). If I go into OBS, and click "Start Virtual Camera", I can view the video on the virtual camera – this virtual webcam is working as expected in Slack, Cheese (the Gnome webcam app), and Webcam Tests
If I check video4linux, I get:
$ v4l2-ctl --list-devices OBS Virtual Camera (platform:v4l2loopback-000): /dev/video0
If I then check my AVD, I get:
$ emulator -avd Pixel_4_API_30 -webcam-list List of web cameras connected to the computer: Camera 'webcam0' is connected to device '/dev/video0' on channel 0 using pixel format 'YUYV'
So (to me) it looks like the AVD is using the OBS virtual camera (
/dev/video0). However, If I then start the AVD (using the command:
emulator -avd Pixel_4_API_30 -camera-back webcam0 -camera-front none) and then try to use the camera app (the standard camera app, not my OpenCV one), I get the following warning in the terminal:
emulator: WARNING: _camera_client_query_stop: Camera '/dev/video0' is not started emulator: WARNING: _camera_client_query_stop: Camera '/dev/video0' is not started
The camera app then closes after the warnings are output. No other camera-based app (in the AVD) is able to show the output of the virtual camera.
I managed to find this answer to a similar Stack Overflow question (about AVD with OBS) – however, this answer was from a few weeks before OBS added in virtual webcam support. When I get to Step 4 of this answer, I get the following error:
$ emulator -avd Pixel_4_API_30 -webcam-list emulator: ERROR: _camera_device_open: Camera '/dev/video0' is not a video capture device
Does anyone know how to resolve this issue with the virtual webcam not functioning properly with AVD? I’ve attached the AVD config for additional info:
AvdId=Pixel_4_API_30 PlayStore.enabled=true abi.type=x86 avd.ini.displayname=Pixel 4 API 30 avd.ini.encoding=UTF-8 disk.dataPartition.size=6G fastboot.chosenSnapshotFile= fastboot.forceChosenSnapshotBoot=no fastboot.forceColdBoot=no fastboot.forceFastBoot=yes hw.accelerometer=yes hw.arc=false hw.audioInput=yes hw.battery=yes hw.camera.back=webcam0 hw.camera.front=emulated hw.cpu.arch=x86 hw.cpu.ncore=4 hw.dPad=no hw.device.hash2=################# REMOVED ################# hw.device.manufacturer=Google hw.device.name=pixel_4 hw.gps=yes hw.gpu.enabled=yes hw.gpu.mode=auto hw.initialOrientation=Portrait hw.keyboard=yes hw.lcd.density=440 hw.lcd.height=2280 hw.lcd.width=1080 hw.mainKeys=no hw.ramSize=1536 hw.sdCard=yes hw.sensors.orientation=yes hw.sensors.proximity=yes hw.trackBall=no image.sysdir.1=system-images/android-30/google_apis_playstore/x86/ runtime.network.latency=none runtime.network.speed=full sdcard.size=2048 MB showDeviceFrame=yes skin.dynamic=yes skin.name=pixel_4 skin.path=/home/chardeemacdennis/Android/Sdk/skins/pixel_4 tag.display=Google Play tag.id=google_apis_playstore vm.heapSize=1024
Source: Android Questions