469,645 Members | 1,684 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,645 developers. It's quick & easy.

Webcam init and get

Hi there,
I need a simple and stupid few line source code to access my webcam.
I found lots of huge projects (c++ c and other) which are so big that
they are impossible to be used.
Does somebody know how to manage a webcam from it's basic functions?
Where can i find a SIMPLE, VERY SIMPLE example project?
Doesn't matter the what is the OS or the language, i just need it is
easy portable source code...
Jun 27 '08 #1
5 2744
In article <6b**********************************@a1g2000hsb.g ooglegroups.com>,
frakie <fr*******@gmail.comwrote:
>I need a simple and stupid few line source code to access my webcam.
I found lots of huge projects (c++ c and other) which are so big that
they are impossible to be used.
Does somebody know how to manage a webcam from it's basic functions?
Where can i find a SIMPLE, VERY SIMPLE example project?
Doesn't matter the what is the OS or the language, i just need it is
easy portable source code...
You will not be able to find "easy portable source code", as
not all systems provide enough functionality to be able to control
webcams, or provide the functionality in very different ways.
For example on the system I am using right now, it is possible to
add a webcam... if you add in a digital I/O board, the webcam
for which uses a 75 pin connector and transfers data in parallel.
Meanwhile there are ethernet based webcams and USB based webcams
and probably serial and parallel based webcams as well, all of which
need to be controlled in very different ways.

The most common webcams these days are ethernet based or USB based.

The ethernet based ones are often accessible via TCP -- which requires
that the system you are working on has a TCP stack, which is by no
means guaranteed (though it is getting increasingly common except in
some kinds of embedded systems.) The access to such systems is via
an HTTP transaction; that does not require a full HTTP library, but
does require an HTTP framework, complete with some MIME parsing.
Typically to get an image, you would issue an HTTP GET against
a particular file on the system and it would return it in encoded
form. But controlling the camera would generally require HTTP POST
transactions.

The USB cameras... well, those require a USB interface library,
which is going to be operating system dependant.
You might find that someone has written Perl modules and posted
them at cpan.org and you might find that those modules work
for all of the kinds of systems you are interested in. But then
you face the problem that installing Perl itself can be a bear of
a job if you have to install it from source.
--
"Any sufficiently advanced bug is indistinguishable from a feature."
-- Rich Kulawiec
Jun 27 '08 #2
On May 12, 6:03 pm, rober...@ibd.nrc-cnrc.gc.ca (Walter Roberson)
wrote:
In article <6bc54fd5-4290-4442-a004-a5c8e40f0...@a1g2000hsb.googlegroups.com>,

frakie <frakie...@gmail.comwrote:
I need a simple and stupid few line source code to access my webcam.
I found lots of huge projects (c++ c and other) which are so big that
they are impossible to be used.
Does somebody know how to manage a webcam from it's basic functions?
Where can i find a SIMPLE, VERY SIMPLE example project?
Doesn't matter the what is the OS or the language, i just need it is
easy portable source code...

You will not be able to find "easy portable source code", as
not all systems provide enough functionality to be able to control
webcams, or provide the functionality in very different ways.
For example on the system I am using right now, it is possible to
add a webcam... if you add in a digital I/O board, the webcam
for which uses a 75 pin connector and transfers data in parallel.
Meanwhile there are ethernet based webcams and USB based webcams
and probably serial and parallel based webcams as well, all of which
need to be controlled in very different ways.

The most common webcams these days are ethernet based or USB based.

The ethernet based ones are often accessible via TCP -- which requires
that the system you are working on has a TCP stack, which is by no
means guaranteed (though it is getting increasingly common except in
some kinds of embedded systems.) The access to such systems is via
an HTTP transaction; that does not require a full HTTP library, but
does require an HTTP framework, complete with some MIME parsing.
Typically to get an image, you would issue an HTTP GET against
a particular file on the system and it would return it in encoded
form. But controlling the camera would generally require HTTP POST
transactions.

The USB cameras... well, those require a USB interface library,
which is going to be operating system dependant.

You might find that someone has written Perl modules and posted
them at cpan.org and you might find that those modules work
for all of the kinds of systems you are interested in. But then
you face the problem that installing Perl itself can be a bear of
a job if you have to install it from source.
--
"Any sufficiently advanced bug is indistinguishable from a feature."
-- Rich Kulawiec
Thank you very very much Walter!
I know there must be an interface to interact with, but everything I
found is really too confusing since each project is adding more
functions than just init and getImage...
I will try cpan.org Perl module, and I'll tell you! Really thanks!
Jun 27 '08 #3
frakie *<frakie...@gmail.comwrote:
>I need a simple and stupid few line source code to access my webcam.
>I found lots of huge projects (c++ c and other) which are so big that
>they are impossible to be used.
>Does somebody know how to manage a webcam from it's basic functions?
>Where can i find a SIMPLE, VERY SIMPLE example project?
>Doesn't matter the what is the OS or the language, i just need it is
>easy portable source code...
You might also want to look at Gstreamer. While the framework is
portable, I don't know about webcam support for operating systems
other than Linux (v4l2src worked great for me in some project).
The big advantage is that changing from reading webcam stream to
reading video file is just a few lines (and this can be very useful in
testing!).

Domen
Jun 27 '08 #4
On 2008-05-12, frakie <fr*******@gmail.comwrote:
Hi there,
I need a simple and stupid few line source code to access my webcam.
I found lots of huge projects (c++ c and other) which are so big that
they are impossible to be used.
Does somebody know how to manage a webcam from it's basic functions?
Where can i find a SIMPLE, VERY SIMPLE example project?
Doesn't matter the what is the OS or the language, i just need it is
easy portable source code...
You could consider using libavdevice from ffmpeg, video4linux and
video4windows should be supported, it is plain and portable C (but not
trivial to use, but that's the price you have to pay to deal with
multimedia).

Regards.
--
Stefano Sabatini
Linux user number 337176 (see http://counter.li.org)
Jun 27 '08 #5
In article <sl*****************************@geppetto.reilabs. com>,
Stefano Sabatini <st**************@santefisi.caos.org.invalidwrot e:
>On 2008-05-12, frakie <fr*******@gmail.comwrote:
>I need a simple and stupid few line source code to access my webcam.
>You could consider using libavdevice from ffmpeg, video4linux and
video4windows should be supported, it is plain and portable C (but not
trivial to use, but that's the price you have to pay to deal with
multimedia).
http://cekirdek.pardus.org.tr/~ismai...8c-source.html

#include "config.h"
#include "libavformat/avformat.h"
#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/time.h>
#include <asm/types.h>
#include <linux/videodev2.h>
#include <time.h>
That's not portable C !

C89 3.8.2 Source File Inclusion
[...]
There shall be an implementation-defined mapping between the
delimited sequence and the external source file name. The
implementation shall provide unique mappings for sequences
consisting of one or more letters (as defined in 2.2.1) followed
by a period (.) and a single letter. The implementation may ignore
distinctions of alphabetical case and restrict the mapping
to six significant characters before the period.
Now "libavformat/avformat.h" has more than six significant characters
before the period, so which, if any, file that will map to is
implementation-defined -- and thus not portable C.
--
"I like to build things, I like to do things. I am having
a lot of fun." -- Walter Chrysler
Jun 27 '08 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Kelowna | last post: by
4 posts views Thread by Joakim Rylander | last post: by
reply views Thread by Elp | last post: by
4 posts views Thread by Mathieu Chavoutier | last post: by
reply views Thread by Steve | last post: by
10 posts views Thread by aceto | last post: by
3 posts views Thread by DillonCzerny | last post: by
2 posts views Thread by =?Utf-8?B?d29vZHliZWFy?= | last post: by
13 posts views Thread by Berco Beute | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.