# Reading images from WebCam

**URL:** <https://discourse.libsdl.org/t/reading-images-from-webcam/13237>\
**Category:** SDL Development\
**Created:** [April 12, 2006, 4:03pm UTC](https://discourse.libsdl.org/t/reading-images-from-webcam/13237 "2006-04-12T16:03:42Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Romulo\_Gnomo](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/romulo_gnomo/32/335_2.png) [@Romulo\_Gnomo](https://discourse.libsdl.org/u/Romulo_Gnomo)\
**Post date:** [April 12, 2006, 4:03pm UTC](https://discourse.libsdl.org/t/reading-images-from-webcam/13237/1 "2006-04-12T16:03:42Z")

</div>

Hi, I am starting a project wich involves taking pictures of the web-cam and  
analyzing it in realtime (or the most near to it I can get), I would really  
like to use SDL on this project, so here are some questions before I begin:

Is there anyway to get the images from a “windows” web-cam using sdl? If it  
works on linux and mac it better, but not necessary.

Is it a simples/easy way?

What so you think would be the best way to do it? I need speed because  
images will be analyzed in realtime.

Sorry if this is posted twice, I don’t know if it worked the last time.  
Thanks in advance.

---

<div class="post-metadata">

**Author:** ![Simon3](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/s/dec6dc/32.png) [@Simon3](https://discourse.libsdl.org/u/Simon3)\
**Post date:** [April 12, 2006, 9:34pm UTC](https://discourse.libsdl.org/t/reading-images-from-webcam/13237/2 "2006-04-12T21:34:28Z")

</div>

A friend of mine had started working on a small (pornographic, shhh)  
website that was supposed to include webcams for public/private  
viewing. In his design, the webcam just takes a number of shots  
(images) and puts them on the disk, his tool then take them from there  
and do whatever it wants with the newly created image. I’ll ask him  
how he got to make the camera output image files on disk, and it was  
on windows, not sure if it would be a portable way of dealing with  
webcams.

I’m also interested in webcams, not for building entertainment  
websites, but rather for image analysis. I’m also developping a  
device that will gather the distance-to-image from some sort of robot,  
applied to the realtime image it could yield a 3D view of what the  
robot sees. Anyway, haven’t got a clue how to talk to webcams but  
I’ll be working on it. I’ll post anything I find here, can you do the  
same?

Thanks,  
SimonOn 4/12/06, Romulo Gnomo wrote:

> Hi, I am starting a project wich involves taking pictures of the web-cam and  
> analyzing it in realtime (or the most near to it I can get), I would really  
> like to use SDL on this project, so here are some questions before I begin:
> 
> Is there anyway to get the images from a “windows” web-cam using sdl? If it  
> works on linux and mac it better, but not necessary.
> 
> Is it a simples/easy way?
> 
> What so you think would be the best way to do it? I need speed because  
> images will be analyzed in realtime.
> 
> Sorry if this is posted twice, I don’t know if it worked the last time.  
> Thanks in advance.

---

<div class="post-metadata">

**Author:** ![Romulo\_Gnomo](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/romulo_gnomo/32/335_2.png) [@Romulo\_Gnomo](https://discourse.libsdl.org/u/Romulo_Gnomo)\
**Post date:** [April 13, 2006, 3:33am UTC](https://discourse.libsdl.org/t/reading-images-from-webcam/13237/3 "2006-04-13T03:33:56Z")

</div>

Yes, of course! I trying somethings with image processing too. If I discover  
something I’ll post here for sure. So this is our deal, let’s share  
knowledge and work togheter, if it is ok to you I think we should even share  
code or develop together. Thanks in advance, you are the fisrt person to  
show some interest in this subject when I exposed it.

---

<div class="post-metadata">

**Author:** ![Simon3](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/s/dec6dc/32.png) [@Simon3](https://discourse.libsdl.org/u/Simon3)\
**Post date:** [April 13, 2006, 4:00am UTC](https://discourse.libsdl.org/t/reading-images-from-webcam/13237/4 "2006-04-13T04:00:29Z")

</div>

> Yes, of course! I trying somethings with image processing too. If I discover  
> something I’ll post here for sure. So this is our deal, let’s share  
> knowledge and work togheter, if it is ok to you I think we should even share  
> code or develop together. Thanks in advance, you are the fisrt person to  
> show some interest in this subject when I exposed it.

As this is not exactly related to SDL, we’ll continue by email…  
however, we may come back with a brand new “SDL\_webcam.h” include for  
you guys! 😉

Romulo, I’ll ask my friend what he has found so far and I’ll share  
that with you later by email…

Simon

---

<div class="post-metadata">

**Author:** ![Chris\_Mendoza](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/c/ea666f/32.png) [@Chris\_Mendoza](https://discourse.libsdl.org/u/Chris_Mendoza)\
**Post date:** [April 13, 2006, 4:24am UTC](https://discourse.libsdl.org/t/reading-images-from-webcam/13237/5 "2006-04-13T04:24:41Z")

</div>

Hey there,

Just before this conversation goes private, you might want to check this:

[http://www.iua.upf.es/mtg/reacTable/?portvideo](http://www.iua.upf.es/mtg/reacTable/?portvideo)

It is a cross-platform SDL based video capture lib. I’ve had success with it  
in OS X and Windows, but I can’t vouch for its Linux talents.

Hope that helps,

c.On 4/13/06 12:00 AM, “Simon” \<simon.xhz at [gmail.com](http://gmail.com)\> wrote:

> > Yes, of course! I trying somethings with image processing too. If I discover  
> > something I’ll post here for sure. So this is our deal, let’s share  
> > knowledge and work togheter, if it is ok to you I think we should even share  
> > code or develop together. Thanks in advance, you are the fisrt person to  
> > show some interest in this subject when I exposed it.
> 
> As this is not exactly related to SDL, we’ll continue by email…  
> however, we may come back with a brand new “SDL\_webcam.h” include for  
> you guys! 😉
> 
> Romulo, I’ll ask my friend what he has found so far and I’ll share  
> that with you later by email…
> 
> Simon
> 
> * * *
> 
> SDL mailing list  
> SDL at [libsdl.org](http://libsdl.org)  
> [http://www.libsdl.org/mailman/listinfo/sdl](http://www.libsdl.org/mailman/listinfo/sdl)

---

<div class="post-metadata">

**Author:** ![Romulo\_Gnomo](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/romulo_gnomo/32/335_2.png) [@Romulo\_Gnomo](https://discourse.libsdl.org/u/Romulo_Gnomo)\
**Post date:** [April 13, 2006, 5:47pm UTC](https://discourse.libsdl.org/t/reading-images-from-webcam/13237/6 "2006-04-13T17:47:02Z")

</div>

Thanks a lot man! I think this should solve most of our problems. Your help  
will be very usefull.

---

<div class="post-metadata">

**Author:** ![icculus](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/icculus/32/81_2.png) [@icculus](https://discourse.libsdl.org/u/icculus)\
**Post date:** [April 13, 2006, 6:35pm UTC](https://discourse.libsdl.org/t/reading-images-from-webcam/13237/7 "2006-04-13T18:35:57Z")

</div>

> Yes, of course! I trying somethings with image processing too. If I  
> discover something I’ll post here for sure. So this is our deal, let’s  
> share knowledge and work togheter, if it is ok to you I think we should  
> even share code or develop together. Thanks in advance, you are the  
> fisrt person to show some interest in this subject when I exposed it.

There isn’t a cross-platform way to get webcam data. You’ll need to use  
the v4l2 API on Linux, and (uh…) something else on other platforms.

Mac, Linux, and Windows all have ways to get this info, just no unified way.

–ryan.

---

<div class="post-metadata">

**Author:** ![icculus](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/icculus/32/81_2.png) [@icculus](https://discourse.libsdl.org/u/icculus)\
**Post date:** [April 13, 2006, 6:39pm UTC](https://discourse.libsdl.org/t/reading-images-from-webcam/13237/8 "2006-04-13T18:39:23Z")

</div>

> Mac, Linux, and Windows all have ways to get this info, just no unified way.

(Except for portVideo, which I wasn’t aware of…thanks for pointing  
this out, Chris!)

–ryan.
