创作人QQ:851301776,邮箱:lfr890207@163.com,欢迎大家一起技术交流,本博客主要是自己学习的心得体会,只为每天进步一点点!
个人座右铭:
1.没有横空出世,只要厚积一定发。
2.你可以学历不高,你可以不上学,但你不能不学习
一、介绍
这里主要是以测试实现功能为准则,并没有进一步的整理和优化,测试完成功能后,后期项目进行整理。
ONVIF网上介绍的很多,还有很多对实现进行介绍的,这里不做介绍,网上很多的获取设备能力、获取音视频数据等都有,这里主要贴云台控制。
二、绝对移动
1.或者云台地址
ONVIF_GetCapabilities(DeviceXAddr, ptzXAddr);
2.获取配置文件token
ONVIF_GetProfiles(ptzXAddr, profilesToken);
3.绝对移动(切记使用动态分配)
int ONVIF_PTZAbsoluteMove(const char *ptzXAddr, const char *ProfileToken)
{
int result = 0;
struct soap *soap = NULL;
struct _tptz__AbsoluteMove absoluteMove;
struct _tptz__AbsoluteMoveResponse absoluteMoveResponse;
SOAP_ASSERT(ptzXAddr != NULL);
SOAP_ASSERT(NULL != (soap = ONVIF_soap_new(SOAP_SOCK_TIMEOUT)));
ONVIF_SetAuthInfo(soap, USERNAME, PASSWORD);
absoluteMove.ProfileToken = (char *)soap_malloc(soap, 128);
memcpy(absoluteMove.ProfileToken, "MediaProfile00000", strlen("MediaProfile00000"));
printf("absoluteMove.ProfileToken = %s\n", absoluteMove.ProfileToken);
absoluteMove.Position = soap_new_tt__PTZVector(soap,sizeof(struct tt__PTZVector));
absoluteMove.Position->PanTilt = soap_new_tt__Vector2D(soap, sizeof(struct tt__Vector2D));
absoluteMove.Position->Zoom = soap_new_tt__Vector1D(soap, sizeof(struct tt__Vector1D));
absoluteMove.Speed = soap_new_tt__PTZSpeed(soap, sizeof(struct tt__PTZSpeed));
absoluteMove.Speed->PanTilt = soap_new_tt__Vector2D(soap, sizeof(struct tt__Vector2D));
absoluteMove.Speed->Zoom = soap_new_tt__Vector1D(soap, sizeof(struct tt__Vector1D));
absoluteMove.Position->PanTilt->x = 0; // p
absoluteMove.Position->PanTilt->y = 0; // t
absoluteMove.Position->Zoom->x = -1; // z
// x 和y的绝对值越接近1,表示云台的速度越快
absoluteMove.Speed->PanTilt->x = 0;
absoluteMove.Speed->PanTilt->y = 0;
absoluteMove.Speed->Zoom->x = 1;
result = soap_call___tptz__AbsoluteMove(soap,ptzXAddr, NULL,&absoluteMove,&absoluteMoveResponse);
SOAP_CHECK_ERROR(result, soap, "ONVIF_PTZAbsoluteMove");
printf("%s result = %d \n", __func__);
EXIT:
if (NULL != soap) {
ONVIF_soap_delete(soap);
}
return 0;
}
4.相对移动
void ONVIF_PTZMoveStep(const char *ptzXAddr, char *ProfileToken, enum ptz_common cmd, float move_step)
{
SOAP_ASSERT(NULL != ptzXAddr);
SOAP_ASSERT(NULL != ProfileToken);
float MoveStep = 0;
if(move_step >= 1)
MoveStep = 0.9;
else{
MoveStep = move_step;
}
struct soap *soap = NULL;
SOAP_ASSERT(NULL != (soap = ONVIF_soap_new(SOAP_SOCK_TIMEOUT)));
ONVIF_SetAuthInfo(soap, USERNAME, PASSWORD);
struct _tptz__RelativeMove RelativeMove;
struct _tptz__RelativeMoveResponse RelativeMoveResponse;
RelativeMove.ProfileToken = ProfileToken;
printf("tptz__RelativeMove.ProfileToken:%s\n", RelativeMove.ProfileToken);