Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GoPro Hero 9 connected via USB - take_photo() not returning #199

Open
Peter-S-G opened this issue Sep 13, 2022 · 1 comment
Open

GoPro Hero 9 connected via USB - take_photo() not returning #199

Peter-S-G opened this issue Sep 13, 2022 · 1 comment

Comments

@Peter-S-G
Copy link

Peter-S-G commented Sep 13, 2022

@KonradIT

I was following a discussion from gopro/OpenGoPro#146. I connect my GoPro Hero 9 (firmware v1.21) to my MacBook Pro via USB. I am running code you provided AlanEbell in PyCharm with a little modification to account for the UUID (code is provided below). When I run the program, the code takes a photo and saves it onto the SD card in the GoPro but it does not download the photo onto my laptop and does not stop until I stop the program. When I tried gopro.shoot_video(10) the command would start taking a video but it would go over the 10 second duration until I manually stop the recording on the GoPro and the code. When I debug the issue I find out that the program is stuck at the command gopro.take_photo() or gopro.shoot_video() where the command is not being completed and that the command is going into an infinite loop at GoProCamera.py line 587 to 589 (for gopro.take_photo()) where ready = "" stating that it is still busy.

When I run the same code in Windows 10 (again in PyCharm), instead of getting an infinite loop I get an error message stating Connectionreseterror: [winerror 10054] an existing connection was forcibly closed by the remote host

What is weird is before I downgraded the firmware to v1.21, I ran the program and I was not able to take a photo or video but the program would be able to download the last saved photo/video from the SD card.

from goprocam import GoProCamera, constants
import netifaces as ni

interface_port = 0
ifaces = ni.interfaces()
for iface in ifaces:
    try:
        ip = ni.ifaddresses(iface)[ni.AF_INET][0]["addr"]
        if ip.startswith("172."):
            print(f"IP: {ip} from Interface {iface}")
            interface_port = iface
    except:
        pass


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

    print("Taking Photo")
    r = gopro.take_photo(1) # Error creating infinite while loop in GoProCamera.py line 587 to 589
    print(r)
    print("Photo Taken")
    gopro.downloadLastMedia()
    r = gopro.delete(constants.Delete.LAST)
    gopro.checkResponse(r)
    exit()


record_video(interface_port)

MacOS Monterey 12.5.1
Windows 10
PyCharm
GoPro Hero 9 v1.21

@Peter-S-G Peter-S-G reopened this Oct 5, 2022
@Sladerix
Copy link

Schermata 2022-11-17 alle 11 17 06

tried your code on macOS Monterey 12.6.1
with PyCharm and Python 3.10

Seems to work like intended

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants