pizthewiz/Cinder-EDSDK

How to run as a pure C++ EDSDK wrapper without Cinder

hezhao opened this issue · 4 comments

This is more of a question rather than an issue.

I find this to be a great Cinder block with minimum cinder code (only using boost fillesystem and Cinder surface), which is perfect for me to use it as a pure C++ wrapper of EDSDK to use in a Qt project. I stripped away the Cinder surface and other ci namespaces in Camera and CameraBrowser source code, and the SimpleTetherApp works as expected.

Then I replaced CINDER_APP_NATIVE(SimpleTetherApp, RendererGl) with a simple main loop,

int main()
{
    SimpleTetherApp *app = new SimpleTetherApp();
    app->setup();
    while (1)
    {
        app->keyDown();
    }
    return 0;
}

Now the SimpleTetherApp works, every time I press a key it will capture an image. However, the callback functions are not registered properly, resulting the program only runs after the camera is turned on, and it won't copy the image immediately after capturing until the next time the program runs.

Can you help me to find where the problem might be? Thank you! You can find the modifications I had in this forked repo, https://github.com/hezhao/Cinder-EDSDK

No ❤️ for Cinder eh?

I won't be of much help as I cannot say that I have implemented my own runloop in a raw C++ app, though I would have thought Qt provided a simple app launch entry point. You could look into the Cinder macro and see how it handles it.

Thanks for the tip! I figured it out. I get rid of Cinder code in this case because I need to add Canon camera support in a relatively large Qt application, as opposed to rewrite the entire application in Cinder.

The callback functions / event handlers to work ARE registered properly, but not called in the while loop, one must explicitly call CFRunLoopRunInMode(). Note that keydown() method will not work here because it needs to be a keyboard event handler such as one that is implemented in Cinder and Qt.

int main()
{
    SimpleTetherApp *app = new SimpleTetherApp();
    app->setup();
    while (1)
    {
        //app->keyDown();
        CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, false);
    }
    return 0;
}

A CoreFoundation runloop, and here I thought that you were using Qt?

Glad you figured it out, closing this issue out.

I'm only using CFRunloopRunInMode() to prove that the code can be run as pure C++ wrapper without Cinder. You are right about Qt, I'll find the run loop method in Qt to replace CFRunloopRunInMode().