Resolving vertically flipped images from webcams in Ubuntu

Friday, July 31st 2009, 01:53

UPDATE 2: I strongly recommend against using this patch any more and relaying on the solution provided by UPDATE 1.

UPDATE 1: Please check the solution from here as it represents the correct approach for fixing this problem in Ubuntu (all releases). Also, the patch from this post doesn’t work for the kernel included in Ubuntu 9.10.

Usually I do not use my laptop’s webcam. Not that I use another webcam. But when I made the radical switch from Windows to Ubuntu, I was disappointed to see that the images from my webcam were vertically flipped and I had no option of turning them 180°. The almost mythical explanation is that somehow some of the webcams mounted on laptops were mounted flipped and the producers have corrected this by pushing the repairs into the Windows drivers. Today luck seemed to be on my side as I have found a patch that now fixes my problem. To correctly apply it in Ubuntu 9.04 you have to browse that topic until the 12th page and check this post.

Because some of you might not correctly apply the patch, I have built a script that will help you patch the uvcvideo module in order to get the right images from your webcam. There are two patches available (I have chosen only the patches that provide a non-mirrored image) so pick the one that gives you the best image. To be able to compare them you must apply both patches, testing your webcam after each of them and then, for the third time, apply the patch that suites your needs.

To test your webcam, you can use VLC.

Here’s the short how to:

  1. install VLC if you do not have it:
  2. sudo apt-get install vlc
  3. download my script from here (right click, Save link as…) and make it executable:
  4. chmod +x flip_webcam
  5. make sure you have the build-essential package:
  6. sudo apt-get install build-essential
  7. run the script with super-user privileges from where you have downloaded it, providing the right options:
  8. This script must be run with super-user privileges.
    Usage: ./flip_webcam {OPTION}
    	 1		this applies patch1 file
    	 2		this applies patch2 file
    	-h, --help	displays this beautiful help section
    

The script will automatically download the needed files, will apply the patch and then it will push the module into your kernel. Do the tests by opening VLC and then following these steps:

  1. go to Media
  2. then go to Open capture device…
  3. in the pop-up window that opens, in the “Video device name” text field, insert /dev/video0
  4. click on Play

Remember to run the script whenever your kernel changes. If everything worked okay, drop a Kudos line to me in the comments. :)

Similar Posts:

40 Comments

1 2 3 4
  • Thanks a lot, it’s working :P

  • Sweet man, thanks! worked perfectly!

    I’m really glad i found this

  • Thanks, but I try to fix this problem in pardus -linux
    both of ./flip_webcam1 and 2 can not solve this flip problem.

    the end of building windows is:

    Loading the module into your kernel…
    ./flip_webcam: line 36: modprobe: command not found
    Housekeeping…
    Done!

    is it error..??

    • Hi Unal! Yes, it’s an error… Try installing modeprobe first. It’s very interesting why this program isn’t already installed in your system.

  • Hey it took a couple of times doing it to get it to work but after following the directions again it now works. Thanks alot.

    • Hi Darkzeus, can you please provide more details? I mean if it’s something that I can improve in the script please tell me. By the way, you are welcome! It’s my way of helping the open-source community by giving something in return.

  • Brilliant! Took a while to download but worked like a charm.

  • [...] webcam fonctionne dès la première utilisation mais l'image est retournée, la solution vient de ce site et m'a été rapportée par edlapoignee du forum [...]

  • this works great !! I’ve been trying to do this for a long time. thank you very much.

    • You are welcome, Burak!

  • Great!!
    Just works fine entered the command, waited and now the image in the right orientation.
    While waiting for completion of the compilation, I continued browsing your blog: Nice Job you do. Felicitations!!

    • Thank you, Christoph!

  • No-one except me seems to have this prob, at least i couldnt find anything, but my webcam is not working AT ALL! and i cant find it in my hw-config either. can anyone help? or does anyone know any forum where this was discussed or any ideas what i could put in google to find something?

  • ba2toot, what is the output of lsusb on your system? I get this on the first line:

    radu@data:~$ lsusb
    Bus 002 Device 003: ID 04f2:b012 Chicony Electronics Co., Ltd 1.3 MPixel UVC webcam

    Does your webcam fail to function only in Ubuntu (Linux)?

1 2 3 4

Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">


CODE EXAMPLES: When you want to include source code or terminal output, please use the the following tags like in the next example:

    [language]
    code lines
    [/language]
	

where you substitute language with the programming laguage used throught the code example (for terminal output that would be bash), e.g:

    [bash]
    /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
    [/bash]
	

To see a list of all the supported languages, please check this page.

If you want to include code bits inline, please use the code tags like in the following example:

    The <code>$USER</code> variable holds the current logged in username.
	

Secure your files

Dropbox

Recent Comments

  • Radu said:
    I think you have a corrupted archive. Try to download it again. more»
  • Ronny Ko said:
    I have a gigabit Dlink card ( D-Link System Inc DGE-530T Gigabit Ethernet Adapter (rev 11) (rev 11)). When I first run... more»
  • al.zatv said:
    Calin, thank you for your info. web face for virtualbox is the thing i was looking for. more»
  • djrise said:
    Hi and thank you for your job, I have downloaded the script but when i execute them it said : sh vmware-server-2.0.x-kernel-... more»
  • Xr said:
    Disabling vmci in the web access solved it: Select the VM–>ConfigurationR 11;>Advanced–>Conf iguration... more»

Recent Tweets

Geek blogs

Bear