Wikia

CHDK Wiki

PTP Extension

Talk0
571pages on
this wiki
Revision as of 00:48, February 11, 2014 by 83.161.211.11 (Talk)

The Picture Transfer Protocol (PTP) facilitates remote operations on a camera connected computer. Typical operations are uploading/downloading photos and remote captures.

Most cameras support some basic operations over PTP, but often only in a limited fashion. For example, downloading of files can be limited to just JPEG files.

The PTP extension for CHDK discussed in this article does not alter the standard operations but adds new CHDK-specific operations instead. This is due to the complexity involved in altering or complete overwriting the standard operations. It also means that special tools are required to access this new functionality.

If you want simple control over the camera without USB a protocol connection (for example, using a micro-controller or RC equipment) see USB Remote.

The CHDK extension was first added to the CHDK trunk in changeset 957, and has been enabled for all cameras since changeset 1116

Related forum thread: [1]

Functionality

An overview of the functionality available through the PTP interface is described below. The specific functionality and usage depends on which client application you use. The canonical reference to the CHDK PTP protocol is core/ptp.h in the CHDK source tree.

File transfer

Files can be uploaded to and downloaded from any part of the file system.

Script execution

The PTP interface allows execution of lua scripts sent over PTP. In general, any scripting function available to normal CHDK scripts can be executed remotely. See CHDK Scripting Cross Reference Page for a list of CHDK script functions. There are some additional functions specific to PTP, described in Lua/PTP Scripting.

Some of the features available using Lua scripts include

  • Switch to and from record mode
  • Switch recording modes, e.g. Av, Tv, Video
  • Adjust exposure parameters, focus, zoom etc.
  • Shoot pictures or video
  • Manipulate Canon menus and settings with simulated key presses
  • List, create and delete files and directories
  • Return values from script, send and receive arbitrary messages between the camera and PC
  • Shutdown or reboot the camera

Remote display

CHDK 1.1 add support streaming the contents of the camera LCD display over PTP. (revision 1921 and later)

Remote shooting

CHDK 1.2 added support for saving images directly over USB, without saving on the SD card. This is supported for raw and DNG on all cameras, and for jpeg on some cameras. For raw and DNGs capturing a subset of rows from the raw framebuffer is also supported.

Debugging features

  • Read and write camera memory
  • call arbitrary camera functions

LibUSB Driver for Windows

All the client applications below require libusb-win32 driver on Windows:

  • It is available for Windows 2000, Windows XP 32 Bit, Windows Vista 32/64 Bit, Windows 7 32/64 Bit.
  • Windows 8 users should read the following guide: How to install an unsigned driver on Windows 8
  • A useful note for Windows 8.1 users, refers to this site.
  • It should be installed as an INF Driver, NOT a Filter Driver.
  • It will most likely break your ability to download photos through Windows built-in Wizard, but you can still download files using the client applications below.

To install libusb-win32 on Windows:

  • Download the latest binary release from here
  • Extract archive
  • Connect camera via USB and turn on in Play mode
  • Let Windows install its built-in driver if not already installed
  • Run \bin\inf-wizard.exe from extracted archive
  • Select your camera from the list of attached USB devices
  • Hit Next and save the resulting INF file to a new folder
  • Hit Install Now...
  • It should appear in Device Manager as libusb-win32 devices > Canon Digital Camera
  • No PC reboot is needed

NOTES

  • The installed INF driver is specific to the selected model. If you use more than one camera model with CHDK PTP clients, you may need to install an INF driver for each one.
  • Depending on the camera, the INF driver installation may be specific to the particular physical USB port. In this case, plugging the camera into a different port will allow you to access the camera using normal windows software. This probably applies to older cameras (vxworks?)
  • You may be able to get the filter driver to work on some OSes (XP) but the INF driver is strongly recommended.

Client applications

As described above, a client program compatible that implements the CHDK protocol is required to access these features

ptpcam

Download:

1) download and install libusb (see install instructions above)
2) go here (German CHDK forum topic on the development of ptpcam with CHDK extensions)
3) download ptpcam_Vx.x.zip at the end of the first message.

The version of ptpcam available in the forum link has CHDK extensions added to communicate to the CHDK code on your camera. This is a derivative of the official ptpcam available at http://libptp.sourceforge.net/ (the CHDK extensions are not included in the official version of ptpcam).

f you are comfortable writing batch scripts (or perl/python/... scripts) for your PC, ptpcam can be used to download jpg files and upload lua scripts and execute CHDK lua scripts on your camera all while your camera is carefully lined up on your subject and mounted to a tripod (when, for most Canon cameras, removing the memory card is not possible).

Keep in mind the fact that commands sent to your camera via ptpcam will take more time to complete than it takes for ptpcam to return control to your script. So make sure that after you issue a ptpcam --chdk="blah blah" command, that you have inserted a delay in your (batch file, perl, ...) script running on your PC to give the camera time to finish its business before you go poking the camera again.

See PTP Extension/ptpcam Examples for some examples.

A version of ptpcam is maintained in the chdkde source tree, with builds available from the chdkde forum (download ptpcam_Vx.x.zip). The ptpcam executable may be built for Windows or Linux.

ptpCamGui

ptpCamGui is a graphical front end for ptpcam. Builds are available from the chdkde forum It's also part of CHDK Shell.

A forum thread including descriptions can you find here.

The source code for the frontend and the DLL is available on the ptpCamGui assembla project.

ptpCamGui is only available for Windows.

English translation of instructions for using can be found here. Note that despite coming from a German site, both English and German languages are supported in the same .exe and are set automatically (based on your Windows installation language setting).

First time users note that the big red camera icon is used both to enter camera mode and to shoot (when radio buttons to right select "Photo").

chdkptp

chdkptp is a client created specifically for controlling CHDK cameras. It provides CLI and optional GUI based on IUP.

chdkptp also provides a Lua API for the CHDK protocol on the PC. Because the GUI and CLI are also implemented in Lua, this makes chdkptp easy to extend and enables end users to implement complex interactions with code on the camera.

CHDK 1.1 remote display and CHDK 1.2 remote capture are supported.

Source and builds are available on the chdkptp assembla project. A thread in the chdk forum is available for support and discussion.

Build instructions are available in README.TXT in the source. Usage information is available in USAGE.TXT

chdkptp is currently considered pre-alpha because functionality and APIs are subject to change. However, the snapshot builds are generally stable and suitable for everyday use.

The chdkptp code is based on the CHDK fork of ptpcam, but it does not use the same commands or command line options.

Platforms

chdkptp is compatible with MS Windows, OSX and Linux on x86

Additional Platforms

In addition standard desktop environments, chdkptp builds are also available for the raspberry pi SBC.

Work is also on its way to get as least the CHDKPTP CLI running on an ODroid XU board and a BeagleBone Black

Helping out to make that a reality is apprcated, more inf on

and

Arch Linux

chdkptp package is available from AUR, see package page.

Usage notes

Windows

In order to get CHDK clients to work properly you might need to disable the "Canon Camera Access Library" service (or, if that doesn't work, the "WIA" service).

Linux

Make sure you've got access to USB; in some cases this means switching to root (or changing permissions). Some information can be found in this post: http://chdk.setepontos.com/index.php?topic=6231.msg89252#msg89252

If your distro's default configuration accesses the camera on connect, this may put the camera in a state where some functionality (such as switching to shooting mode) is not available, or prevent CHDK clients from accessing the camera.

FAQ

  • Download/upload fails with code 0x2ff or the camera crashes when you try to transfer a file
Perhaps you didn't correctly specify the file on the camera. Always use the full path and start with a capitalised 'A'. For example: "download A/DCIM/100CANON/IMG_1234.jpg test.jpg"
note this mainly applies to ptpcam, chdkptp corrects the names for you.
  • The canon firmware does not recognize key presses (real or from script) when PTP is connected
There are two known workarounds:
  • Switch to record mode using switch_mode_usb script function. Keys will still be enabled if you switch back to play.
  • On many DryOS cameras, post_levent_to_ui(4484) will also unlock the keys.

Development history

The original PTP Extension was contributed by mweerden. At mweerden's github one can find the original sources as well as a follow-up attempt at a minimal version for inclusion in the SVN trunk. The proposal version, with some minor modifications, has been included in CHDK trunk since changeset 957. ewavr made additional contributions, including the first "live view" functionality and GUI client. You can find files related to this work on ewavr's site.

The full history can be found in the PTP development thread on the forum.

Around Wikia's network

Random Wiki