NET_DVR_POINT_FRAME ptFrame;
//int left, int top, int right, int bottom
//这里放一个在画面框选的矩形 我这里是用了识别出来的矩形模拟
Rectangle ec = new Rectangle();
ec = Rectangle.FromLTRB(933, 213, 1175, 614);
//divides the width and height to 255 proportion
ptFrame.xTop = (int)(ec.Left * 255 / RealPlayWnd.Width);
ptFrame.yTop = (int)(ec.Top * 255 / RealPlayWnd.Height);
ptFrame.xBottom = (int)(ec.Right * 255 / RealPlayWnd.Width);
ptFrame.yBottom = (int)(ec.Bottom * 255 / RealPlayWnd.Height);
if (ec.Left < ec.Right)
{
if (ec.Top < ec.Bottom)
{
ptFrame.bCounter = 4;
}
else
{
ptFrame.bCounter = 2;
}
}
else
{
if (ec.Top < ec.Bottom)
{
ptFrame.bCounter = 3;
}
else
{
ptFrame.bCounter = 1;
}
}
bool bRet = CHCNetSDK.NET_DVR_PTZSelZoomIn_EX(m_lUserID, 1, ref ptFrame);
//还有之前自己写的一个,现在在这做下备份:
multiple=CenterX/27 #倍数
if(CopyObjectCenterX<CenterX):
ShiJiX=int(wTPanPos-(CenterX-int(CopyObjectCenterX))/multiple)
if(ShiJiX<0): #如果小于0加360度
ShiJiX=ShiJiX+360
else:
ShiJiX=int(wTPanPos+int((CopyObjectCenterX)-CenterX)/multiple)
if(ShiJiX>360): #如果大于360 就-360度
ShiJiX=ShiJiX-360
if(CopyObjectCenterY<CenterY):
ShiJiY=int(wTTiltPos-(CenterY-int(CopyObjectCenterY))/multiple)
if(ShiJiY<0): #如果小于0加360度
ShiJiY=ShiJiY+90
else:
ShiJiY=int(wTTiltPos+int((CopyObjectCenterY)-CenterY)/multiple)
if(ShiJiY>90): #如果大于360 就-360度
ShiJiY=ShiJiY-90
convertT="0x"+str(ShiJiX*10)
print("convertT:"+str(convertT));
PP=int(convertT, 16)
print("PP:"+str(PP));
convertQ="0x"+str(abs(ShiJiY*10))
TP=int(convertQ, 16)
convertZ="0x"+str(abs(2*10))
TZ=int(convertZ, 16)
#云台参数传输到云台
ptrPicCfgX=NET_DVR_PTZPOS()
ptrPicCfgX.wAction=1
ptrPicCfgX.wZoomPos=TZ
ptrPicCfgX.wPanPos=PP
ptrPicCfgX.wTiltPos=TP
Objdll.NET_DVR_SetDVRConfig(lUserId,292, 1, byref(ptrPicCfgX),sys.getsizeof(NET_DVR_PTZPOS))