rotate_image.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. from onvif import ONVIFCamera
  2. def rotate_image_180():
  3. ''' Rotate the image '''
  4. # Create the media service
  5. mycam = ONVIFCamera('192.168.0.112', 80, 'admin', '12345')
  6. media_service = mycam.create_media_service()
  7. profiles = media_service.GetProfiles()
  8. # Use the first profile and Profiles have at least one
  9. token = profiles[0]._token
  10. # Get all video source configurations
  11. configurations_list = media_service.GetVideoSourceConfigurations()
  12. # Use the first profile and Profiles have at least one
  13. video_source_configuration = configurations_list[0]
  14. # Enable rotate
  15. video_source_configuration.Extension[0].Rotate[0].Mode[0] = 'OFF'
  16. # Create request type instance
  17. request = media_service.create_type('SetVideoSourceConfiguration')
  18. request.Configuration = video_source_configuration
  19. # ForcePersistence is obsolete and should always be assumed to be True
  20. request.ForcePersistence = True
  21. # Set the video source configuration
  22. media_service.SetVideoSourceConfiguration(request)
  23. if __name__ == '__main__':
  24. rotate_image_180()