scan-manager -- python app for controlling tethered cameras

General discussion about software packages and releases, new software you've found, and threads by programmers and script writers.

Moderator: peterZ

Post Reply
og200
Posts: 62
Joined: 26 Mar 2012, 15:38
E-book readers owned: Kindle
Number of books owned: 2000
Country: UK
Location: Oxford, United Kingdom

scan-manager -- python app for controlling tethered cameras

Post by og200 »

I've put my code for 'scan-manager' up on google code (http://code.google.com/p/scan-manager/) -- a simple Windows GUI app for controlling tethered cameras (Canon compact cameras with some old code which supports Nikon DSLRs).

The app is windows-only because it is tied to the windows tethering libraries (Canon and Nikon). I wanted to be able to show real-time video previews (the small window in the top left of the screenshot) so gphoto was not really an option. It needs Python 2.7 + wxPython installed.

It works for me (with a single A640 on a copy stand for now) but will probably be more useful to others as example code for controlling tethered cameras rather than as a complete application. It should be simple to update it to use two cameras and I plan to do that (for Canon) at some point in the next few months. I'll post here when that's done. The code for controlling the cameras is reasonably clean and nicely pythonic, though not well commented or documented (something I'll try to rectify in future).

http://youtu.be/cTCpmW0NNhE
Screenshot from scan-manager
Screenshot from scan-manager
Last edited by og200 on 27 Mar 2012, 13:54, edited 2 times in total.
User avatar
Gerard
Posts: 154
Joined: 17 Oct 2010, 07:15
Number of books owned: 0
Location: Berlin (Germany)

Re: scan-manager -- python app for controlling tethered came

Post by Gerard »

Nice
where did you found the "windows tethering libraries" for python, currently i'am writing a similar application for chdk enabled cameras (small cameras does not have a build in tethering feature)
my long term plan is to write something with a plugin structure for different image sources (chdk cams, ptp, proprietary sdk, android, webcam, eye-fi, sd-card reader), i don't wont to write all this plugins but someone how has this kind of image-source will maybe

ptpcamgui and chdkptp has similar feature but for chdk enabled cameras (you should have a lock on it, it could give you some inspiration)
og200
Posts: 62
Joined: 26 Mar 2012, 15:38
E-book readers owned: Kindle
Number of books owned: 2000
Country: UK
Location: Oxford, United Kingdom

Re: scan-manager -- python app for controlling tethered came

Post by og200 »

Gerard wrote:where did you found the "windows tethering libraries" for python
The tethering libraries are (or were) available directly from Canon and Nikon -- you need to sign up as an SDK developer with them and they'll send you the DLLs and documentation. There's nothing specific for Python -- I wrote Python wrappers using the built-in ctypes library which allows you to access extrenal DLLs and has facilities work working with structs, pointers, etc. (You can see this if you browse the source on my google code project.)

This Canon wrappers (PS-ReC) work with compact cameras (e.g. my A640s). The SDK lists the following cameras as supported:
PowerShot A620
PowerShot S80
PowerShot S3 IS
PowerShot G7
PowerShot A640
PowerShot S5 IS
PowerShot G9
PowerShot SX100 IS
PowerShot G10
PowerShot SX110 IS
Information on Canon's PS-ReC SDK is available here: https://www.developers.canon-europa.com ... endocument -- it's no longer supported so new camera's won't be added, unfortunately. It's a shame that Canon stopped develpoing this but they presumably want to force people to upgrade to EOS to do tethered shooting.

I haven't written code for Canon's EOS cameras but there's an SDK for these here: http://www.didp.canon-europa.com/ and you could probably write wrapper code for these too. I don't know how similar the API is -- I suspect it's rather different.

For Nikon I only have the SDK for the D80 but other cameras could be made to work if you download the correct SDK modules. Nikon's SDKs are available here:https://sdk.nikonimaging.com/apply/
Gerard wrote:ptpcamgui and chdkptp has similar feature but for chdk enabled cameras (you should have a lock on it, it could give you some inspiration)
The CHDK-based PTP stuff is very interesting. I came across it some time ago while I was tinkering with this stuff and it was rather too 'alpha' to be usable but it looks like progress is being made. I suspect this might be the way to go and I'll keep an eye on it and maybe give it a try. If it looks feasible I'd certainly be interested in building a Python wrapper.
User avatar
Gerard
Posts: 154
Joined: 17 Oct 2010, 07:15
Number of books owned: 0
Location: Berlin (Germany)

Re: scan-manager -- python app for controlling tethered came

Post by Gerard »

it's a pity but the cam that are very cheap (e.g. my PowerShoot A494) are not on the list, sometimes i'am regrading it that i dind not spend more on cams, for now i'am stuck with my a495 and a chdk solution
if you wont 3 seconds (this is how fast i can turn the pages) between shooting and also have downloading at the same time, than you need some special tricks, but you are right, is is alpha software, i've run in a lot of race conditions, memory leeks and other not describable problems

i've already wrote an python wrapper for ptpcam (ptpcam (with chdk patches) is an cli application), but is is still a lot of work to do

Code: Select all

#!/usr/bin/python

import os
import subprocess
from subprocess import PIPE
import re
import threading 
import time
import sys


ptpcam_exec=os.path.expandvars("$HOME")+"/Dokumente/robo-chdk/chdk-de/tools/ptpcam/ptpcam"

class PtpcamPipe:
    def __init__(self, bus, dev): 
        self.bus = bus
        self.dev = dev
        args = [ptpcam_exec, "--bus=%s"%self.bus, "--dev=%s"%self.dev, "--chdk"]
        self.subp = p=subprocess.Popen(args, shell=False, stdin=PIPE, stdout=PIPE, stderr=PIPE)
        
    def call(self, cmd):
        self.subp.stdin.write(cmd)
        self.output = self.subp.stdout.readline()
        
    def write(self, cmd):
        self.subp.stdin.write(cmd)
        self.output = []


    
def getptpcamsPipe():
    ptpcam_output = subprocess.check_output([ptpcam_exec, "-l"])
    ptpdevmatch = re.findall(b'^([0-9]{3})/([0-9]{3})\s*0x[^/]*/0x\S*', ptpcam_output, re.MULTILINE)
    noptpdev = re.search(b'Found no PTP devices', ptpcam_output)
    if noptpdev:
        return []
    ptpcam_list=[]
    for (bus,dev) in ptpdevmatch:
        ptpcam_list.append(PtpcamPipe(bus.decode(), dev.decode()))
    return ptpcam_list
og200
Posts: 62
Joined: 26 Mar 2012, 15:38
E-book readers owned: Kindle
Number of books owned: 2000
Country: UK
Location: Oxford, United Kingdom

Re: scan-manager -- python app for controlling tethered came

Post by og200 »

The CHDK PTP stuff, particularly with the live view patch, looks promising, though the list of cameras it seems to support is even more limited than the PS-ReC SDK at the moment (but at least it's growing).

From the CHDK site it looks like there are only a few cameras that have CHDK binaries with PTP available: A480, A570, A590, A610, A710, A720, IXUS700IS/SD500, SX1, SX10, SX200IS. Is that right? If the list grows to include any cameras I actually have (A640 and IXUS 105/SD1300 IS) I'll try to write a full Python wrapper for a dll based on CHDKPTP or similar (which could support live view and certainly some fine-grained control of camera settings). I've been looking at the code here http://www.assembla.com/spaces/chdkptp/ ... rsion_tool and wrapping some of it seems feasible.
User avatar
Gerard
Posts: 154
Joined: 17 Oct 2010, 07:15
Number of books owned: 0
Location: Berlin (Germany)

Re: scan-manager -- python app for controlling tethered came

Post by Gerard »

og200 wrote:The CHDK PTP stuff, particularly with the live view patch, looks promising, though the list of cameras it seems to support is even more limited than the PS-ReC SDK at the moment (but at least it's growing).

From the CHDK site it looks like there are only a few cameras that have CHDK binaries with PTP available: A480, A570, A590, A610, A710, A720, IXUS700IS/SD500, SX1, SX10, SX200IS. Is that right?
i think all chdk autobuilds (binaries) have ptp support, my A495 has definitely ptp support and it one of the low end cams (i bought my for 50€ new)
but live view is an other topic, for me it was to early and since i'm using linux most of the tutorials are not straight forward
og200
Posts: 62
Joined: 26 Mar 2012, 15:38
E-book readers owned: Kindle
Number of books owned: 2000
Country: UK
Location: Oxford, United Kingdom

Re: scan-manager -- python app for controlling tethered came

Post by og200 »

Gerard wrote:i think all chdk autobuilds (binaries) have ptp support, my A495 has definitely ptp support and it one of the low end cams (i bought my for 50€ new)
but live view is an other topic, for me it was to early and since i'm using linux most of the tutorials are not straight forward
Ah yes -- you're right, I should read the whole page before posting, the PTP stuff is apparently in the trunk now so it should be built in as standard. I don't know about live view though and I'll investigate further. I'll look into this more in a few weeks once I've built my new scanner.
User avatar
daniel_reetz
Posts: 2812
Joined: 03 Jun 2009, 13:56
E-book readers owned: Used to have a PRS-500
Number of books owned: 600
Country: United States
Contact:

Re: scan-manager -- python app for controlling tethered came

Post by daniel_reetz »

This is a very-often requested feature and a unique approach to implementing it. I think you'll find it has uses outside this community. Thank you for coding this and for sharing it with us.
Fab52
Posts: 63
Joined: 21 Feb 2012, 21:10
Number of books owned: 0
Country: Canada
Location: Montreal South Shore, Quebec, Canada

Re: scan-manager -- python app for controlling tethered came

Post by Fab52 »

Hi,

Thanks for sharing this stuff, I'm not a programmer or a computer wiz, but I know we need a capture software to make sure the first part of the process is done right. This kind of software will save us process time done the road.
It should be simple to update it to use two cameras and I plan to do that (for Canon) at some point in the next few months. I'll post here when that's done.
Hummmm!!! this seem the weird part of the process....

Tethered one camera seem relatively easy if we 're talking about DSLR camera, but trying to tethered two cameras and see a split screen image of the two and control both cameras seems to be GURU stuff....

I only find two commercials software able to this kind of work, do I have to name it ????

Today I do a 9 to 5 search on the web to see how I could have two nikons D90 camera tethered....

The answer: .............................................................. None.

Yousston (Houston) we have a problem !!!!

But in the process I learn stuff for sure...

Hey!!! I do not lost my saturday doing this 9 to 5 ....

One of the commercial scanner manufacturer say in their hardware description the following:

Workstation • Kirtas Image Server
• Two Quad Core 2.33 GHz Intel Xeon processors
• 8 GB DDR2 ECC SDRAM
• Four Hitachi 1 TB hard drives
(RAID 0, 1, 5, or 10 for storage)
• Windows SERVER 64-bit
• 19” flat screen monitor
• Two PC camera controllers Included

Humm! Why a Window 64 bit SERVER???

What is the use for this ??? "Two PC camera controllers"

See you

Fab
og200
Posts: 62
Joined: 26 Mar 2012, 15:38
E-book readers owned: Kindle
Number of books owned: 2000
Country: UK
Location: Oxford, United Kingdom

Re: scan-manager -- python app for controlling tethered came

Post by og200 »

If people are interested in tethered shooting then a simple frontend app like the one above with pluggable camera/SDK backends would be a good thing to work on together. I would see it supporting the control of basic camera settings for 1 or 2 cameras, with or without live view, plus, of course, capturing the files direclty to disk rather than to the SD card. The backends would be abstracted from the main code and should be easy enough to hack about with so that people with different camera models can test and modify the different SDKs.

I'm still thinking about camera APIs and there seems to be a wide range of choices. The two main options seem to me to be a) to use some generic layer or API (probably Linux support only); and b) to use manufacturer-specific APIs (which would limit us to Windows for many models).

Generic Methods

libgphoto2 [Linux only, wide camera support out of the box with live view, well tested]
Supporting libgphoto2 on Linux whould be easier than all separate manufacturer APIs and it does support live view for many cameras (see http://gphoto.org/doc/remote/). This would be a quick route to a linux app with wide camera support. There is a python wrapper https://github.com/alexdu/piggyphoto/ur ... m/p/pyptp/. They do not seem well supported however and would probably need significant modification to work with

CHDK-based PTP protocol [Windows, MacOS, Linux] [Multiple cameras: unknown but seems likely]:
URL: http://chdk.wikia.com/wiki/PTP_Extension (N.B. this page is out of date -- the PTP code is now in the CHDK trunk)
Potentially any camera supporting CHDK (not all may support PTP and not all of these will support live view -- AFAIK live view code is not in the CHDK trunk but is available for some cameras and should be somewhat portable).


Manufacturer APIs

I've done some searching for the various available APIs for Canon, Nikon and Olympus. Here's a summary below. Potentially, remote capture is possible on most of these cameras and live view (i.e. seeing the viewfinder/LCD image live in a window on the PC before shooting) is possible for many of them. I'm not clear on which SDKs have a problem supporting multiple cameras but this should be possible for many models -- see e.g. NKRemote/PSRemote/DSLRRemote from Breeze systems http://www.breezesys.com/products.htm which seem to use manufacturer SDKs and support multiple cameras.

Olympus SDK [Windows] [Multiple cameras: yes for all current cameras except E-1 and E-300]:
URL: http://developer.olympus.com/cameras_25.html
Current: E-3, E-30, E-620, E-520, E-510, E-500, E-450, E-420, E-410, E-400, E-330, E-300, E-1
Discontinued v3.4: C-8080 Wide Zoom,C-7070 Wide Zoom, C-7000 Zoom, C-70 Zoom, C-5060 Wide Zoom*, C-5050 Zoom*, C-4040 Zoom, C-4000 Zoom, C-4100 Zoom,
C-3040 Zoom, C-3020 Zoom, C-3100 Zoom, C-2040 Zoom, C-765 Ultra Zoom, C-760 Ultra Zoom, C-750 Ultra Zoom*, C-740 Ultra Zoom*, C-730 Ultra Zoom, C-700 Ultra Zoom, D-40 Zoom,
C-40 Zoom, C-21, E-100 RS, SP-700, SP-500 Ultra Zoom*, SP-350 Zoom*, FE-130/X-720, D-595/C-500 Zoom,
Discontinued v2.0: D-360L/C-860, D-460Z/C-960Z, D-490Z/C-990Z, C-211 Zoom, C-2100 Ultra Zoom, C-3000 Zoom, C-3030 Zoom,
Discontinued v1.5: D-220L/C-420L, D-320L/C-820L, D-340L/C-840L, D-340R/C-830L, D-400Z/C-900Z, D-450Z/C-920Z, C-2000 Zoom, C-2020 Zoom, D-500L/C-1000L, D-600L/C-1400L, D-620L/C-1400XL

Nikon SDK [Windows, MacOS] [Multiple cameras: unkonwn but seems likely]:
URL: https://sdk.nikonimaging.com/apply/
D5100, D3, D300, D300S, D3S, D3X, D700, D7000, D90, D5000, D40, D60, D80

Canon PS-ReC SDK (no updates) [Windows] [Multiple cameras: unkonwn but seems likely]:
URL: http://www.didp.canon-europa.com AND https://www.didp.canon-europa.com/devel ... nformation
PowerShot A620, PowerShot S80, PowerShot S3 IS, PowerShot G7, PowerShot A640, PowerShot S5 IS, PowerShot G9, PowerShot SX100 IS, PowerShot G10, PowerShot SX110 IS

Canon ED-SDK (current) [Windows] [Multiple cameras: unkonwn but seems likely]:
URL: http://www.didp.canon-europa.com AND https://www.didp.canon-europa.com/devel ... nformation
EOS 450D, EOS 1D Mark II, EOS 20D, EOS 1Ds Mark II, EOS 350D, EOS 5D, EOS 1D Mark II N, EOS 30D, EOS 400D, EOS 1D Mark III, EOS 40D, EOS 1Ds Mark III

Canon CD-SDK (old) [Windows] [Multiple cameras: unkonwn]:
URL: http://www.didp.canon-europa.com AND https://www.didp.canon-europa.com/devel ... nformation
PowerShot Pro1, PowerShot G6, PowerShot G5, PowerShot G3, PowerShot G2, PowerShot G1, PowerShot S2 IS, PowerShot S1 IS, PowerShot S70, PowerShot S60, PowerShot S5, PowerShot S45, PowerShot S40, PowerShot S30, PowerShot Pro90 IS, PowerShot A95, PowerShot A85, PowerShot A80, PowerShot A75, PowerShot A70, PowerShot A60, PowerShot A520, PowerShot A510, PowerShot A40, PowerShot A30, PowerShot A20, PowerShot A10, PowerShot A400, PowerShot A310, PowerShot A300, PowerShot A300, PowerShot A100, DIGITAL IXUS 500, DIGITAL IXUS 400, DIGITAL IXUS 430, DIGITAL IXUS 330, DIGITAL IXUS 300, DIGITAL IXUS, DIGITAL IXUS v3, DIGITAL IXUS v2, DIGITAL IXUS v, DIGITAL IXUS IIs, DIGITAL IXUS II
(these cameras do not support remote capture: DIGITAL IXUS 700, Digital IXUS 55, DIGITAL IXUS 50, DIGITAL IXUS 40, DIGITAL IXUS 30, DIGITAL IXUS i5, DIGITAL IXUS i, PowerShot S20, PowerShot S10)

Canon RC-SDK (old) [Windows]:
URL: http://www.didp.canon-europa.com AND https://www.didp.canon-europa.com/devel ... nformation
EOS-1D Mark II N, EOS-1D MarkII, EOS 1Ds Mark II, EOS 1Ds, EOS-1D, EOS 5D, EOS 20D, EOS 10D, EOS 350D, EOS 300D, EOS D60, EOS D30


There is also a comparison of commercial and free tethered shooting software here: http://thephotogeek.com/choosing-nikon- ... -software/
Post Reply