Skip to content

Commit

Permalink
[WIP] Hero10 support (#181)
Browse files Browse the repository at this point in the history
* Hero10 initial support

* Update to 4.2.0: Hero10 support, OpenGoPro v2 support
  • Loading branch information
KonradIT committed Feb 12, 2022
1 parent 6582015 commit 9c184f5
Show file tree
Hide file tree
Showing 7 changed files with 242 additions and 67 deletions.
26 changes: 26 additions & 0 deletions README.md
Expand Up @@ -5,6 +5,23 @@
Unofficial GoPro API Library for Python - connect to GoPro cameras via WiFi.
![](http://i.imgur.com/kA0Rf1b.png)

## Notice:

Project has been updated to support Hero10 Black + OpenGoPro v2 + USB control. Further is needed to support these features:

- Python3.8 typing
- Custom exceptions
- Integration tests
- BLE support (using [gopro-ble-py](https://github.com/konradit/gopro-ble-py))
- Hero9 (v1.21 & 1.22 fw) / Hero10 (OpenGoPro v2) USB identifier Autodiscovery
- Stacktraces
- More robust examples, with boilerplate code ready for use

Project covers a decade worth of camera releases, naturally something might've broken as development focuses on the newer cameras. Hopefully nothing broke.

Acknowledgments to GoPro for the OpenGoPro API spec release.

\- @konradit
### Compatibility:

- HERO3
Expand All @@ -18,6 +35,15 @@ Unofficial GoPro API Library for Python - connect to GoPro cameras via WiFi.
- HERO8 Black
- MAX
- HERO9 Black
- HERO10 Black

## WiFi vs USB:

Hero3..Hero8 (incl. MAX/Fusion/Session) all use WiFi (and some use Bluetooth) for controls, media management, status updates and live preview

Hero9 Black and Hero10 Black have Webcam functionality, and Hero10 Black is officially exposing the API server over USB Ethernet with full camera control capabilities

Hero9 Black requires using an older firmware to get ability to take photos. See [the compatibility chart](https://github.com/KonradIT/goprowifihack/blob/master/HERO9/HERO9-Functionality-Compatibility-Chart.md)

### Installation

Expand Down
21 changes: 19 additions & 2 deletions examples/hero9-take-photo-webcam.py
@@ -1,17 +1,34 @@
import sys
import time
from goprocam import GoProCamera, constants
from goprocam import GoProCamera, constants, exceptions
import threading
from signal import signal, SIGINT

isOpenGoPro = True


def take_photo(interface):
gopro = GoProCamera.GoPro(ip_address=GoProCamera.GoPro.getWebcamIP(
interface), camera=constants.gpcontrol, webcam_device=interface)
interface), camera=constants.gpcontrol, webcam_device=interface, api_type=constants.ApiServerType.OPENGOPRO if isOpenGoPro else constants.ApiServerType.SMARTY)
try:
r = gopro.setWiredControl(constants.on)
print(r)
except exceptions.WiredControlAlreadyEstablished:
pass # sometimes throws 500 server error when camera is already on wired control mode

while True:
gopro.take_photo()
time.sleep(2)
print("Photo taken")
exit()


def handler(s, f):
thr.stop()
quit()


signal(SIGINT, handler)

cameras = sys.argv[1]
cameras = cameras.split(",")
Expand Down
6 changes: 5 additions & 1 deletion examples/launch_webcam_preview.py
Expand Up @@ -13,7 +13,11 @@ def handler(s, f):

signal(SIGINT, handler)

# gopro.startWebcam(constants.Webcam.Resolution.R720p)
try:
gopro.setWiredControl(constants.off)
except:
pass
gopro.startWebcam(constants.Webcam.Resolution.R720p)
gopro.webcamFOV(constants.Webcam.FOV.Linear)
gopro.getWebcamPreview()
gopro.KeepAlive()
36 changes: 36 additions & 0 deletions examples/opengopro-record_video.py
@@ -0,0 +1,36 @@
import sys
import time
from goprocam import GoProCamera, constants
import threading
from signal import signal, SIGINT


def record_video(interface: str) -> None:

gopro = GoProCamera.GoPro(ip_address=GoProCamera.GoPro.getWebcamIP(
interface), camera=constants.gpcontrol, webcam_device=interface, api_type=constants.ApiServerType.OPENGOPRO)
try:
r = gopro.setWiredControl(constants.on)
gopro.checkResponse(r)
except:
pass # sometimes throws 500 server error when camera is already on wired control mode

r = gopro.shoot_video(10)
print(r)
print("Video recorded")
exit()


def handler(s, f):
thr.stop()
quit()


signal(SIGINT, handler)

cameras = sys.argv[1]
cameras = cameras.split(",")

for interface in cameras:
thr = threading.Thread(target=record_video, args=(interface,))
thr.start()

0 comments on commit 9c184f5

Please sign in to comment.