Skip to content

Commit

Permalink
properly handle cameras without PTZ function
Browse files Browse the repository at this point in the history
  • Loading branch information
cedricve committed Jan 3, 2024
1 parent deb0a3f commit 9c97422
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions machinery/src/onvif/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,13 +311,18 @@ func GetPositionFromDevice(configuration models.Configuration) (xsdonvif.PTZVect
if err == nil {
// Get the PTZ configurations from the device
position, err := GetPosition(device, token)
if err == nil && position.PanTilt != nil && position.Zoom != nil {
// float to string
x := strconv.FormatFloat(position.PanTilt.X, 'f', 6, 64)
y := strconv.FormatFloat(position.PanTilt.Y, 'f', 6, 64)
z := strconv.FormatFloat(position.Zoom.X, 'f', 6, 64)
log.Log.Info("onvif.GetPositionFromDevice(): successfully got position (" + x + ", " + y + ", " + z + ")")
return position, err
if err == nil {
if position.PanTilt != nil && position.Zoom != nil {
// float to string
x := strconv.FormatFloat(position.PanTilt.X, 'f', 6, 64)
y := strconv.FormatFloat(position.PanTilt.Y, 'f', 6, 64)
z := strconv.FormatFloat(position.Zoom.X, 'f', 6, 64)
log.Log.Info("onvif.GetPositionFromDevice(): successfully got position (" + x + ", " + y + ", " + z + ")")
return position, err
} else {
log.Log.Debug("onvif.GetPositionFromDevice(): position is nil")
return position, errors.New("position is nil")
}
} else {
log.Log.Debug("onvif.GetPositionFromDevice(): " + err.Error())
return position, err
Expand Down

0 comments on commit 9c97422

Please sign in to comment.