您好,登錄后才能下訂單哦!
這篇文章主要介紹VS2022如何調(diào)試通過??禂z像頭煙火識別SDK,文中介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們一定要看完!
下面是我根據(jù)??倒俜轿臋n代碼,放到VS 2022 版本中調(diào)試通過后的代碼:
#include <stdio.h> #include <iostream> #include "Windows.h" #include "HCNetSDK.h" using namespace std; //時(shí)間解析宏定義 #define GET_YEAR(_time_) (((_time_)>>26) + 2000) #define GET_MONTH(_time_) (((_time_)>>22) & 15) #define GET_DAY(_time_) (((_time_)>>17) & 31) #define GET_HOUR(_time_) (((_time_)>>12) & 31) #define GET_MINUTE(_time_) (((_time_)>>6) & 63) #define GET_SECOND(_time_) (((_time_)>>0) & 63) BOOL CALLBACK MessageCallback(LONG lCommand, NET_DVR_ALARMER* pAlarmer, char* pAlarmInfo, DWORD dwBufLen, void* pUser) { switch (lCommand) { case COMM_FIREDETECTION_ALARM: //火點(diǎn)檢測報(bào)警 { printf("fire192.168.1.31 \n"); NET_DVR_FIREDETECTION_ALARM struFireDetection = { 0 }; memcpy(&struFireDetection, pAlarmInfo, sizeof(NET_DVR_FIREDETECTION_ALARM)); printf("火點(diǎn)檢測報(bào)警: RelativeTime:%d, AbsTime:%d, PTZ{PanPos:%d, TiltPos:%d, ZoomPos:%d}, \ PicDataLen:%d, DevInfo{DevIP:%s, Port:%d, Channel:%d, IvmsChannel:%d}, \ FireMaxTemperature:%d, TargetDistance:%d, fireRectInfo{fX:%f,fY:%f,fWidth%f,fHeight%f}, \ fireMaxTemperaturePoint{fX:%f,fY:%f}\n", struFireDetection.dwRelativeTime, \ struFireDetection.dwAbsTime, struFireDetection.wPanPos, struFireDetection.wTiltPos, \ struFireDetection.wZoomPos, struFireDetection.dwPicDataLen, \ struFireDetection.struDevInfo.struDevIP.sIpV4, struFireDetection.struDevInfo.wPort, \ struFireDetection.struDevInfo.byChannel, struFireDetection.struDevInfo.byIvmsChannel, \ struFireDetection.wFireMaxTemperature, struFireDetection.wTargetDistance, \ struFireDetection.struRect.fX, struFireDetection.struRect.fY, struFireDetection.struRect.fWidth, \ struFireDetection.struRect.fHeight, struFireDetection.struPoint.fX, struFireDetection.struPoint.fY); NET_DVR_TIME struAbsTime = { 0 }; struAbsTime.dwYear = GET_YEAR(struFireDetection.dwAbsTime); struAbsTime.dwMonth = GET_MONTH(struFireDetection.dwAbsTime); struAbsTime.dwDay = GET_DAY(struFireDetection.dwAbsTime); struAbsTime.dwHour = GET_HOUR(struFireDetection.dwAbsTime); struAbsTime.dwMinute = GET_MINUTE(struFireDetection.dwAbsTime); struAbsTime.dwSecond = GET_SECOND(struFireDetection.dwAbsTime); //保存報(bào)警抓拍圖片 if (struFireDetection.dwPicDataLen > 0 && struFireDetection.pBuffer != NULL) { char cFilename[256] = { 0 }; HANDLE hFile; DWORD dwReturn; char chTime[128]; sprintf_s(chTime, "%4.4d%2.2d%2.2d%2.2d%2.2d%2.2d", struAbsTime.dwYear, struAbsTime.dwMonth, struAbsTime.dwDay, struAbsTime.dwHour, struAbsTime.dwMinute, struAbsTime.dwSecond); sprintf_s(cFilename, "FireDetectionPic[%s][%s].jpg", struFireDetection.struDevInfo.struDevIP.sIpV4, chTime); LPCWSTR tmp; // begin added by zhangchao tmp = L"FireDetectionPic31.jpg"; // end added by zhangchao //printf("%s", tmp); hFile = CreateFile(tmp, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (hFile == INVALID_HANDLE_VALUE) { break; } WriteFile(hFile, struFireDetection.pBuffer, struFireDetection.dwPicDataLen, &dwReturn, NULL); CloseHandle(hFile); hFile = INVALID_HANDLE_VALUE; } } break; default: printf("other192.168.1.31 \n"); printf("其他報(bào)警,報(bào)警信息類型: %d\n", lCommand); break; } return TRUE; } void RunCam(const char* ip) { //--------------------------------------- // 初始化 NET_DVR_Init(); //設(shè)置連接時(shí)間與重連時(shí)間 NET_DVR_SetConnectTime(2000, 1); NET_DVR_SetReconnect(10000, true); //--------------------------------------- // 注冊設(shè)備 LONG lUserID; //登錄參數(shù),包括設(shè)備地址、登錄用戶、密碼等 NET_DVR_USER_LOGIN_INFO struLoginInfo = { 0 }; struLoginInfo.bUseAsynLogin = 0; //同步登錄方式 strcpy_s(struLoginInfo.sDeviceAddress, ip); struLoginInfo.wPort = 8000; //設(shè)備服務(wù)端口 strcpy_s(struLoginInfo.sUserName, "your_username"); //設(shè)備登錄用戶名 strcpy_s(struLoginInfo.sPassword, "your_password"); //設(shè)備登錄密碼 //設(shè)備信息, 輸出參數(shù) NET_DVR_DEVICEINFO_V40 struDeviceInfoV40 = { 0 }; lUserID = NET_DVR_Login_V40(&struLoginInfo, &struDeviceInfoV40); if (lUserID < 0) { printf("Login failed, error code: %d\n", NET_DVR_GetLastError()); NET_DVR_Cleanup(); return; } //設(shè)置報(bào)警回調(diào)函數(shù) NET_DVR_SetDVRMessageCallBack_V31(MessageCallback, NULL); //啟用布防 LONG lHandle; NET_DVR_SETUPALARM_PARAM struAlarmParam = { 0 }; struAlarmParam.dwSize = sizeof(struAlarmParam); //火點(diǎn)檢測不需要設(shè)置其他報(bào)警布防參數(shù),不支持 lHandle = NET_DVR_SetupAlarmChan_V41(lUserID, &struAlarmParam); if (lHandle < 0) { printf("NET_DVR_SetupAlarmChan_V41 error, %d\n", NET_DVR_GetLastError()); NET_DVR_Logout(lUserID); NET_DVR_Cleanup(); return; } Sleep(50000); //等待過程中,如果設(shè)備上傳報(bào)警信息,在報(bào)警回調(diào)函數(shù)里面接收和處理報(bào)警信息 //撤銷布防上傳通道 if (!NET_DVR_CloseAlarmChan_V30(lHandle)) { printf("NET_DVR_CloseAlarmChan_V30 error, %d\n", NET_DVR_GetLastError()); NET_DVR_Logout(lUserID); NET_DVR_Cleanup(); return; } //注銷用戶 NET_DVR_Logout(lUserID); //釋放SDK資源 NET_DVR_Cleanup(); } void main() { RunCam("192.168.1.31"); return; }
第一步:打開窗口頂部 【項(xiàng)目】菜單,選中 【<某某項(xiàng)目>屬性】。
第二步:在打開的對話框中,左側(cè)菜單選擇 【C/C++】=> 【常規(guī)】,選中右側(cè)附加包含目錄中,點(diǎn)擊右側(cè)出現(xiàn)的向下箭頭,點(diǎn)擊編輯,在打開的對話框中如下填寫:
其中 D:\ws\vc\emptycam\hkheader 文件夾放著海康的頭文件,分別是: DataType.h、DecodeCardSdk.h、HCNetSDK.h、plaympeg4.h。
第三步:左側(cè)菜單選擇 【鏈接器】=> 【常規(guī)】。右側(cè)選中附加庫目錄,點(diǎn)擊右側(cè)小三角,點(diǎn)擊編輯,打開對話框。
文件夾 D:\ws\vc\emptycam\hkdll 是放??礵ll文件的地方。文件如下圖所示:
第四步:左側(cè)菜單選擇 【鏈接器】=> 【輸入】。右側(cè)選中【附加依賴項(xiàng)】點(diǎn)擊右側(cè)小三角,點(diǎn)擊編輯,打開對話框。內(nèi)容按照圖片里的文字進(jìn)行填寫。
以上是“VS2022如何調(diào)試通過??禂z像頭煙火識別SDK”這篇文章的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對大家有幫助,更多相關(guān)知識,歡迎關(guān)注億速云行業(yè)資訊頻道!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。