supplierdeeply

Webcam operation

  • 13 Replies
  • 7560 Views
*

Offline fudgey

  • *****
  • 1705
  • a570is
  • Publish
    Webcam operation
    « on: 30 / November / 2008, 17:39:35 »
    Advertisements
    As I noted on another thread http://chdk.setepontos.com/index.php/topic,2686.0.html, limited webcam operation is now possible.

    I did a quick hack with patched Lua and gphoto2 on Ubuntu on my a570is. As is, the setup shoots an image approximately every 10 seconds and moves it out of the camera to the PC via USB (PTP).

    The scripts (lua and bash) and a help text are attached. Read the help file, Ubuntu needs some configuring to make it ignore the camera so that gphoto2 can use it directly.

    The way I did it Lua needs access to four new Canon firmware functions. It's pretty easy to crash the camera using them, so this all needs a lot of polishing before we can think of adding it to the trunk. That's one reason I haven't spend time prepared a patch for this.

    Additions required for a570is 1.00e are:

    platform/a570/sub/100e/stubs_entry_2.S:
    NHSTUB(PB2Rec, 0xffc119b8)
    NHSTUB(Rec2PB, 0xffc119f8)
    NHSTUB(ForceQuitPTPMode, 0xffd8e158)
    NHSTUB(RefreshUSBMode, 0xffd8df5c)

    include/lolevel.h:
    extern void _PB2Rec(void);
    extern void _Rec2PB(void);
    extern void _ForceQuitPTPMode(void);
    extern void _RefreshUSBMode(void);

    platform/generic/wrappers.c:
    void PB2Rec(void)
    {
      _PB2Rec();
    }
     
    void Rec2PB(void)
    {
      _Rec2PB();
    }
     
    void ForceQuitPTPMode(void)
    {
      _ForceQuitPTPMode();
    }

    void RefreshUSBMode(void)
    {
      _RefreshUSBMode();
    }

    include/platform.h:
    void PB2Rec(void);
    void Rec2PB(void);
    void ForceQuitPTPMode(void);
    void RefreshUSBMode(void);

    core/luascript.c:
    static int luaCB_PB2Rec( lua_State* L )
    {
      PB2Rec();
      return 0; 
    }
     
    static int luaCB_Rec2PB( lua_State* L )
    {
      Rec2PB();
      return 0; 
    }
     
    static int luaCB_ForceQuitPTPMode( lua_State* L )
    {
      ForceQuitPTPMode();
      return 0; 
    }

    static int luaCB_RefreshUSBMode( lua_State* L )
    {
      RefreshUSBMode();
      return 0;
    }

    core/luascript.c function register_lua_funcs()
      FUNC(PB2Rec);
      FUNC(Rec2PB);
      FUNC(ForceQuitPTPMode);
      FUNC(RefreshUSBMode);


    (after those modifications CHDK will of course not build for any other firmware due to missing stubs/dummy wrappers).

    I wanted to signal things from the PC by uploading a file after the PC script is done transferring, but sadly upload didn't work at all. Has anyone ever managed to upload files via USB to an a570is on any OS?

    *

    Offline fe50

    • ******
    • 3034
    • IXUS50 & 860, SX10 Star WARs-Star RAWs
      • fe50
  • Publish
    Re: Webcam operation
    « Reply #1 on: 30 / November / 2008, 17:56:37 »
    ...I wanted to signal things from the PC by uploading a file after the PC script is done transferring, but sadly upload didn't work at all. Has anyone ever managed to upload files via USB to an a570is on any OS?

    Hi fudgey,
    not on A570, but on a SD870 & SD400: for Windows there's Digicanon's firmware uploader: digicanon.narod.ru, you can upload files to the card's root via USB; it should work on all Canon P&S cams...
    It's described in the wikia FAQ, see also How to copy the CHDK firmware onto Canon Powershot S2 IS ? here in the forum.

    *

    Offline fudgey

    • *****
    • 1705
    • a570is
  • Publish
    Re: Webcam operation
    « Reply #2 on: 02 / December / 2008, 18:50:02 »
    Some progress... turned out simpler than I thought it would:

    1) power up in play mode
    2) connect USB cable to PC
    3) call PB2Rec()

    We are now in REC mode (a bit fuzzled up one but it's a REC mode), shooting works etc. But what's cool is that PTP transfers such as gphoto2 --list-files and gphoto2 --get-all-files work. None of that usb_magic RAM manipulation necessary as long as we start out this way from play mode.

    And what's even greater is that these file transfers seem to work even during (long) exposures and burst shooting!

    *

    Offline PhyrePhoX

    • *****
    • 2253
    • make RAW not WAR
      • PhyreWorX
  • Publish
    Re: Webcam operation
    « Reply #3 on: 02 / December / 2008, 18:51:49 »
    great news :)


    *

    Offline fudgey

    • *****
    • 1705
    • a570is
  • Publish
    Re: Webcam operation
    « Reply #4 on: 02 / December / 2008, 19:01:46 »
    Oh and some more.. the above requires a PC that doesn't auto detect and mount the camera instantly when plugged in. For my Ubuntu that means my previous hald disable workaround.

    But turns out that's not necessary with what I just said if we add a call to DisableNotificationPTP() to the procedure:


    1) power up in play mode
    2) call DisableNotificationPTP()
    3) connect USB cable to PC (camera appears on desktop)
    4) call PB2Rec()

    Camera is now usable by normal interactive shooting and scripts (some confusion to be expected, CHDK doesn't quite know we're in REC mode and possibly neither some parts of the camera; for example there's no CHDK osd until I switch the rec/play lever to rec mode too but then USB disconnects) and the camera is available on the PC's PTP explorer thingies, whatever your OS is using (I believe my Ubuntu is using libgphoto2 for mounting and viewing the camera's contents in nautilus, in Windows that would be something else but should work just the same).

    *

    Offline fudgey

    • *****
    • 1705
    • a570is
  • Publish
    Re: Webcam operation
    « Reply #5 on: 02 / December / 2008, 19:15:01 »
    I'm really starting to wish that PTP upload would work...

    If I'm not mistaken, it would then be possible to do things like use PTP and Lua to install scripts without removing the SD card... just run a Lua script (play mode should suffice for this) that monitors for uploads in some folder PTP is able to upload to and moves them to where they belong to, possibly according to a control file (which could be written in form of a Lua script as I believe Lua can run newly uploaded scripts if they're written in a way that can be require()'d?).

    Maybe even update CHDK binaries via USB?

    *

    Offline PhyrePhoX

    • *****
    • 2253
    • make RAW not WAR
      • PhyreWorX
  • Publish
    Re: Webcam operation
    « Reply #6 on: 02 / December / 2008, 19:46:33 »
    using gphoto i was able to move binary and other files onto the camera (DCIM folder though). but should be no problem moving them via lua to other directories... the binary can even be overwritten while chdk is booted (not tested though).
    this worked on s3is and imo on a620 as well.
    gphoto can send the files to the camera, but NOT display them (very confusing :D)

    *

    Offline fudgey

    • *****
    • 1705
    • a570is
  • Publish
    Re: Webcam operation
    « Reply #7 on: 03 / December / 2008, 14:22:34 »
    I've now tried uploading files on Windows Vista (which recognized the camera without 3rd party drivers and showed it as a removable device of a sort, much like Ubuntu), but it fails too.

    And yes, I tried uploading to DCIM and the Canon created directories under DCIM, I even only tried copying JPG files previously shot with the same camera. And I tried without card write protect, and I tried without CHDK. I'm really starting to think a570is doesn't support PTP upload one bit...  >:(


    *

    Offline silas

    • *
    • 19
  • Publish
    Re: Webcam operation
    « Reply #8 on: 23 / February / 2009, 14:36:21 »
    On my camera (a550) it works to upload whit the program camerawindow (from canon).

  • Publish
    SUCCESS
    « Reply #9 on: 21 / January / 2010, 21:53:00 »
    « Last Edit: 21 / January / 2010, 21:56:22 by delco »

     

    Related Topics