LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 08-27-2005, 10:29 PM   #1
Four
Member
 
Registered: Aug 2005
Posts: 298

Rep: Reputation: 30
Getting pictures from webcam


How may I programaticly(preferably in c/c++) get pictures from a webcam on Linux?

Thanks in advance!
 
Old 08-27-2005, 11:48 PM   #2
Dave Kelly
Member
 
Registered: Aug 2004
Location: Todd Mission Texas
Distribution: Linspire
Posts: 213

Rep: Reputation: 31
Just courious, class project or do you like to reinvent the wheel?

I already have: camstream, camserv, webcam, vls, ffmpeg, mencoder, tvtime, xawtv, plus some video conference and video chat that I never have fired up.

So if you must, study the source code to all these.
 
Old 08-28-2005, 12:03 AM   #3
Four
Member
 
Registered: Aug 2005
Posts: 298

Original Poster
Rep: Reputation: 30
I just like to learn how things work, and also try things out . What I found interesting is that on Linux the image from the webcam looks alot better(Quality just like displayed on the box) than on Windows(I had to use lots of light to get equivilent quality).

The sources of those programs and many others are huge, I don't know where to look.

Also what I really want to do is make a simple shooting game with the webcam, simply point the webcam at the screen press a button and look for similar pixels, that are around the middle of the webcam image. I'm going to start with black & white game.
 
Old 08-28-2005, 02:19 PM   #4
Dave Kelly
Member
 
Registered: Aug 2004
Location: Todd Mission Texas
Distribution: Linspire
Posts: 213

Rep: Reputation: 31
Quote:
The sources of those programs and many others are huge, I don't know where to look.
I don't either and since I don't want to know I'm not going to look for you. I guess if it was easy we could get your girlfriend to do it for you.

K & R were the only ones who did not need to look something up because they were writing the language.

Quote:
Also what I really want to do is make a simple shooting game with the webcam, simply point the webcam at the screen press a button and look for similar pixels, that are around the middle of the webcam image. I'm going to start with black & white game.
If you do not understand the process of loading a file into a text editor and searching for keywords, can you explain how you would be able to figure out how it works from the many lines of code you are asking to be posted here?

If you will do the research then create the code and then run it and if you get some errors post the offending code snippet and list of errors we will help.
 
Old 08-28-2005, 03:07 PM   #5
aluser
Member
 
Registered: Mar 2004
Location: Massachusetts
Distribution: Debian
Posts: 557

Rep: Reputation: 42
I've done this in C and it was a bitch. http://alf.hopto.org/misc/wallclock.tgz is the whole project (it's supposed to read an anologue clock with a webcam and tell you the time, and it's got a crazy client/server structure... school assignment)

It works for the two cameras I tested it with (and there's code specific to each).

The relevant files are c/camera.[ch], c/YUV420PtoRGB.[ch], and c/RGBtoRGBA.[ch] .

There's also an example video4linux program we copied from somewhere in c/capture_image.c.

video4linux is the API you use to get images from a webcam with linux. It gives you different formats depending on the camera and you have to look up some cracked out way to decode them. That's what's in the YUV420PtoRGB and RGBtoRGBA files. It's possible that YUV420PtoRGB should have been named YUV420PtoRGBA; been a while since I did the project but I remember something like that.

Conclusion: for the love of god use somebody's code who's already done it right. Not mine either because it probably won't work for many different cameras. I'm hoping mine *is* slightly simpler so you can get the idea.
 
Old 08-28-2005, 07:19 PM   #6
Four
Member
 
Registered: Aug 2005
Posts: 298

Original Poster
Rep: Reputation: 30
Quote:
Also what I really want to do is make a simple shooting game with the webcam, simply point the webcam at the screen press a button and look for similar pixels, that are around the middle of the webcam image. I'm going to start with black & white game.
I already know how to do this part. Sorry if I made it sound like Iam looking for help on how to do this part too.

Iam currently looking at other peoples code, if theres a tutorial or something like that about webcam on Linux it would great.

Thank you!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How To Install A Usb Webcam [Genius WebCam on Suse 9.1 Personal] ofvergara Suse/Novell 4 11-29-2006 01:09 PM
Pictures brianthegreat Linux - Software 3 11-14-2005 01:16 PM
I want to veiw my friends webcam, im using Lycoris, how do i c his webcam? CaffeinatedGamer Linux - Newbie 10 06-07-2005 08:23 PM
user pictures mjjzf Mandriva 3 08-20-2004 05:11 PM
Taking pictures with webcam shinkm Linux - Newbie 1 01-13-2004 11:33 AM


All times are GMT -5. The time now is 04:51 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration