Canon EDSDK Liveview 的示例 C 代码?

发布于 2024-09-08 13:16:52 字数 329 浏览 6 评论 0原文

是否有人拥有使用 Canon EDSDK 实现 LiveView 的示例 C 代码的工作片段?文档中的示例代码看起来很棒,直到您看到这一点:

// 
// Display image 
// 

是的,就是这样。他们没有展示如何使用从相机检索的数据将图像 BLT 到窗口。他们只是说“显示图像”。谢谢,佳能。

我已经在互联网上搜索过(包括这个论坛),但我还没有找到一个 C 代码示例来展示如何做到这一点。我希望避免使用 MFC、VB、托管代码或 C#。当然可以在普通 C 中做到这一点,对吗? Vanilla C++ 也不错。

谢谢, 弗雷德·P

Is there anyone with a working piece of sample C code that implements LiveView using the Canon EDSDK? The sample code in the documentation looks great until you get to this bit:

// 
// Display image 
// 

Yup, that's it. They don't show how to BLT an image to a window using the data retrieved from the camera. They just say, "Display image." Thanks, Canon.

I have hunted the Internet (including this forum), but I have yet to find a C code sample that shows how to do this. I'm looking to avoid MFC, VB, managed code, or C#. Surely it's possible to do this in vanilla C, right? Vanilla C++ is fine as well.

Thanks,
FredP

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

冷︶言冷语的世界 2024-09-15 13:16:52

有两个功能他们没有告诉您:
1) EdsGetPointer
2) EdsGetLength

这将为您提供分别指向 JPEG 流开头和大小的指针。

一旦您使用 LibJPEG Turbo 来解压缩,Libjpeg 就不够快。

解压后,您可以使用opencv显示图像。

bool CanonCamera::downloadLiveViewImage()
{
    EdsError err = EDS_ERR_OK;
    EdsEvfImageRef image = NULL;
    EdsStreamRef stream = NULL;
    unsigned char* data = NULL;
    unsigned long size = 0;

    err = EdsCreateMemoryStream(0, &stream);

    if (err != EDS_ERR_OK) {
        cout << "Download Live View Image Error in Function EdsCreateMemoryStream: " << err << "\n";
        return false;
    }

    err = EdsCreateEvfImageRef(stream, &image);

    if (err != EDS_ERR_OK) {
        cout << "Download Live View Image Error in Function EdsCreateEvfImageRef: " << err << "\n";
        return false;

    }

    err = EdsDownloadEvfImage(cameraRef, image);

    if (err != EDS_ERR_OK) {
        cout << "Download Live View Image Error in Function EdsDownloadEvfImage: " << err << "\n";
        return false;
    }

    err = EdsGetPointer(stream, (EdsVoid**)& data);

    if (err != EDS_ERR_OK) {
        cout << "Download Live View Image Error in Function EdsGetPointer: " << err << "\n";
        return false;
    }

    err = EdsGetLength(stream, &size);

    if (err != EDS_ERR_OK) {
        cout << "Download Live View Image Error in Function EdsGetLength: " << err << "\n";
        return false;
    }

    // libjpegTurbo(data, size);
    // display RGB image in opencv

    if (stream != NULL) {
        EdsRelease(stream);
        stream = NULL;
    }

    if (image != NULL) {            
        EdsRelease(image);
        image = NULL;
    }

    data = NULL;
    return true;
}

There are two functions that they don't tell you about:
1) EdsGetPointer
2) EdsGetLength

This will give you a pointer to the beginning of the JPEG stream and the size respectively.

Once you have this use LibJPEG Turbo to decompress, Libjpeg just isn't fast enough.

Once you decompress, you can show the image using opencv.

bool CanonCamera::downloadLiveViewImage()
{
    EdsError err = EDS_ERR_OK;
    EdsEvfImageRef image = NULL;
    EdsStreamRef stream = NULL;
    unsigned char* data = NULL;
    unsigned long size = 0;

    err = EdsCreateMemoryStream(0, &stream);

    if (err != EDS_ERR_OK) {
        cout << "Download Live View Image Error in Function EdsCreateMemoryStream: " << err << "\n";
        return false;
    }

    err = EdsCreateEvfImageRef(stream, &image);

    if (err != EDS_ERR_OK) {
        cout << "Download Live View Image Error in Function EdsCreateEvfImageRef: " << err << "\n";
        return false;

    }

    err = EdsDownloadEvfImage(cameraRef, image);

    if (err != EDS_ERR_OK) {
        cout << "Download Live View Image Error in Function EdsDownloadEvfImage: " << err << "\n";
        return false;
    }

    err = EdsGetPointer(stream, (EdsVoid**)& data);

    if (err != EDS_ERR_OK) {
        cout << "Download Live View Image Error in Function EdsGetPointer: " << err << "\n";
        return false;
    }

    err = EdsGetLength(stream, &size);

    if (err != EDS_ERR_OK) {
        cout << "Download Live View Image Error in Function EdsGetLength: " << err << "\n";
        return false;
    }

    // libjpegTurbo(data, size);
    // display RGB image in opencv

    if (stream != NULL) {
        EdsRelease(stream);
        stream = NULL;
    }

    if (image != NULL) {            
        EdsRelease(image);
        image = NULL;
    }

    data = NULL;
    return true;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文