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. :)

You might also like:

41 Comments

1 2 3 4 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>


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.
	

Projects that I support

Recent Comments

  • nope said:
    yeah that was my first thought too, but: mount: warning: seems to be mounted read-write. too bad, would have been just perfect. more»
  • Klaus Deiss said:
    Dear Radu, I tried it on Ubuntu 10.0.4.2 and 10.0.4.3 with different kernel versions (amd64 server 2.6.32 kernel). No... more»
  • scompo said:
    Nope.. Now it’s not working again.. This printer it’s a real pain in the butt.. The other hp printer I had... more»
  • Dmitrij said:
    Thank you Peter and Patrice. Could you please post the updated script? more»
  • hd_flash_pains said:
    didn’t work for me more»

Recent Tweets

Bear