EasyDarwin開源雲平台接入海康威視EasyCamera攝像機之快照獲取與上傳


本文轉自EasyDarwin團隊成員Alex的博客:http://blog.csdn.net/cai6811376

EasyCamera開源攝像機擁有獲取攝像機實時快照並上傳至EasyDarwin雲平台的功能,那么我們如何使用海康的攝像機SDK獲取實時快照呢?

我們看海康SDK的說明文檔中有

這里寫圖片描述

我們使用這個接口進行快照獲取

//EasyCamera-HK EasyCameraSource.cpp
bool EasyCameraSource::getSnapData(unsigned char* pBuf, UInt32 uBufLen, int* uSnapLen)
{
    //如果攝像機未登錄,返回false
    if (!cameraLogin()) return false;

    //調用SDK獲取數據
    LPNET_DVR_JPEGPARA jpegPara = new NET_DVR_JPEGPARA;
    jpegPara->wPicQuality = 0;
    jpegPara->wPicSize = 9;

    LPDWORD Ret = 0;

    NET_DVR_SetCapturePictureMode(JPEG_MODE);
    /*{ cout << "Set Capture Picture Mode error!" << endl; cout << "The error code is " << NET_DVR_GetLastError() << endl; }*/

    bool capture = NET_DVR_CaptureJPEGPicture_NEW(m_u32Handle, 1, jpegPara, (char*)pBuf, uBufLen, (LPDWORD)uSnapLen);
    if (!capture)
    {
        printf("Error: NET_DVR_CaptureJPEGPicture_NEW = %d", NET_DVR_GetLastError());
        delete jpegPara;
        return false;
    }

    delete jpegPara;
    return true;
}

將獲取到的快照數據進行Base64編碼,將編碼后的數據上傳至雲平台。

源碼及視頻教程

源碼地址:https://github.com/EasyDarwin/EasyDarwin/tree/master/EasyCamera-HK

視頻教程地址:[http://edu.csdn.net/course/detail/3029

](http://edu.csdn.net/course/detail/3029)

獲取更多信息

郵件:support@easydarwin.org

WEB:www.EasyDarwin.org

Copyright © EasyDarwin.org 2012-2016

EasyDarwin


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM