Webcam attached to Nexus 7

Update: Check for the latest version here

We managed to attach a USB webcam to a Nexus 7 and stream the content in a small app. This will be interesting for projects where stereo vision is involved. In theory two or even more cameras are possible. The Nexus 7 should also deliver enough power to make some real-time computer vision feasible. Stereo SLAM will definitely be an interesting thing to look into.

Howto

Required:

1. Plug in your Webcam to the Tablet

2. Start Terminal App and enter the following:

su
ls -l /dev/video0

This should give you root rights and show you the attached Webcam device node.

If you see something like “No such file or directory” then your Webcam is either not attached correctly or may not be supported.

3. Now enter the following to set the permissions for the device node:

chmod 666 /dev/video0

4. Start your Webcam App and see if it works.

The Downside to this approach is that as soon as the webcam is removed the device node disappears and the permissions have to be set again when the webcam is reattached.

More permanent methods would require a rule change in the ueventd.rc files.

Troubleshooting

1. Why does /dev/video0 not appear when i plug in the webcam ?

Check the output of dmesg and see if the webcam has been recognized. Type the following in the terminal app:

su
dmesg

What you should see among a lot of other output is this:

uvcvideo: Found UVC 1.00 device <unnamed> (046d:0807)
input: UVC Camera (046d:0807) as /devices/platform/tegra-ehci.0/usb2/2-1/2-1:1.0/input/input6

The 046d:0807 is the unique product and vendor ID of the camera that should be on the list of supported devices here. The ID shown is for Logitech and the C500.

Check if there are issues reported in connection with you camera. If you don’t see the above output altogether, your camera is likely not supported.

Advertisements

66 responses to “Webcam attached to Nexus 7

  1. I’d love to try this out on my Nexus 7.
    Would you be able to provide the compiled app for downbload?
    I only see src on the neuralassembly site.
    Thanks

      • Thanks! Tried it with a camera that is supposedly UVC but don’t see /dev/video0 being created. need to try other devices.

      • Hi,
        I downloaded both the terminal app and webcam app. What will be shown on the screen if I plug the webcam via OTG USB? How do I know if the webcam is detected or not? Why is the /dev/video0 not there in the root of my Nexus 7? Pls advice….thanks!!

  2. Here is the dmesg created when I attach the uvc cam.

    [ 146.206554] usb 2-1: new high speed USB device number 2 using tegra-ehci
    [ 146.247193] usb 2-1: New USB device found, idVendor=1e4e, idProduct=0100
    [ 146.247272] usb 2-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
    [ 146.247389] usb 2-1: Product: USB2.0 Camera
    [ 146.247453] usb 2-1: Manufacturer: Etron Technologies
    [ 146.248952] uvcvideo: Found UVC 1.00 device USB2.0 Camera (1e4e:0100)
    [ 146.253694] uvcvideo: UVC non compliance – GET_DEF(PROBE) not supported. Enabling workaround.
    [ 146.254966] input: USB2.0 Camera as /devices/platform/tegra-ehci.0/usb2/2-1/2-1:1.0/input/input3
    [ 146.290563] tegra-otg tegra-otg: HOST –> SUSPEND
    [ 146.291755] usb 2-1: USB disconnect, device number 2
    [ 146.293479] Wake39 for irq=52
    [ 146.293546] Disabling wake39
    [ 146.293612] tegra-ehci tegra-ehci.0: remove, state 18
    [ 146.293744] usb usb2: USB disconnect, device number 1
    [ 146.477591] hub 2-0:1.0: hub_port_status failed (err = -19)
    [ 146.477744] hub 2-0:1.0: connect-debounce failed, port 1 disabled
    [ 146.517887] tegra-ehci tegra-ehci.0: USB bus 2 deregistered

  3. Pingback: Terminal Emulator bekommt kein Root - Android-Hilfe.de·

  4. Great app!!! I have got it to work with the following devices (Nexus 7 both rooted and unrooted and the Galaxy SIII). Also the following cameras worked.
    SSK = Gsou USB2.0 Camera
    0ac8:3420=Venus USB 2.0 Camera (Tevion MD 85872 and Minoru3D) BY Vimicro

    CREATIVE = Vimicro USB Camera (Altair)
    0ac8:3450=A4Tech PK-333E BY A4Tech

    Logitech = Logitech Webcam C260
    046D: 081A can not find specific info

    It would be really great if the app had a record feature. I have tried working with your source to work on this but have not been able to do much (need to work on my Eclipse and coding skills).

    • Glad to see that it works for you. I am surprised that it works on an unrooted device. The device nodes usually have the permissions set in a way that one needs root permissions to make it work.
      It is not my app by the way but something that has been developed at the Kogakuin University. I merely showed that it does work with the Nexus 7. They were kind enough to provide the source code which should allow you to implement a recording feature. It is tricky but not impossible to do that. My time is currently limited by other projects but if you want to give it a try I recommend looking into opencv and the VideoCapture and VideoWriter classes.

  5. Hi,
    I have a problem…
    I followed the steps :
    1. I typed in terminal su…not found
    2. ls -l /dev/video0 … crw-rw—-media camera. etc.etc
    3. chmod 666 /dev/video0 … unable to chmod /dev/video0: operation not permitted

    if I can help me tell me the problem ?
    Thanks

    • It seems like you don’t have ‘su’ (short for superuser) installed which means your device may not be properly rooted.
      There are a lot of instructions on how to do this you can find via google. Just search for “root Nexus”
      It is unfortunately beyond the scope of this post to explain it in detail here.

      Good Luck

  6. Hi Larry,
    I found the following message after dmesg:

    [192.641956] usb 2-1: New USB device found. idVendor=1b3f, iProduct=2002
    [192.642161] usb 2-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
    [192.642512] usb 2-1: Product: GENERAL -UVC
    [192.646856]: usb 2-1: Manufacturer : GENERAL
    [192.646856] uvcvideo:Found UVC 1.00 device GENERAL – UVC (1b3f:2002)
    [192.650138] input: GENERAL – UVC as /devices/platform/tegra-ehci.0/usb2/2-1/2-1:1.0/input/input3

    what should I do to proceed? I have the simplewebcam application in my nexus 7 but I am still seeing black display after I click the app. Pls advice. Thank you

  7. by the way, when I type: ls -l /dev/video0
    I get the following prompt:
    crw-rw —- media camera 81, 0 2013-01-05 17:46 video0

    • Your webcam has been detected and the device node has been created which is great. Still the permissions are wrong. What you should see is this “crw-rw-rw- media camera” . The last -rw- part means that every user can access the webcam. Did you perform the “su chmod 666” part ?

      • I’m curious as to why the app doesn’t ‘see’ the camera if I set the UID bit on it (4666). I suspect it’s not the webcam app that needs the general user access to the device to see the camera but another system module? Looking through the source code, I can’t see which module that might be. Any ideas?

      • Yes I perform chmod 666 /dev/video0 but it doesn’t prompt anything after I press enter. Should it prompt any message indicating something?

      • TK, seriously, are you reading the instructions at the top of this webpage?
        Please read step 3, then step 4. All the information you need is right here, if you look!

  8. Curious to know, is the video0 file automatically created upon detection of the webcam? What is the content inside the video0 file?

  9. hi Larry,
    First, thanks for your great efforts!
    i was wondering if it is possible to write a small guide
    “how to config the camera permanent” because on every restart i have to opne the emu again.

      • Just to be clear – ‘droidperception’ is the one here doing the dev work, not me. It’s his blog.
        If you have any questions, please direct them to droidperception in a new reply.
        Thanks

      • I know this app is experimental but there must be a better way of getting the device to work than to run the app with superuser priv.
        How do other apps access new devices with out granting su priv?

      • It really depends on what other devices you mean. I just check my keyboard and it gets a special device node under /dev/usb that points to /dev/input. The device node in /dev/usb has full permissions for everybody. I don’t have a USB drive to test laying around but I suspect that when attaching an USB drive a rule that creates a full permissions device node also exists. The proper way to make this work is to write a udev rule for /dev/video0 in udev.rc . Here comes the “but”, afaik this file is created read only on every restart by the contents of init.rc. Init.rc is part of the system image and will be reset on every restart. If you want to change init.rc here is an explanation on how it is done but quite frankly, sticking with the posted solution is the safest way. I really only recommend changes to init.rc if you know what you are doing. http://stackoverflow.com/questions/9768103/make-persistent-changes-to-init-rc

  10. hi all,
    i tried this on my rooted s2 with stock rom. /dev/video0 node is created but after “ls -l /dev/video0” terminal says “crw-rw-rw- 1 1000 0 81, 0 jan 9 20:50 /dev/video0” and after “chmod 666 /dev/video0” it says nothing.

  11. Pingback: Nexus 7 Webcam attached update | droidperception·

  12. Pingback: Have any android tab display rearview camera when reversing - Page 2 - Genesis Forum: GenCoupe Hyundai Genesis Forums·

  13. I followed the steps said here. But when I run simplewebcam I get an error “permission denied”
    It is happening when the app tries to open /dev/video4 (In my case the usb webcam node is /dev/video4. I am using htc one s)

    I used adb and shell and checked the permissions on /dev/video4. here is the output
    shell@android:/ # ls -l /dev/v*
    ls -l /dev/v*
    crw-rw-rw- root root 81, 5 2013-03-01 19:03 v4l-subdev0
    crw-rw-rw- root root 81, 6 2013-03-01 19:03 v4l-subdev1
    crw-rw-rw- root root 81, 7 2013-03-01 19:03 v4l-subdev2
    crw-rw-rw- root root 81, 8 2013-03-01 19:03 v4l-subdev3
    crw-rw-rw- root root 81, 9 2013-03-01 19:03 v4l-subdev4
    crw-rw-rw- root root 81, 10 2013-03-01 19:03 v4l-subdev5
    crw-rw-rw- root root 81, 11 2013-03-01 19:03 v4l-subdev6
    crw-rw-rw- root root 81, 12 2013-03-01 19:03 v4l-subdev7
    crw-rw-rw- root root 81, 13 2013-03-01 19:03 v4l-subdev8
    crw-rw-rw- system camera 81, 1 2013-03-01 19:03 video0
    crw-rw-rw- system camera 81, 2 2013-03-01 19:03 video1
    crw-rw-rw- system camera 81, 0 2013-03-01 19:03 video100
    crw-rw-rw- system camera 81, 3 2013-03-01 19:03 video2
    crw-rw-rw- system camera 81, 4 2013-03-01 19:03 video3
    crw-rw-rw- system camera 81, 15 2013-03-01 19:15 video4

    It clearly shows that there is read write permission for everybody. But still I am getting permission denied error. What could be the problem?

    • Hello Sairam. That looks indeed weird. I just did a quick check on the code and it looks like by default it will pick video4 if video0 to video3 exist which should be fine in your case. Since you are using an htc phone as opposed to a nexus which has a different flavor of android installed there may really be some permission issue. Video nodes on the nexus are assigned to the media group on htc it appears to be the system group. You could try and run the app with strace that will show you all the accesses the app is trying to make and it is great for debugging. Unfortunately it is not on the system by default and you will have to install it manually.

  14. Works on a rooted Nexus 7, with a cheep camers nameg Targus. (Outdated, I think)
    Hardware ID: USB\VID_0AC&PID0332&REV_0100&MI_02
    Seems to be a Vimicro UVC control device

  15. I have asked you this question in the past. Web cam is not working with usb hub. I have tried using with USBROM mod. No luck. I have even powered the hub connected to OTG y cable.. Came to conclusion that My hub is faulty. It seems you suceeded with hub. Please let me know the brand of the hub your are using.

  16. Great man! this works!
    I tested with a Microsoft LiveCam VX-700, now I need to figure out how to use it with other apps.
    Thanks!

  17. I’m doing my head in trying to get this working on my Galaxy S3.

    Rooted my S3 and tried everything within my limited skill set but can’t get it to work. I have multiple video folders and no extra’s appear when I plug the camera in and non are removed when the usb camera is removed.

    The Video folders are:
    /dev/video 0 1 2 3 11 12 16 and 20

    I don’t see any UVC camera connected when I run the dmseg, it has a lot of the same things repeating. I can post them if you wouldn’t mind pointing me in the right direction. I did see the following and it was the only thing that was relevant to me:
    [ 713.031431] c0 usb 1-2: unlink qh8-0001/eac49280 start 3 [2/0 us]
    [ 713.032709] c0 [RACB:6]<
    [ 713.032743] c0 s5p-ehci s5p-ehci: reused qh eac49280 schedule
    [ 713.032774] c0 usb 1-2: link qh8-0001/eac49280 start 3 [2/0 us]
    [ 713.032816] c0 [CHKRA:6]>
    [ 713.032854] c0 Read: 01 12 00 80 03 01 04 00 00 51 00 06 00 13 03 00
    [ 713.033294] c0 pm_dev_runtime_get_enabled: rpm status: 0
    [ 713.033320] c0 Write: 01 0c 00 00 03 01 00 db 00 4f 00 00 00
    [ 713.039332] c0 [NACB:6]<
    [ 713.039368] c0 [NRA:6]>
    [ 713.039411] c0 usb 1-2: unlink qh8-0001/eac49280 start 3 [2/0 us]
    [ 713.040960] c0 [RACB:6]<
    [ 713.040987] c0 s5p-ehci s5p-ehci: reused qh eac49280 schedule
    [ 713.041017] c0 usb 1-2: link qh8-0001/eac49280 start 3 [2/0 us]
    [ 713.041059] c0 [CHKRA:6]>
    [ 713.041089] c0 Read: 01 1e 00 80 03 01 02 db 00 4f 00 12 00 02 04 00
    [ 713.120298] c0 max77686: id=26, org=5, val=3
    [ 713.120794] c0 max77686: id=28, org=20, val=19
    [ 713.220518] c0 max77686: id=27, org=36, val=18
    [ 713.228939] c0 melfas-ts 3-0048: finger [0] down, palm 0
    [ 713.229367] c0 max77686: id=26, org=3, val=5
    [ 713.230205] c0 max77686: id=28, org=19, val=20
    [ 713.231003] c0 max77686: id=27, org=18, val=1e
    [ 713.231516] c0 [TSP] DVFS On![8]
    [ 713.240076] c0 max77686: id=27, org=1e, val=36Mali: gpu bottom lock status is not valid for pop
    [ 713.241246] c0 max77686: id=29, org=16, val=18
    [ 713.241688] c0 max77686_get_voltage: id=29, val=18
    [ 713.317924] c0 melfas-ts 3-0048: finger [0] up, palm 0
    [ 713.415074] c0 [TSP] DVFS Off!
    [ 713.519037] c2 s3c-fimc0: FIMC0 1 opened.
    [ 713.519077] c2 s3c-fimc0: fimc_cropcap_capture: No capture device.
    [ 713.519115] c2 fimc_s_fmt_vid_capture
    [ 713.519138] c2 s3c-fimc0: fimc_s_fmt_vid_capture: No capture structure.you have to call s_input first.

    ^^^^^^^^The last line^^^^^^^^

    That line lead me to this: http://searchco.de/codesearch/view/26496603

    looks like it might be something of use to someone else having issues who might know what to do with it.

    Anyway, I can’t get it to work. If you could help I’d be in your debt. I’m really suprised there isn’t an app out as yet that just works. But then again it seems very complex to me so I can’t say I blame anyone for not having time to write such an app.

    Thanks for your guide, seems to have worked for quite a few people.

    • Actually looks like it does see it fine. Comes up in host controller app. And this populates in dmesg:

      [ 82.125292] c0 max77686: id=27, org=2a, val=36
      [ 82.245352] c0 max77686: id=27, org=36, val=2a
      [ 82.420369] c0 max77686: id=27, org=2a, val=26
      [ 82.511674] c0 usb 1-1: skipped 1 descriptor after configuration
      [ 82.511717] c0 usb 1-1: skipped 5 descriptors after interface
      [ 82.511751] c0 usb 1-1: skipped 1 descriptor after endpoint
      [ 82.511783] c0 usb 1-1: skipped 17 descriptors after interface
      [ 82.513046] c0 usb 1-1: default language 0x0409
      [ 82.521307] c0 usb 1-1: udev 3, busnum 1, minor = 2
      [ 82.521338] c0 usb 1-1: New USB device found, idVendor=0bda, idProduct=5801
      [ 82.521379] c0 usb 1-1: New USB device strings: Mfr=3, Product=1, SerialNumber=2
      [ 82.521423] c0 usb 1-1: Product: USB Camera
      [ 82.521448] c0 usb 1-1: Manufacturer: Generic
      [ 82.521472] c0 usb 1-1: SerialNumber: 200901010001
      [ 82.521502] c0 call_battery_notify : VID : 0xbda, PID : 0x5801 no action.
      [ 82.522099] c0 usb 1-1: usb_probe_device
      [ 82.522138] c0 usb 1-1: configuration #1 chosen from 1 choice
      [ 82.528306] c0 usb 1-1: adding 1-1:1.0 (config #1, interface 0)
      [ 82.531588] c0 usb 1-1: adding 1-1:1.1 (config #1, interface 1)
      [ 82.532122] c0 drivers/usb/core/inode.c: creating file ‘003’
      [ 82.532250] c0 s5p-ehci s5p-ehci: GetStatus port:2 status 001005 0 ACK POWER sig=se0 PE CONNECT

      • Hi there,
        you are right in that the camera is recognized but it seems like the S3 doesn’t come with the uvc driver precompiled in the kernel which means webcams won’t work, sorry.
        Samsung devices often come with wildly changed android versions compared to the vanilla android you get from google nexus devices. If you really want this to work very badly you would need to install a custom rom with the driver enabled.

        The fimc driver seems to take care of the internal camera not any externaly attached devices btw. http://www.mjmwired.net/kernel/Documentation/video4linux/fimc.txt

  18. Hi,
    Thanks for the reply, is there a ROM you can recommend that might already have this recompiled? I don’t think i will be able to add the driver in my self. I’ll have a look around the usual forums and see if I can find any references to uvc camera drivers or v4l support but I don’t think I have seen this before.

    Thanks again!

    • I’ve tried SuperNexus [4.2.2] but unfortunately the drivers are not complied. I’ll try a couple of others tonight or on the weekend. But if I can’t get it to work I’ll likely have to give up and next time I’ll purchase a Nexus device 😦

  19. I had a quick look around, they unfortunately never publish their kernel configuration when creating roms. The kernel modules / options that have to be enabled are at the top of Kanamura Lab page. You could ask the rom creator to enable these or try to create your own rom from the android source tree before resorting to buying a new device.

  20. Pingback: Android - Review AOC Breeze MW0731DC·

  21. Hi! I’ve came across your blog in search of information about Android external USB webcams. I got two tablet (ICOO D70Pro II) running stock fw and the other CM10. I was trying to access my webcam thru your app, but it doesn’t show any image. At my surprise, I found that the system detects my webcam properly (creation of dev/video1). Also, the stock camera app now shows that I have a back camera (note that device has only front), but the gallery app crashes (and many other camera apps) when I try to switch to it. Tried different combinations – booting with and without the camera plugged, but nothing seems to work. Can you help me out? It’s a big project for me. I would greatly appreciate any help and advice. Posting dmesg as a proof that it works:

    [ 2.854075] usb 1-1: config 1 interface 3 has no altsetting 1
    [ 3.122337] usb 1-1: New USB device found, idVendor=0c45, idProduct=6710
    [ 3.122355] usb 1-1: New USB device strings: Mfr=2, Product=1, SerialNumber=0
    [ 3.122364] usb 1-1: Product: Wireless PC-CAM
    [ 3.122371] usb 1-1: Manufacturer: Sonix Technology Co., Ltd.
    [ 3.214270] uvcvideo: Found UVC 1.00 device Wireless PC-CAM (0c45:6710)
    [ 3.279205] vpu: power on
    [ 3.279261] VPU_SERVICE: HW ID = 0x67312398
    [ 3.279268] VPU_SERVICE: Compatible HW found at 0x10104400
    [ 3.279279] VPU_SERVICE: HW ID = 0x48311220
    [ 3.279285] VPU_SERVICE: Compatible HW found at 0x10104000
    [ 3.279661] vpu: power off…done
    [ 3.279686] VPU_SERVICE: init success
    [ 3.396796] input: Wireless PC-CAM as /devices/platform/usb20_otg/usb1/1-1/1-1:1.0/input/input3

  22. Hi Michael,

    if you indeed get a /dev/video1 you can try and create a symbolic link /dev/video0 that points to /dev/video1.

    Do this as after ‘su’
    ln -s /dev/video0 /dev/video1

    The app expects the camera to show up as video0.

    • First of all, thank you for quick response. I’ve tried to create symlink, but it gives me an error, that the file already exists.

      I should have mentioned earlier that I got another USB cam that worked out of the box, but only in the stock camera app, where it was recognized as rear camera. But the one I’m trying to make work in android is far more important to the project (actually, they both are USB microscopes). Also, both worked on Androidx86 flawlessly. They are supported by v4l and uvc compatible.

  23. I am using a rocketfish webcam and I do see the following lines

    uvcvideo: Found UVC 1.00 device (19ff:0218)
    input: Rocketfish HD webcam as /devices/platform/usb20_host/usb2/2-1/2-1.4/2-1.4:1.0/input/input9

    But i still cannot see it in my camera app. Is it because the wecam is not on the list of supported devices?

    • Hi LuK,

      that’s not possible unfortunately. Skype doesn’t offer any way to inject video data into its app. If it doesn’t support your webcam already it probably won’t work.

  24. Hello. This is very interesting task to do on my S4 GT-I9505 4.3 no root. There it says version 5 doesn’t need root so what’s the steps to follow?
    One more thing. How I know if my camera which i connect via OTG has been detected? Should appear something called “video0” inside the “dev” folder?

  25. Hi I have just got a Nexus 7 2013 and saw this I was wondering if there was a way to be able to record video on my nexus 7 using an external cam I use a cam with my telescope to do Astrophotography and this would be so usefull using the tablet instead of a laptop if there were a few more controls available like gain and exposure but it’s an amazing achievement so far.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s