Webcam init and get

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • frakie

    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...
  • Walter Roberson

    #2
    Re: Webcam init and get

    In article <6bc54fd5-4290-4442-a004-a5c8e40f0414@a1 g2000hsb.google groups.com>,
    frakie <frakieack@gmai l.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 indistinguishab le from a feature."
    -- Rich Kulawiec

    Comment

    • frakie

      #3
      Re: Webcam init and get

      On May 12, 6:03 pm, rober...@ibd.nr c-cnrc.gc.ca (Walter Roberson)
      wrote:
      In article <6bc54fd5-4290-4442-a004-a5c8e40f0...@a1 g2000hsb.google groups.com>,
      >
      frakie <frakie...@gmai l.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 indistinguishab le 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!

      Comment

      • domen@coderock.org

        #4
        Re: Webcam init and get

        frakie  <frakie...@gmai l.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

        Comment

        • Stefano Sabatini

          #5
          Re: Webcam init and get

          On 2008-05-12, frakie <frakieack@gmai l.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)

          Comment

          • Walter Roberson

            #6
            Re: Webcam init and get

            In article <slrng3tfk7.a3j .stefano.sabati ni@geppetto.rei labs.com>,
            Stefano Sabatini <stefano.sabati ni@santefisi.ca os.org.invalidw rote:
            >On 2008-05-12, frakie <frakieack@gmai l.comwrote:
            >I need a simple and stupid few line source code to access my webcam.
            >You could consider using libavdevice from ffmpeg, video4linux and
            >video4window s 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).


            #include "config.h"
            #include "libavforma t/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 "libavforma t/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

            Comment

            Working...