样品C code佳能EDSDK实时查看? [英] Sample C code for Canon EDSDK Liveview?

查看:779
本文介绍了样品C code佳能EDSDK实时查看?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有任何人使用实现使用佳能EDSDK实时查看样品C code的工作一块?在文档中的示例code看起来不错,直到你到达此位:

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 
// 

是啊,就是这样。它们没有显示如何将图像BLT使用从相机获取的数据的窗口。他们只是说,显示的图像。谢谢,佳能

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.

我已经猎杀了互联网(包括本论坛),但我还没有找到一个C code示例演示如何做到这一点。我期待,以避免MFC,VB,管理code或C#。当然,这是可能做到这一点香草C,对不对?香草C ++是罚款为好。

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.

谢谢,
FredP

Thanks, FredP

推荐答案

有两个功能,他们不告诉你:结果
1) EdsGetPointer 结果
2) EdsGetLength

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

这会给你一个指针JPEG视频流分别尺寸的开始。

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

一旦有了这种使用的libjpeg涡轮来DECOM preSS,的libjpeg 只是不够快

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

一旦DECOM preSS,您可以使用显示图像 OpenCV的

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;
}

这篇关于样品C code佳能EDSDK实时查看?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆