Resolving vertically flipped images from webcams in Ubuntu
Posted on July 31st, 2009 at 1:53, in Code, How To, Linux, Ubuntu.
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:
- install VLC if you do not have it:
- download my script from here (right click, Save link as…) and make it executable:
- make sure you have the
build-essentialpackage: - run the script with super-user privileges from where you have downloaded it, providing the right options:
sudo apt-get install vlc
chmod +x flip_webcam
sudo apt-get install build-essential
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:
- go to Media
- then go to Open capture device…
- in the pop-up window that opens, in the “Video device name” text field, insert
/dev/video0 - 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:
- Flipped images from your webcam in Ubuntu?
- How to install VMware Server 2.0.x on Ubuntu 9.10 Karmic Koala
- How to install VMware Server 2.0.1 on Ubuntu 9.04 Jaunty Jackalope
- How to install VMware Server 2.0.2 on Ubuntu 9.04 Jaunty Jackalope
- How to install VMware Server on 2.6.31 kernels



40 Comments
KoKuToru said
on August 11th, 2009,
at 14:45 hours
Thanks a lot, it’s working
linkxs said
on August 24th, 2009,
at 00:12 hours
Sweet man, thanks! worked perfectly!
I’m really glad i found this
Unal said
on September 3rd, 2009,
at 15:19 hours
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..??
Radu said
on September 3rd, 2009,
at 15:32 hours
Hi Unal! Yes, it’s an error… Try installing
modeprobefirst. It’s very interesting why this program isn’t already installed in your system.Darkzeus said
on September 6th, 2009,
at 21:36 hours
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.
Radu said
on September 6th, 2009,
at 23:10 hours
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.
Tohia said
on September 10th, 2009,
at 09:08 hours
Brilliant! Took a while to download but worked like a charm.
ASUS K50IN-SX002C sous Ubuntu 9.04 « Les Consultations du Dr. Emixam said
on September 15th, 2009,
at 07:25 hours
[...] 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 [...]
Burak said
on October 3rd, 2009,
at 23:58 hours
this works great !! I’ve been trying to do this for a long time. thank you very much.
Radu said
on October 4th, 2009,
at 15:50 hours
You are welcome, Burak!
christoph said
on October 22nd, 2009,
at 21:56 hours
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!!
Radu said
on October 22nd, 2009,
at 21:57 hours
Thank you, Christoph!
ba2toot said
on October 25th, 2009,
at 15:46 hours
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?
Radu said
on October 25th, 2009,
at 16:40 hours
ba2toot, what is the output of
lsusbon your system? I get this on the first line:Does your webcam fail to function only in Ubuntu (Linux)?
ba2toot said
on October 25th, 2009,
at 17:08 hours
output is
i dont have a dual boot system on this machine (or any). and i know even less about getting things to work in virtualbox
ba2toot said
on October 25th, 2009,
at 17:12 hours
just checked, though: camera does not work ootb in virtualbox and windows hw assistant cant seem to find it. (winXP)
Also, it’s in none of the menus in virtualbox.
ba2toot said
on October 25th, 2009,
at 20:46 hours
IT WORKS!!!!! THNAKS VERY VERY MUCH!
Luca Béla Palkovics said
on October 31st, 2009,
at 12:28 hours
Is there a possibility that it wont work anymore on Ubuntu 9.10 ?
I tried it now 2 times and didn’t work..
Andrew said
on October 31st, 2009,
at 18:24 hours
I just tried it on a clean Ubuntu 9.10 desktop (Asus U6V laptop with built-in webcam) and it doesn’t work, both option 1 and 2. Scripts run fine, with no errors, but no change to the WebCam, it’s still upside-down.
My cam is:
Bus 002 Device 003: ID 04f2:b036 Chicony Electronics Co., Ltd
Any suggestions?
In any case, thank you for your effort, as you’ve helped quite a few people already.
Radu said
on November 1st, 2009,
at 13:16 hours
Hi Andrew… It’s been brought up to my attention that the script doesn’t work anymore and I’ve promised I will try to find a solution. I will start investigating now…
qw105 said
on November 5th, 2009,
at 16:53 hours
thanks a lot for this Post, waiting updates
Francesco said
on November 6th, 2009,
at 12:51 hours
Salut Radu,
ubuntu karmic with 2.6.31-14-generic kernel, when trying to compile patched module i obtain these errors:
Have you please some advice about that?
Radu said
on November 6th, 2009,
at 13:10 hours
Francesco, please follow the update from the post’s beginning.
Francesco Conti said
on November 6th, 2009,
at 15:22 hours
It was just my curiosity while I was waiting for Hans’s response to my notebook logs. Now I’ve tested a new version of its library and that’s alright.
mulțumesc
Radu said
on November 6th, 2009,
at 15:45 hours
You are welcome! I am glad that your webcam works. As I have written in the new post, the solution posted by me here – while it made the things work in Jaunty’s kernels – it’s not the best way to handle these problems. Hans’ way of fixing this is far more elegant and actually it’s the only way webcam problems should be fixed. Patching the kernel is not okay under these circumstances.
Mario Saleiro said
on November 9th, 2009,
at 04:38 hours
Hi! I have tested your patch with Karmic Koala and now the webcam doesn’t work anymore. I should have read the whole list of comments before testing it
Do you have any suggestion on how to at least restore the uvc driver so that the webcam may work again, even if it keeps upside down? Thanks in advance
Radu said
on November 9th, 2009,
at 12:54 hours
Mario, you should have followed the update written in bold at this post’s beginning.
To reinstall
uvcvideodo this:Then follow the update from here.
Flipped images from your webcam in Ubuntu? :: Fix them easily | Radu Cotescu's blog said
on November 14th, 2009,
at 22:18 hours
[...] certain laptop webcams on Ubuntu because some of them were mounted upside down. I have posted a solution for fixing this on the blog, but apparently it’s not quite the best way to obtain the desired [...]
christoph said
on November 19th, 2009,
at 22:34 hours
I’m back after having done my upgrade to 9.10. Which in itself was quite a nightmare:
1) The upgrade tentative ended badly with the system hanging with the Ubunutu logo sitting on the screen.
Never mind I thought, I’ll do a fresh install from scratch (this isn’t my main computer). That worked, but I wasn’t able to retrieve my user settings from the existing accounts?
Question: Any chance to find a working patch to the webcam problem, for the kernel in 9.10. Or should I revert to 9.04?
Radu said
on November 20th, 2009,
at 00:51 hours
Christoph, follow the update. It’s written with red and in bold at this post’s beginning.
Christoph said
on November 30th, 2009,
at 18:54 hours
Thanks Radu – following the instructions hepped me solving the problem – guess I was a bit too fast complaining ;-
semaphore said
on March 19th, 2010,
at 12:32 hours
Thanks so much – I got my webcam with patch 1 working:
ASUS X70AE
OpenSuSE 11.2
Webcam Model: Chicony Electronics Co., Ltd 2.0M UVC Webcam / CNF7129
Had to install devel(C/C++) pattern, kernel sources, kernel-firmware packages (as there is no nuild-essentials on SuSE).
Radu said
on March 19th, 2010,
at 13:55 hours
@semaphore: You should have followed the update where you don’t patch your kernel (which is inefficient) but install a library that handles the cameras mounted upside down.
semaphore said
on March 19th, 2010,
at 15:34 hours
@Radu: I did (the libv4l library is installed and gets pre-loaded), but it did not help with my type of camera (seems like it is not supported by the libv4l upside-down fix).
hunter said
on April 15th, 2010,
at 21:52 hours
how to unistall this ?
Radu said
on April 15th, 2010,
at 22:45 hours
Search for the module on your machine and simply delete so it won’t be loaded.
hunter said
on April 17th, 2010,
at 20:11 hours
can you show me where is the module ? i cant find it
Radu said
on April 17th, 2010,
at 23:54 hours
It should be located in
/lib/modules/[running kernel version]/kernel/drivers/media/.Geoff said
on July 3rd, 2010,
at 22:34 hours
Is there a way to make this work using Ubuntu 10.04?
Radu said
on July 4th, 2010,
at 12:12 hours
Is it so hard to follow the UPDATES? It’s not like they’re marked with a bold red font…
Think you've got something to say?
For leaving comments including source code or terminal output, please use the the following tags like in the next example:
where you substitutelanguagewith the programming laguage used throught the code example (for terminal output that would be bash), e.g:To see a list of all the supported languages, please check this page.
If you want to include code bits inline, please use the
codetags like in the following example: