云台控制也是onvif功能中最常用的,最常用的功能排第一的是拿到视频流地址,排第二的就是云台控制了,云台控制的含义就是对带云台的摄像机进行上下左右的移动,一般云台摄像机都是带有一个小电机,一旦收到485或者网络来的正确的指令以后就触发单片机程序,然后单片机程序驱动电机进行转动,所以相对来说云台摄像机比普通的摄像机更耗电,当然价格也更贵。
云台控制的发送命令除了用户信息玩主要就三个核心参数xyz,通过这三个参数的组合来实现云台和焦距的控制,云台的转动主要就是改变xy的值,焦距的控制通过改变z的值来实现。
云台控制说明:
onvif主要的功能:
onvif的处理流程:
void frmPtz::moveAbsolute()
{
OnvifDevice *device = frm->getCurrentDevice();
if (device) {
QString profile = frm->getProfile();
device->moveAbsolute(profile, x, y, z);
frm->append(5, QString("执行绝对移动-> x: %1 y: %2 z: %3").arg(x).arg(y).arg(z));
}
}
void frmPtz::moveRelative()
{
OnvifDevice *device = frm->getCurrentDevice();
if (device) {
QString profile = frm->getProfile();
device->moveRelative(profile, x, y, z);
frm->append(5, QString("执行相对移动-> x: %1 y: %2 z: %3").arg(x).arg(y).arg(z));
}
}
void frmPtz::setFrm(frmMain *frm)
{
this->frm = frm;
}
void frmPtz::on_btnPtzUp_clicked()
{
if (ui->rbtnMoveRelative->isChecked()) {
x = 0.0;
y = 0.1;
z = 0.0;
moveRelative();
} else {
y = 0.1;
moveAbsolute();
}
}
void frmPtz::on_btnPtzDown_clicked()
{
if (ui->rbtnMoveRelative->isChecked()) {
x = 0.0;
y = -0.1;
z = 0.0;
moveRelative();
} else {
y = -0.0;
moveAbsolute();
}
}
void frmPtz::on_btnPtzLeft_clicked()
{
if (ui->rbtnMoveRelative->isChecked()) {
x = -0.1;
y = 0.0;
z = 0.0;
moveRelative();
} else {
x = 0.0;
moveAbsolute();
}
}
void frmPtz::on_btnPtzRight_clicked()
{
if (ui->rbtnMoveRelative->isChecked()) {
x = 0.1;
y = 0.0;
z = 0.0;
moveRelative();
} else {
x = 0.1;
moveAbsolute();
}
}
void frmPtz::on_btnPtzLeftUp_clicked()
{
if (ui->rbtnMoveRelative->isChecked()) {
x = -0.1;
y = 0.1;
z = 0.0;
moveRelative();
} else {
x = 0.0;
y = 0.0;
moveAbsolute();
}
}
void frmPtz::on_btnPtzLeftDown_clicked()
{
if (ui->rbtnMoveRelative->isChecked()) {
x = -0.1;
y = -0.1;
z = 0.0;
moveRelative();
} else {
x = 0.1;
y = 0.1;
moveAbsolute();
}
}
void frmPtz::on_btnPtzRightUp_clicked()
{
if (ui->rbtnMoveRelative->isChecked()) {
x = 0.1;
y = 0.1;
z = 0.0;
moveRelative();
} else {
x = 0.0;
y = 0.0;
moveAbsolute();
}
}
void frmPtz::on_btnPtzRightDown_clicked()
{
if (ui->rbtnMoveRelative->isChecked()) {
x = 0.1;
y = -0.1;
z = 0.0;
moveRelative();
} else {
x = 0.1;
y = 0.1;
moveAbsolute();
}
}
void frmPtz::on_btnPtzZoomIn_clicked()
{
if (ui->rbtnMoveRelative->isChecked()) {
x = 0.0;
y = 0.0;
z = 0.01;
moveRelative();
} else {
z = 0.01;
moveAbsolute();
}
}
void frmPtz::on_btnPtzZoomOut_clicked()
{
if (ui->rbtnMoveRelative->isChecked()) {
x = 0.0;
y = 0.0;
z = -0.01;
moveRelative();
} else {
z = 0.0;
moveAbsolute();
}
}
void frmPtz::on_btnPtzStop_clicked()
{
OnvifDevice *device = frm->getCurrentDevice();
if (device) {
frm->setText("ptzStop");
QString profile = frm->getProfile();
device->moveStop(profile);
}
}
void frmPtz::on_btnPtzReset_clicked()
{
x = 0.0;
y = 0.0;
z = 0.0;
moveAbsolute();
}
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有