Skip to content
Snippets Groups Projects
Commit 9bcc0648 authored by Chevalier Paul's avatar Chevalier Paul
Browse files

Edit gopro.py

parent 2e71a7ae
No related branches found
No related tags found
No related merge requests found
import cv2
import numpy as np
import goprocam
from goprocam import GoPro
#modif
def list_cameras():
""" Liste les caméras disponibles et retourne leurs indices. """
index = 0
available_cameras = []
while True:
cap = cv2.VideoCapture(index)
if not cap.read()[0]:
break
else:
available_cameras.append(index)
cap.release()
index += 1
return available_cameras
def select_camera():
cameras = list_cameras()
if not cameras:
print("Aucune caméra détectée.")
return None
print("Caméras disponibles :", cameras)
selected = int(input("Sélectionnez l'indice de votre GoPro : "))
return selected if selected in cameras else None
def record_video(camera_index):
cap = cv2.VideoCapture(camera_index)
if not cap.isOpened():
print("Impossible d'accéder à la caméra.")
return
fourcc = cv2.VideoWriter_fourcc(*'XVID')
out = cv2.VideoWriter('gopro_output.avi', fourcc, 30.0, (640, 480))
while True:
ret, frame = cap.read()
if not ret:
break
cv2.imshow('GoPro Video', frame)
out.write(frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
out.release()
cv2.destroyAllWindows()
if __name__ == "__main__":
print("Connexion à la GoPro...")
gopro = GoPro.GoPro()
gopro.webcamFOV("medium")
gopro.startWebcam()
cam_index = select_camera()
if cam_index is not None:
record_video(cam_index)
else:
print("Sélection invalide.")
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment