Usa una GoPro como cámara web remota usando Python

Tengo una GoPro Hero 7 White y recientemente descubrí que puedo usarla como una cámara web remota usando un paquete de Python llamadoAPI de GoPro para Python, disponible enhttps://github.com/konradit/gopro-py-api.

Primero instale el paquete usandopip3 install goprocamluego habilite la conexión WiFi en la GoPro.

Esto hace que la GoPro inicie una red WiFi. Conéctese a esa red desde la computadora.

Ahora está listo para escribir su programa Python para hacer lo que quiera con la cámara web.

ImportarGoProCamerayconstantsdesdegoprocam:

from goprocam import GoProCamera, constants

Entonces llama alGoProCamera.GoPro()método para obtener un objeto de cámara:

gopro = GoProCamera.GoPro(constants.gpcontrol)

Obtenga una descripción general del estado de la cámara utilizando

gopro.overview()

En mi caso, imprimí esto:

camera overview
current mode: Photo
current submode: Burst
current video resolution: out of scope
current video framerate: 240
pictures taken: 0
videos taken:  0
videos left: 02:10:44
pictures left: 11257
battery left: Halfway
space left in sd card: 58.04GB
camera SSID: HERO7 White
Is Recording: Not recording - standby
Clients connected: 2
camera model: HERO7 White
firmware version: H18.02.02.10.00
serial number: C3343323864041

Now you can use a variety of methods that make the GoPro take actions.

You can take a photo immediately:

gopro.take_photo()

You can take a photo after 2 seconds:

gopro.take_photo(2)

You can shoot a 10-seconds video:

gopro.shoot_video(10)

Or just start recording, with no preset end time, using

gopro.shoot_video()

You can download the last picture or video taken using

gopro.downloadLastMedia()

You can also set a name for the file:

gopro.downloadLastMedia("pic.JPG")

Tip: I ran into a bug that prevented me to download the picture when I called downloadLastMedia(). I was getting errors that said “Not supported while recording or processing media”. I had to call gopro.getStatusRaw() before calling downloadLastMedia() to fix it.

There are many useful methods like

  • KeepAlive() to prevent the GoPro to turn off
  • setZoom() to set the zoom
  • downloadAll() to download all media from the camera
  • delete("last") to delete the last media taken
  • delete("all") to delete all media
  • power_off() power off the camera
  • power_on() power on the camera
  • stream() to start streaming (haven’t figured it out yet)

You can find many examples here and more documentation here.

The camera is available on IP 10.5.5.9, with the MAC address AA:BB:CC:DD:EE:FF.


More python tutorials: