Home > Back-end >  Hai kang network camera C encapsulation
Hai kang network camera C encapsulation

Time:02-06

I do hai kang camera development recently, want to have a function of the SDK encapsulated, encounter a problem, also please god to see see!
This is my own class
The class Grab_picture {
Public:
Grab_picture ();
Void CALLBACK DecCBFun (long nPort, char * pbufs, long nSize, FRAME_INFO * pFrameInfo, long nReserved1, long nReserved2);
Void fRealDataCallBack (LONG lRealHandle dwords dwDataType, BYTE * pBuffer, dwords dwBufSize, void * pUser);

};
In the function implementation and encounter such problem
if (! PlayM4_SetDecCallBack (nPort, DecCBFun))//get the data flow
27 IntelliSense error: "void (Grab_picture: : *) (long nPort, char * pbufs, long nSize, FRAME_INFO * pFrameInfo, long nReserved1, long nReserved2)" type of real participation "void (__stdcall *) (long nPort, char * pbufs, long nSize, FRAME_INFO * pFrameInfo, long nReserved1, long nReserved2)" type parameter is not compatible with
Idea is to cast, could you tell me how to turn?

CodePudding user response:

Function parameters, then try direct call

CodePudding user response:

//decoding callback for YUV video data (YV12), audio for PCM data
Void CALLBACK DecCBFun (long nPort, char * pbufs, long nSize, FRAME_INFO * pFrameInfo, long nReserved1, long nReserved2)
{
Long lFrameType=pFrameInfo - & gt; NType;

If (lFrameType==T_YV12)
{
Mat frame;
Frame. The create (Size (pFrameInfo - & gt; NWidth, pFrameInfo - & gt; NHeight), CV_8UC1);
Memcpy (frame data, pbufs pFrameInfo - & gt; NWidth * pFrameInfo - & gt; NHeight);
Imshow (" IP Camera, "frame);
WaitKey (1);
}
}


///real-time flow callback
Void CALLBACK fRealDataCallBack (LONG lRealHandle dwords dwDataType, BYTE * pBuffer, dwords dwBufSize, void * pUser)
{
DWORD dRet;
The switch (dwDataType)
{
Case NET_DVR_SYSHEAD://system head
if (! PlayM4_GetPort (& amp; NPort))//access to play library unused channel number
{
break;
}
If (dwBufSize & gt; 0)
{
if (! PlayM4_OpenStream (nPort, pBuffer, dwBufSize, 1024 * 1024))
{
DRet=PlayM4_GetLastError (nPort);
break;
}
//set the decoding callback function only decoding does not display the
if (! PlayM4_SetDecCallBack (nPort, DecCBFun))
{
DRet=PlayM4_GetLastError (nPort);
break;
}

//set the decoding the callback function to decode and display
//if (! PlayM4_SetDecCallBackEx (nPort, DecCBFun, NULL, NULL))
//{
//dRet=PlayM4_GetLastError (nPort);
//break;
//}

//open the video decoding
if (! PlayM4_Play (nPort, hWnd))
{
DRet=PlayM4_GetLastError (nPort);
break;
}

//open the audio decoding, code flow is compound flow
if (! PlayM4_PlaySound (nPort))
{
DRet=PlayM4_GetLastError (nPort);
break;
}
}
break;

Case NET_DVR_STREAMDATA://stream data
If (dwBufSize & gt; 0 & amp; & NPort!=1)
{
BOOL inData=https://bbs.csdn.net/topics/PlayM4_InputData (nPort, pBuffer, dwBufSize);
while (! InData)
{
Sleep(10);
inData=https://bbs.csdn.net/topics/PlayM4_InputData (nPort, pBuffer, dwBufSize);
OutputDebugString (L "PlayM4_InputData failed \ n");
}
}
break;
}
}

CodePudding user response:

//decoding callback for YUV video data (YV12), audio for PCM data 
Void CALLBACK DecCBFun (long nPort, char * pbufs, long nSize, FRAME_INFO * pFrameInfo, long nReserved1, long nReserved2)
{
Long lFrameType=pFrameInfo - & gt; NType;

If (lFrameType==T_YV12)
{
Mat frame;
Frame. The create (Size (pFrameInfo - & gt; NWidth, pFrameInfo - & gt; NHeight), CV_8UC1);
Memcpy (frame data, pbufs pFrameInfo - & gt; NWidth * pFrameInfo - & gt; NHeight);
Imshow (" IP Camera, "frame);
WaitKey (1);
}
}


///real-time flow callback
Void CALLBACK fRealDataCallBack (LONG lRealHandle dwords dwDataType, BYTE * pBuffer, dwords dwBufSize, void * pUser)
{
DWORD dRet;
The switch (dwDataType)
{
Case NET_DVR_SYSHEAD://system head
if (! PlayM4_GetPort (& amp; NPort))//access to play library unused channel number
{
break;
}
If (dwBufSize & gt; 0)
{
if (! PlayM4_OpenStream (nPort, pBuffer, dwBufSize, 1024 * 1024))
{
DRet=PlayM4_GetLastError (nPort);
break;
}
//set the decoding callback function only decoding does not display the
if (! PlayM4_SetDecCallBack (nPort, DecCBFun))
{
DRet=PlayM4_GetLastError (nPort);
break;
}

//set the decoding the callback function to decode and display
//if (! PlayM4_SetDecCallBackEx (nPort, DecCBFun, NULL, NULL))
//{
//dRet=PlayM4_GetLastError (nPort);
//break;
//}

//open the video decoding
if (! PlayM4_Play (nPort, hWnd))
{
DRet=PlayM4_GetLastError (nPort);
break;
}

//open the audio decoding, code flow is compound flow
if (! PlayM4_PlaySound (nPort))
{
DRet=PlayM4_GetLastError (nPort);
break;
}
}
break;

Case NET_DVR_STREAMDATA://stream data
If (dwBufSize & gt; 0 & amp; & NPort!=1)
{
BOOL inData=https://bbs.csdn.net/topics/PlayM4_InputData (nPort, pBuffer, dwBufSize);
while (! InData)
{
Sleep(10);
inData=https://bbs.csdn.net/topics/PlayM4_InputData (nPort, pBuffer, dwBufSize);
OutputDebugString (L "PlayM4_InputData failed \ n");
}
}
break;
}
}

CodePudding user response:

CodePudding user response:

This is real-time real-time preview callback, how to answer the subsequent face detection algorithm? Need a packaging? Or how to do? null
  • Related