510 lines
13 KiB
C++
510 lines
13 KiB
C++
|
// MsgHandleDlg.cpp : ʵ<><CAB5><EFBFBD>ļ<EFBFBD>
|
|||
|
//
|
|||
|
|
|||
|
#include "stdafx.h"
|
|||
|
#include "afxdialogex.h"
|
|||
|
#include "Fast.h"
|
|||
|
#include "DahuaFisheyeCamera.h"
|
|||
|
#include "FastView.h"
|
|||
|
#include "dhplay.h"
|
|||
|
|
|||
|
|
|||
|
#define TIMER_LOGIN 10
|
|||
|
|
|||
|
|
|||
|
// CMsgHandleDlg <20>Ի<EFBFBD><D4BB><EFBFBD>
|
|||
|
|
|||
|
IMPLEMENT_DYNAMIC(CDahuaFisheyeCamera, CBaseCamera)
|
|||
|
|
|||
|
CDahuaFisheyeCamera::CDahuaFisheyeCamera(CFastView * pParentWnd, int nIdx, ENUM_PLAY_TYPE enPlayType, CWnd* pParent /*=NULL*/)
|
|||
|
: CBaseCamera(IDD_DLG_CAM, pParentWnd)
|
|||
|
{
|
|||
|
m_nCameraIdx = nIdx;
|
|||
|
m_nIndex = 0;
|
|||
|
m_pParentWnd = pParentWnd;
|
|||
|
m_hCameraHandle = NULL;
|
|||
|
m_nPlayTyp = enPlayType;
|
|||
|
}
|
|||
|
|
|||
|
CDahuaFisheyeCamera::~CDahuaFisheyeCamera()
|
|||
|
{
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
void CDahuaFisheyeCamera::DoDataExchange(CDataExchange* pDX)
|
|||
|
{
|
|||
|
CDialog::DoDataExchange(pDX);
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
BEGIN_MESSAGE_MAP(CDahuaFisheyeCamera, CDialog)
|
|||
|
ON_WM_DESTROY()
|
|||
|
ON_WM_TIMER()
|
|||
|
ON_MESSAGE(WM_CAMERA_SNAP, &CDahuaFisheyeCamera::OnSnap)
|
|||
|
END_MESSAGE_MAP()
|
|||
|
|
|||
|
|
|||
|
/*
|
|||
|
int GetDahuaCameraIdxByLoginID(CDahuaFisheyeCamera *pThis, LLONG lLoginID)
|
|||
|
{
|
|||
|
for (int i = 0; i < theApp.m_nCameraCount; i++)
|
|||
|
{
|
|||
|
if (theApp.m_CameraArray[i].lLoginId == lLoginID)
|
|||
|
{
|
|||
|
return i;
|
|||
|
}
|
|||
|
}
|
|||
|
return -1;
|
|||
|
}
|
|||
|
*/
|
|||
|
//<2F><><EFBFBD>ص<DFBB>
|
|||
|
void CALLBACK DahuaDisConnectFunc(LLONG lLoginID, char *pchDVRIP, LONG nDVRPort, LDWORD dwUser)
|
|||
|
{
|
|||
|
if (dwUser == 0)
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
CDahuaFisheyeCamera *pThis = (CDahuaFisheyeCamera *)dwUser;
|
|||
|
TRACE("[%I64d - %d]*********************** <20>Ͽ<EFBFBD><CFBF><EFBFBD><EFBFBD><EFBFBD> *********************\r\n", lLoginID, pThis->m_hWnd);
|
|||
|
|
|||
|
HWND hWnd = pThis->GetSafeHwnd();
|
|||
|
if (NULL == hWnd)
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
//int nIdx = GetDahuaCameraIdxByLoginID(pThis, lLoginID);
|
|||
|
if (pThis->m_lLoginId == lLoginID)
|
|||
|
{
|
|||
|
pThis->m_nCameraState = 0;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
//pThis->m_pParentWnd->RefreshCameraList();
|
|||
|
//pThis->m_pParentWnd->VoiceReminder();
|
|||
|
}
|
|||
|
|
|||
|
void CALLBACK DahuaReConnectFunc(LLONG lLoginID, char *pchDVRIP, LONG nDVRPort, LDWORD dwUser)
|
|||
|
{
|
|||
|
if (dwUser == 0)
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
CDahuaFisheyeCamera *pThis = (CDahuaFisheyeCamera *)dwUser;
|
|||
|
TRACE("[%I64d - %d]*********************** <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> *********************\r\n", lLoginID, pThis->m_hWnd);
|
|||
|
HWND hWnd = pThis->GetSafeHwnd();
|
|||
|
if (NULL == hWnd)
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
if (pThis->m_lLoginId == lLoginID)
|
|||
|
{
|
|||
|
pThis->m_nCameraState = 1;
|
|||
|
}
|
|||
|
//int nIdx = GetDahuaCameraIdxByLoginID(pThis, lLoginID);
|
|||
|
//pThis->m_nCameraState = 1;
|
|||
|
|
|||
|
//pThis->m_pParentWnd->RefreshCameraList();
|
|||
|
//pThis->m_pParentWnd->VoiceReminder();
|
|||
|
}
|
|||
|
|
|||
|
void CALLBACK DahuaSnapPicRet(LLONG lLoginID, BYTE *pBuf, UINT RevLen, UINT EncodeType, DWORD CmdSerial, LDWORD dwUser)
|
|||
|
{
|
|||
|
|
|||
|
CDahuaFisheyeCamera *pThis = (CDahuaFisheyeCamera*)dwUser;
|
|||
|
|
|||
|
if (pThis->m_lLoginId == lLoginID)
|
|||
|
{
|
|||
|
CTime currentTime = CTime::GetCurrentTime(); // <20><>ȡ<EFBFBD><C8A1>ǰʱ<C7B0><CAB1>
|
|||
|
CString dateStr = currentTime.Format(_T("%Y_%m_%d")); // <20><>ʽ<EFBFBD><CABD>Ϊ<EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>
|
|||
|
CString tiemStr = currentTime.Format(_T("%H_%M_%S")); // <20><>ʽ<EFBFBD><CABD>Ϊ<EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>
|
|||
|
CString strPath = theApp.m_strDataPath + "\\" + dateStr;
|
|||
|
|
|||
|
if (!PathIsDirectory(strPath))//<2F>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><C2B7><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
{
|
|||
|
CreateDirectory(strPath, NULL);//<2F>½<EFBFBD><C2BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>
|
|||
|
}
|
|||
|
|
|||
|
//ԭͼ
|
|||
|
char acFileName[256] = "";
|
|||
|
sprintf(acFileName, "%s\\%s-%d.jpg", strPath, tiemStr, pThis->m_nCameraIdx);
|
|||
|
|
|||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼƬ
|
|||
|
//char acAnalysisName[256] = "";
|
|||
|
//sprintf(acAnalysisName, "%s\\analysis-%d.JPG", strPath, 0);
|
|||
|
|
|||
|
|
|||
|
|
|||
|
/* Save image original file */
|
|||
|
FILE *stream;
|
|||
|
if ((stream = fopen((const char*)acFileName, "wb")) != NULL)
|
|||
|
{
|
|||
|
int numwritten = fwrite(pBuf, sizeof(char), RevLen, stream);
|
|||
|
fclose(stream);
|
|||
|
}
|
|||
|
|
|||
|
pThis->m_pParentWnd->StartPlay(acFileName);
|
|||
|
|
|||
|
|
|||
|
//theApp.m_CameraArray[nIdx].strImagePath[0] = acFileName;
|
|||
|
//theApp.m_CameraArray[nIdx].strImagePath[1] = acAnalysisName;
|
|||
|
//pThis->m_pParentWnd->ShowCameraImage(acFileName, nIdx);
|
|||
|
//SetEvent(theApp.m_EventHandles[nIdx]);
|
|||
|
|
|||
|
/*if (theApp.m_CameraArray[nIdx].bAnalysis == TRUE)
|
|||
|
{
|
|||
|
//<2F><>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>
|
|||
|
ParseImage(pThis, acFileName, acAnalysisName, nIdx);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
SetEvent(theApp.m_EventHandles[nIdx]);
|
|||
|
theApp.m_CameraArray[nIdx].strImagePath[0] = acFileName;
|
|||
|
theApp.m_CameraArray[nIdx].strImagePath[1] = acFileName;
|
|||
|
pThis->m_pParentWnd->ShowCameraImage(acFileName, nIdx);
|
|||
|
}*/
|
|||
|
}
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
// netsdk ʵʱ<CAB5>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
void CALL_METHOD fRealDataCB(LLONG lRealHandle, DWORD dwDataType, BYTE *pBuffer, DWORD dwBufSize, LDWORD dwUser)
|
|||
|
{
|
|||
|
|
|||
|
CDahuaFisheyeCamera *pWnd = (CDahuaFisheyeCamera*)dwUser;
|
|||
|
if (pWnd->m_lRealHandle != lRealHandle)return;
|
|||
|
|
|||
|
// <20>Ѵ<EFBFBD><D1B4><EFBFBD>ʵʱ<CAB5><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD>playsdk<64><6B>
|
|||
|
PLAY_InputData(pWnd->m_nWndID, pBuffer, dwBufSize);
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
// playsdk <20>ص<EFBFBD> yuv<75><76><EFBFBD><EFBFBD>
|
|||
|
void CALL_METHOD fDisplayCB(LONG nPort, char * pBuf, LONG nSize, LONG nWidth, LONG nHeight, LONG nStamp, LONG nType, void* pReserved)
|
|||
|
{
|
|||
|
|
|||
|
CDahuaFisheyeCamera *pShowWnd = (CDahuaFisheyeCamera *)(pReserved);
|
|||
|
|
|||
|
if (pShowWnd->m_nWndID != nPort)return;
|
|||
|
|
|||
|
//TRACE("%d\n", pThis->m_nWndID);
|
|||
|
|
|||
|
|
|||
|
//if (pThis->m_nWndID > 1)return;
|
|||
|
pShowWnd->m_nIndex++;
|
|||
|
if (pShowWnd->m_nIndex == 10)
|
|||
|
{
|
|||
|
|
|||
|
cv::Mat cv_img;
|
|||
|
cv::Mat cv_yuv(nHeight + nHeight / 2, nWidth, CV_8UC1, pBuf);//pFrameΪYUV<55><56><EFBFBD>ݵ<EFBFBD>ַ,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> CV_8UC1<43><31> CV_8UC3.
|
|||
|
cv_img = cv::Mat(nHeight, nWidth, CV_8UC3);
|
|||
|
cv::cvtColor(cv_yuv, cv_img, cv::COLOR_YUV2BGR_I420); //cv::COLOR_YUV2BGR_I420
|
|||
|
//cv::imshow("video", cv_img);
|
|||
|
|
|||
|
cv::Mat imgTmp;
|
|||
|
|
|||
|
CRect rect;
|
|||
|
pShowWnd->GetClientRect(&rect); // <20><>ȡ<EFBFBD>ؼ<EFBFBD><D8BC><EFBFBD>С
|
|||
|
int nWidth = cv_img.cols * rect.Height() *1.0 / cv_img.rows;
|
|||
|
|
|||
|
if (rect.Width() == 0)return;
|
|||
|
|
|||
|
|
|||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƭվչƽ
|
|||
|
//if (theApp.m_bCalibrator)
|
|||
|
//{
|
|||
|
// cv_img = CImageCalibrator::imageCalibration(cv_img);
|
|||
|
//}
|
|||
|
|
|||
|
cv::resize(cv_img, imgTmp, cv::Size(nWidth, rect.Height()));// <20><><EFBFBD><EFBFBD>Mat<61><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
pShowWnd->m_nIndex = 0;
|
|||
|
pShowWnd->m_pParentWnd->DrawMat(imgTmp, (rect.Width() - nWidth) / 2);
|
|||
|
cv::waitKey(10);
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
CString CDahuaFisheyeCamera::ConvertString(CString strText)
|
|||
|
{
|
|||
|
char *val = new char[200];
|
|||
|
CString strIniPath, strRet;
|
|||
|
|
|||
|
memset(val, 0, 200);
|
|||
|
GetPrivateProfileString("String", strText, "",
|
|||
|
val, 200, "./langchn.ini");
|
|||
|
strRet = val;
|
|||
|
if (strRet.GetLength() == 0)
|
|||
|
{
|
|||
|
//If there is no corresponding string in ini file then set it to be deafault value(English).
|
|||
|
strRet = strText;
|
|||
|
}
|
|||
|
delete[] val;
|
|||
|
return strRet;
|
|||
|
}
|
|||
|
|
|||
|
//Display log in failure reason
|
|||
|
void CDahuaFisheyeCamera::ShowLoginErrorReason(int nError)
|
|||
|
{
|
|||
|
if (1 == nError) MessageBox(ConvertString("Invalid password!"), ConvertString("Prompt"));
|
|||
|
else if (2 == nError) MessageBox(ConvertString("Invalid account!"), ConvertString("Prompt"));
|
|||
|
else if (3 == nError) MessageBox(ConvertString("Timeout!"), ConvertString("Prompt"));
|
|||
|
else if (4 == nError) MessageBox(ConvertString("The user has logged in!"), ConvertString("Prompt"));
|
|||
|
else if (5 == nError) MessageBox(ConvertString("The user has been locked!"), ConvertString("Prompt"));
|
|||
|
else if (6 == nError) MessageBox(ConvertString("The user has listed into illegal!"), ConvertString("Prompt"));
|
|||
|
else if (7 == nError) MessageBox(ConvertString("The system is busy!"), ConvertString("Prompt"));
|
|||
|
else if (9 == nError) MessageBox(ConvertString("You Can't find the network server!"), ConvertString("Prompt"));
|
|||
|
else MessageBox(ConvertString("Login failed!"), ConvertString("Prompt"));
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
// CMsgHandleDlg <20><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
|
|||
|
BOOL CDahuaFisheyeCamera::OnInitDialog()
|
|||
|
{
|
|||
|
CDialog::OnInitDialog();
|
|||
|
InitCameraSDK();
|
|||
|
|
|||
|
|
|||
|
CString strIpAddr = "192.168.0.102";
|
|||
|
int nPort = 37777;
|
|||
|
CString strUser = "admin";
|
|||
|
CString strPW = "wdq@2023";
|
|||
|
m_lLoginId = Login(strIpAddr, nPort, strUser, strPW);
|
|||
|
|
|||
|
if (m_lLoginId > 0)
|
|||
|
{
|
|||
|
m_nCameraState = 1;
|
|||
|
KillTimer(TIMER_LOGIN);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
m_nCameraState = 0;
|
|||
|
SetTimer(TIMER_LOGIN, 10000, NULL);
|
|||
|
}
|
|||
|
return TRUE; // return TRUE unless you set the focus to a control
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
BOOL CDahuaFisheyeCamera::InitCameraSDK()
|
|||
|
{
|
|||
|
|
|||
|
TRACE("[%d - %d]*********************** InitNetSDK *********************\r\n", m_nCameraIdx, this->m_hWnd);
|
|||
|
BOOL ret = CLIENT_Init(DahuaDisConnectFunc, (LDWORD)this);
|
|||
|
if (ret)
|
|||
|
{
|
|||
|
LOG_SET_PRINT_INFO stLogPrintInfo = { sizeof(stLogPrintInfo) };
|
|||
|
CLIENT_LogOpen(&stLogPrintInfo);
|
|||
|
CLIENT_SetSnapRevCallBack(DahuaSnapPicRet, (LDWORD)this);
|
|||
|
CLIENT_SetAutoReconnect(DahuaReConnectFunc, (LDWORD)this);
|
|||
|
//CLIENT_SetConnectTime(0, 0);
|
|||
|
TRACE("[%d - %d]*********************** InitNetSDK SUCCEED*********************\r\n", m_nCameraIdx, this->m_hWnd);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
MessageBox(ConvertString("initialize SDK failed!"), ConvertString("prompt"));
|
|||
|
}
|
|||
|
|
|||
|
// <20><>ʼ<EFBFBD><CABC><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
NET_PARAM stuNetParam = { 0 };
|
|||
|
// Ŀǰ<C4BF><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD>ȡ<EFBFBD>豸<EFBFBD><E8B1B8>Ϣʱ<CFA2>䣨<EFBFBD><E4A3A8><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>⣬û<E2A3AC><C3BB><EFBFBD><EFBFBD>Ĭ<EFBFBD><C4AC>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɣ<EFBFBD><C9A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>Ĭ<EFBFBD>ϣ<EFBFBD>
|
|||
|
stuNetParam.nGetDevInfoTime = 3000;
|
|||
|
CLIENT_SetNetworkParam(&stuNetParam);
|
|||
|
return TRUE;
|
|||
|
}
|
|||
|
|
|||
|
LLONG CDahuaFisheyeCamera::Login(CString strIpAddr, int nPort, CString strUser, CString strPW)
|
|||
|
{
|
|||
|
//<2F><><EFBFBD>ε<EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1>¼ID
|
|||
|
NET_IN_LOGIN_WITH_HIGHLEVEL_SECURITY stInparam;
|
|||
|
memset(&stInparam, 0, sizeof(stInparam));
|
|||
|
stInparam.dwSize = sizeof(stInparam);
|
|||
|
strncpy(stInparam.szIP, strIpAddr.GetBuffer(), strIpAddr.GetLength());
|
|||
|
strncpy(stInparam.szPassword, strPW.GetBuffer(), strPW.GetLength());
|
|||
|
strncpy(stInparam.szUserName, strUser.GetBuffer(), strUser.GetLength());
|
|||
|
stInparam.nPort = nPort;
|
|||
|
stInparam.emSpecCap = EM_LOGIN_SPEC_CAP_TCP;
|
|||
|
|
|||
|
NET_OUT_LOGIN_WITH_HIGHLEVEL_SECURITY stOutparam;
|
|||
|
memset(&stOutparam, 0, sizeof(stOutparam));
|
|||
|
stOutparam.dwSize = sizeof(stOutparam);
|
|||
|
LLONG lLoginHandle = CLIENT_LoginWithHighLevelSecurity(&stInparam, &stOutparam);
|
|||
|
|
|||
|
if (0 == lLoginHandle)
|
|||
|
{
|
|||
|
//Display log in failure reason
|
|||
|
//ShowLoginErrorReason(stOutparam.nError);
|
|||
|
return -1;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
if (SNAP_PICTURE == m_nPlayTyp)
|
|||
|
{
|
|||
|
//m_LoginID = lRet;
|
|||
|
int nRetLen = 0;
|
|||
|
NET_DEV_CHN_COUNT_INFO stuChn = { sizeof(NET_DEV_CHN_COUNT_INFO) };
|
|||
|
stuChn.stuVideoIn.dwSize = sizeof(stuChn.stuVideoIn);
|
|||
|
stuChn.stuVideoOut.dwSize = sizeof(stuChn.stuVideoOut);
|
|||
|
BOOL bRet = CLIENT_QueryDevState(lLoginHandle, DH_DEVSTATE_DEV_CHN_COUNT, (char*)&stuChn, stuChn.dwSize, &nRetLen);
|
|||
|
if (!bRet)
|
|||
|
{
|
|||
|
DWORD dwError = CLIENT_GetLastError() & 0x7fffffff;
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
else if (RT_STREAMING == m_nPlayTyp)
|
|||
|
{
|
|||
|
PLAY_GetFreePort(&m_nWndID);
|
|||
|
PLAY_SetStreamOpenMode(m_nWndID, STREAME_REALTIME);
|
|||
|
PLAY_OpenStream(m_nWndID, NULL, 0, 1024 * 512 * 6);
|
|||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƶץͼ<D7A5>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>Իص<D4BB><D8B5><EFBFBD>YUV<55><56><EFBFBD><EFBFBD>
|
|||
|
PLAY_SetDisplayCallBack(m_nWndID, fDisplayCB, this);
|
|||
|
PLAY_Play(m_nWndID, NULL);
|
|||
|
//<2F><><EFBFBD><EFBFBD>
|
|||
|
m_lRealHandle = CLIENT_RealPlayEx(lLoginHandle, 0, 0);
|
|||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD>
|
|||
|
CLIENT_SetRealDataCallBack(m_lRealHandle, fRealDataCB, (LDWORD)this);
|
|||
|
}
|
|||
|
return lLoginHandle;
|
|||
|
}
|
|||
|
//SetWindowText(ConvertString("CapturePicture"));
|
|||
|
|
|||
|
|
|||
|
/*
|
|||
|
char *pchDVRIP;
|
|||
|
//CString strDvrIP = GetDvrIP();
|
|||
|
pchDVRIP = (LPSTR)(LPCSTR)strIpAddr;
|
|||
|
WORD wDVRPort = (WORD)nPort;
|
|||
|
char *pchUserName = (LPSTR)(LPCSTR)strUser;
|
|||
|
char *pchPassword = (LPSTR)(LPCSTR)strPW;
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
NET_DEVICEINFO_Ex stLoginInfo = { 0 };
|
|||
|
int nErrcode = 0;
|
|||
|
|
|||
|
LLONG lLoginHandle = CLIENT_LoginEx2(pchDVRIP, nPort, pchUserName, pchPassword, (EM_LOGIN_SPAC_CAP_TYPE)0, NULL, &stLoginInfo, &nErrcode);
|
|||
|
if (0 == lLoginHandle)
|
|||
|
{
|
|||
|
//cout << "Login device failed" << endl;
|
|||
|
//cin >> szIpAddr;
|
|||
|
return -1;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
//cout << "Login device success" << endl;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
if (0 == m_lRealHandle)
|
|||
|
{
|
|||
|
//cout << "CLIENT_RealPlayEx fail!" << endl;
|
|||
|
Sleep(100000);
|
|||
|
return -1;
|
|||
|
}
|
|||
|
//cout << "CLIENT_RealPlayEx success!" << endl;
|
|||
|
|
|||
|
*/
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
LRESULT CDahuaFisheyeCamera::OnSnap(WPARAM wParam, LPARAM lParam)
|
|||
|
{
|
|||
|
//AfxMessageBox("<22><><EFBFBD><EFBFBD>");
|
|||
|
//<2F><><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD>
|
|||
|
if (m_nCameraState == 0)
|
|||
|
return 0;
|
|||
|
|
|||
|
//Fill in request structure
|
|||
|
SNAP_PARAMS snapparams = { 0 };
|
|||
|
snapparams.Channel = 0;
|
|||
|
snapparams.mode = 0;
|
|||
|
snapparams.CmdSerial = 0;
|
|||
|
|
|||
|
BOOL b = CLIENT_SnapPicture(m_lLoginId, snapparams);
|
|||
|
if (!b)
|
|||
|
{
|
|||
|
//<2F><><EFBFBD>ӳɹ<D3B3><C9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽʧ<CABD>ܵ<EFBFBD><DCB5><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
//MessageBox(ConvertString("begin to snap failed!"), ConvertString("prompt"));
|
|||
|
}
|
|||
|
return 0;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
void CDahuaFisheyeCamera::OnTimer(UINT_PTR nIDEvent)
|
|||
|
{
|
|||
|
// TODO: <20>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>/<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĭ<EFBFBD><C4AC>ֵ
|
|||
|
if (nIDEvent == TIMER_LOGIN)
|
|||
|
{
|
|||
|
//<2F>豸<EFBFBD>Ͽ<EFBFBD><CFBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>´<EFBFBD><C2B4><EFBFBD>
|
|||
|
}
|
|||
|
|
|||
|
CDialog::OnTimer(nIDEvent);
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
void CDahuaFisheyeCamera::OnDestroy()
|
|||
|
{
|
|||
|
CDialog::OnDestroy();
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
void CDahuaFisheyeCamera::TargetDetection(int nCameraIdx, cv::Mat &mat_img, vector<CRect> &findRects)
|
|||
|
{
|
|||
|
CRect findRect;
|
|||
|
try {
|
|||
|
cv::Mat dst = mat_img;
|
|||
|
//cv::Size newSize(mat_img.size().width / 4, mat_img.size().height / 4); // <20><><EFBFBD><EFBFBD><EFBFBD>µijߴ<C4B3>
|
|||
|
//cv::resize(mat_img, dst, newSize); // <20><><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD>ߴ<EFBFBD>
|
|||
|
|
|||
|
auto det_image = theApp.m_yoloV4.m_pDetector->mat_to_image_resize(dst);
|
|||
|
|
|||
|
auto start = std::chrono::steady_clock::now();
|
|||
|
std::vector<bbox_t> result_vec = theApp.m_yoloV4.m_pDetector->detect_resized(*det_image, dst.size().width, dst.size().height);
|
|||
|
auto end = std::chrono::steady_clock::now();
|
|||
|
std::chrono::duration<double> spent = end - start;
|
|||
|
std::cout << " Time: " << spent.count() << " sec \n";
|
|||
|
|
|||
|
theApp.m_yoloV4.DrawObjectBoxes(dst, result_vec, theApp.m_yoloV4.m_vObjects_Names);
|
|||
|
|
|||
|
for (int i = 0; i < result_vec.size(); i++)
|
|||
|
{
|
|||
|
bbox_t result_area = result_vec.at(i);
|
|||
|
std::string obj_name = theApp.m_yoloV4.m_vObjects_Names[result_area.obj_id];
|
|||
|
//if (result_area.prob >= 0.9 && (0 == obj_name.compare("up") ))
|
|||
|
{
|
|||
|
CRect rect;
|
|||
|
rect.left = result_area.x;
|
|||
|
rect.top = result_area.y;
|
|||
|
rect.right = result_area.x + result_area.w;
|
|||
|
rect.bottom = result_area.y + result_area.h;
|
|||
|
findRects.push_back(rect);
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
catch (std::exception &e) { std::cerr << "exception: " << e.what() << "\n"; getchar(); }
|
|||
|
catch (...) { std::cerr << "unknown exception \n"; getchar(); }
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|