Thread: Getting information/data from USB devices.

  1. #1
    Registered User
    Join Date
    Jul 2007
    Posts
    16

    Getting information/data from USB devices.

    Hi all,

    I am trying to use a USB webcam to communicate with an engineering software; that is MATLAB: Simulink. I am trying to do so with the C S-Function. The C S-Function is a method that uses C programming as well but in a special format.

    Pointers can be used to refer to a memory address, get into it and retrieve the data. I have used Device Monitoring Studio and find that the endpoint address of the webcam is 0x82. So i tried to set a pointer with the address and retrieve the data.

    However i only get 0 values all the time. Can anyone explain where and what is wrong with my technique?

    Thanks in advance.

    ang_ks.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,656
    > and find that the endpoint address of the webcam is 0x82
    That's going to be the USB address, not the memory address.

    You can't simply do something like
    char *data = (char*)0x82;
    and expect to be able to read the camera data.

    Which operating system?
    Which compiler?
    Which webcam?

    Your best bet is to find a DLL (windows may already have one) which can read a frame from the webcam, and store that frame in memory. Your 'C' code then takes that image and reformats it into a form suitable for MATLAB.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Jul 2007
    Posts
    16
    Hi,

    No wonder it would not work.

    i am using windows XP SP2 with a real-time operating software installed.

    The compiler i am with MATLAB (a setting "mex -setup" to set up MATLAB to use the compiler) is Microsoft Visual Studio 2003.

    Webcam is Creative Webcam Live!

    About the DLL file, how do i find the right one? And how do i use it?

    An important point is i need the process to be in real-time.

    Thanks for the reply, Salem.

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,656
    I think Microsoft provide an API to interact with video devices on USB
    http://clusty.com/search?query=usb+c...Mozilla-search
    Though you'll need to do some digging by yourself (unless someone else wants to chip in).

    Moved to windows forum.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #5
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,195
    I believe the appropriate filters are in DirectShow to interface with webcams.

  6. #6
    Registered User
    Join Date
    Jul 2007
    Posts
    16
    I have been looking at some live video codes (actually i had these files for sometime). I only need the webcam.

    It is at codeproject website:

    http://www.codeproject.com/directx/LiveVideo.asp

    So i attempting to understand the codes and then implement into C S-Function in MATLAB: Simulink.

    I can't get to understand the whole picture and how the codes are actually working. Well, i can't deny that i've never been good at hardcore programming but i've been refreshing myself with tutorials.

    Can anyone advice me on an effective approach to study and understand the files?

  7. #7
    Registered User
    Join Date
    Mar 2007
    Location
    Bangor, Northern Ireland
    Posts
    6
    Hi ang_ks,

    There are some good tutorials on VFW at this site :- http://uk.geocities.com/ecafin/index.html They explain about capturing the Pixel array coming from a webcam etc, etc.

    Eric132

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting a List of the USB devices listed on the system
    By WDT in forum Windows Programming
    Replies: 11
    Last Post: 11-22-2009, 09:05 PM
  2. Accessing USB devices
    By deviousdexter in forum C# Programming
    Replies: 1
    Last Post: 01-24-2009, 09:48 PM
  3. Newbie problems after first linux install ever...
    By Leeman_s in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 01-24-2003, 03:04 PM
  4. Will linux support this hardware?
    By Leeman_s in forum Linux Programming
    Replies: 0
    Last Post: 01-19-2003, 01:30 PM
  5. Printers On USB
    By (TNT) in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 03-10-2002, 11:48 AM