Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Snapping pictures from Windows C# Canon SDK vs PTP or MTP

I am hoping to receive some general guidance on accomplishing a seemingly simple goal. I have a DSLR camera (Canon EOS 50D) and need to write an application that will tell the camera to take a picture. I also need to transfer the picture to the computer and possibly delete it from the camera's storage. A bonus would be to get a live preview from the camera in my application. My environment will be Windows (either XP Pro or Vista Enterprise) and .Net 3.5 (C#).

I have done some research and found a couple of options. One I know will work, but limits me to using only Canon cameras in the future. I have found and downloaded an SDK from Canon that provides a lot of this functionality. I've looked over the SDK and while it's extensive and written in C it does have C# wrappers that will speed up development a bit.

Another option I've found is called Windows Portable Devices. Apparently, it is an API that will talk to devices that implement PTP and MTP standards. It is COM based and as far as I can tell it has no .Net wrappers. This is not however a show stopper. I could P/Invoke the functionality I need or write a Managed C++ DLL to use in my application to talk to the camera.

I am looking for anyone with experience with WPD to give me pointers. I've perused the documentation and seen references to transferring images and deleting images. I have not, however, seen mention of commands to take a picture, get a preview image, or say focus/auto-focus.

like image 833
Nate Avatar asked Nov 10 '09 18:11

Nate


People also ask

How do you screenshot on a Windows C?

Press the Windows key + PrintScreen on your keyboard (or, PrtSc). Screenshots are automatically saved to Pictures/Screenshots in your user directory (C:/Users/%username%/Pictures/Screenshots by default).

Where is the Snipping Tool in Windows photos?

2) From the Windows Start Menu, select the Snipping Tool which can be found under the following path: All Programs> Accessories> Snipping Tool.

What is the Snipping Tool for Windows?

The Snipping Tool is a feature introduced in Windows 7 and is also available in Windows 8, Windows 10, and Windows 11. It can take a screenshot of the entire screen, window, or a rectangular area of the screen and save that screenshot as an image file.


2 Answers

The WPD api provides the command WPD_COMMAND_STILL_IMAGE_CAPTURE_INITIATE

I am not sure whether your camera supports it but it should be simple enough to find out. If you can get the "wpdinfo" tool from the driver development kit and start it with your camera connected then send it a WPD_COMMAND_CAPABILITIES_GET_SUPPORTED_COMMANDS command and see if it supports the still image capture command. IF so then you could give that a try.

like image 187
obelix Avatar answered Nov 08 '22 15:11

obelix


The comment from TallGanglyGuy is incorrect. ptp does allow you to trigger new images and change exposure, etc. Some cameras have firmware that only exposes some of the ptp commands.

PTP supports common device controls, such as taking a picture, so that the user could take advantage of the PC/camera combination in new and different ways again, without requiring additional software.

  • quoted from http://msdn.microsoft.com/en-us/windows/hardware/gg463507.aspx#EXC
like image 25
user607645 Avatar answered Nov 08 '22 14:11

user607645