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

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

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

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

這裏寫圖片描述

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

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

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

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

獲取更多信息

郵件:support@easydarwin.org 視頻

WEB:www.EasyDarwin.orgblog

Copyright © EasyDarwin.org 2012-2016

EasyDarwin

相關文章
相關標籤/搜索