0

I'm beginner in c++ programming and I'm starting to use Canon EDSDK 2.12 to remote control an EOS 600D DSLR. I used the code here to get a better understanding how to access camera and take a single picture and it works fine but now I'm not sure how to proceed with my program because I'm unable to figure out the possibilities of the SDK with the Programming Reference.

Is it possible to take a picture which is saved on the camaeras SD with a customized name?

if not

How do I have to create an event handler? I would like to get a string consisting of the image path on the SD (folder & image name as unique id) every time a picture is taken and do some other tasks with it.

I hope this helps to understand what I want to do.

Community
  • 1
  • 1
RichardR
  • 21
  • 4

2 Answers2

0

This is described in the SDK documentation, and is probably a bit late for you, but may be helpful for others.

To create an event handler you need to do something like the following some time after you have a camera reference and have opened a session:

Err = EdsSetObjectEventHandler( Camera, kEdsObjectEvent_All, HandleAllObjectEvents, NULL);

In response to the Canon SDK callback for an object event (i.e. in the HandleAllObjectEvents function) you could do something like:

switch ( inEvent ) {
    case kEdsObjectEvent_DirItemCreated:
        // new file created on camera card
        EdsDirectoryItemRef fileNameRef;
        EdsDirectoryItemRef folderNameRef;
        EdsDirectoryItemInfo fileNameInfo;
        EdsDirectoryItemInfo folderNameInfo;

        fileNameRef = (EdsDirectoryItemRef)inObject;
        EdsGetDirectoryItemInfo( fileNameRef, &fileNameInfo );  // got the file name and some other info
        EdsGetParent( fileNameRef, &folderNameRef );
        EdsGetDirectoryItemInfo( folderNameRef, &folderNameInfo );  // got the folder name

        char fname[100];
        strcpy( fname, folderNameInfo.szFileName );
        strcat( fname, "\\" );
        strcat( fname, fileNameInfo.szFileName );

As you know, getting the folder name is important if you are taking lots of photos, as the file name rolls over from IMG_9999.jpg to IMG_0000.jpg, and the files are put into a new folder (e.g. from 100CANON to 101CANON. Just using the file name does not guarantee a unique name.

Peter
  • 1
-1

I can think of several solutions.

  1. Windows has an API (FindFirstChangeNotification and FindNextChangeNotificaton) that allows you to detect changes in a directory. Just use the "drive" that the camera is represented as on the computer as the "here is where I want to see notifications from". I have never programmed on a Mac, but it appears to have something called FSEvents that would do something similar.

  2. You can rely on the camera to store the image under a consistent name. When your application starts, find the last file in the drive that is the camera's storage. Then just number it up "IMG_0991.JPG" [replace "JPG" with "CR2" if you use RAW mode] will become "IMG_0992.JPG". This works every time, all the time. It will eventually wrap around to "IMG_0001.JPG" when you have taken 10000 images (and it will probably move to a new directory called "DCIM/101CANON" instead of "DCIM/100CANON").

  3. Scan the directory and keep a list of all the files. Then scan it again. This may take a little while if there are lots of images.

Mats Petersson
  • 126,704
  • 14
  • 140
  • 227
  • Hi Mats, thank you for your quick answer. I've still questions but I'll post later in the afternoon because as a new user I have to wait 8h between my posts. – RichardR Jul 04 '13 at 10:15
  • This is not a true answer. Look at the "download" command in the camera controller of the example of canon. This event is triggered by the camera when its set to save to_host or to_both. It then saves the image in the same folder as your main executable, using the name the camera gave it. – Nallath Sep 02 '13 at 12:29
  • @Nallath: I don't see how you can say "it's not a true answer", since the question is how to detect when the file has been saved, and what it's name is. Please do explain what you think the true answer should be - and why you think my methods don't work. – Mats Petersson Sep 02 '13 at 12:35
  • It will work, but its the code equalivant of taking the plane to go grocery shopping. The EDSDK already has an event listener thats being fired once a picture is being taken and providing you with both a stream and a file saved to your disk. – Nallath Sep 03 '13 at 07:10