I'm working on an arduino project that needs to communicate via USB with cameras. There is a great library that everyone knows of when it comes to arduino and USB: https://github.com/felis/PTP_2.0
There are lots of examples on how to use it and even examples of how to communicate with Canon cameras. Even some sort of event handling has its example on github!
But for a VERY long time I just don't get it done: catching the event when a photo was taken!
I digged into the EOSEventLab example and all the other examples, searched the internet up and down but I can't find an answer to my problem. Everyone seems to use "delay" to trigger code after capturing... I can't be the only one in need for this. :)
The following steps should be done:
I can give some code if needed but mainly it's the code found in the EOSEventLab example.
Thank you very much for your help!
YES!!!
Okay, after months of crawling through the code (and maybe because of switching from the arduino IDE to Visual Studio == better code highlighting, code completion...) I found the answer. It was sitting directly in front of my face!
It's inside the header an cpp files on https://github.com/felis/PTP_2.0/tree/master/examples/Canon_EOS/EOSRemote
One has to add the method "OnObjectCreated" to eoseventhandlers.h
virtual void OnObjectCreated(const EOSEvent *evt);
and implement this method in eoseventhandlers.cpp
void EosEventHandlers::OnObjectCreated(const EOSEvent *evt)
{
E_Notify(PSTR("capturing done!"), 0x80);
}
The rest is up to you! "Object Created" is kind of a synonym for "Capturing done". If I understand it correctly you get the address to the image (object) using evt->propCode inside this method. I didn't try to use that information for filename extraction and so on but it may be useful for that.
Although this answer is great, it doesn't apply to all events the camera triggers but "only" the event I was looking for. It's great to be able to wait for a photo to be captured instead of using delays.