Script bench camera : mesure temps preview et capture gphoto2
This commit is contained in:
43
scripts/bench_camera.py
Normal file
43
scripts/bench_camera.py
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""Test direct gphoto2 : mesure temps preview et capture."""
|
||||||
|
import time
|
||||||
|
|
||||||
|
try:
|
||||||
|
import gphoto2 as gp
|
||||||
|
except ImportError:
|
||||||
|
print("gphoto2 non installe")
|
||||||
|
exit(1)
|
||||||
|
|
||||||
|
cam = gp.Camera()
|
||||||
|
cam.init()
|
||||||
|
print("Camera connectee")
|
||||||
|
|
||||||
|
# Test preview
|
||||||
|
print("\n--- Preview (5 frames) ---")
|
||||||
|
times = []
|
||||||
|
for i in range(5):
|
||||||
|
t0 = time.time()
|
||||||
|
f = cam.capture_preview()
|
||||||
|
data = bytes(f.get_data_and_size())
|
||||||
|
dt = time.time() - t0
|
||||||
|
times.append(dt)
|
||||||
|
print("Frame " + str(i+1) + ": " + str(round(dt, 3)) + "s " + str(len(data)//1024) + "KB")
|
||||||
|
|
||||||
|
print("Moyenne preview: " + str(round(sum(times)/len(times), 3)) + "s")
|
||||||
|
|
||||||
|
# Test capture photo
|
||||||
|
print("\n--- Capture photo ---")
|
||||||
|
t0 = time.time()
|
||||||
|
chemin = cam.capture(gp.GP_CAPTURE_IMAGE)
|
||||||
|
dt_declenchement = time.time() - t0
|
||||||
|
print("Declenchement: " + str(round(dt_declenchement, 3)) + "s")
|
||||||
|
|
||||||
|
t1 = time.time()
|
||||||
|
cf = gp.CameraFile()
|
||||||
|
cam.file_get(chemin.folder, chemin.name, gp.GP_FILE_TYPE_NORMAL, cf)
|
||||||
|
data = bytes(cf.get_data_and_size())
|
||||||
|
dt_transfert = time.time() - t1
|
||||||
|
print("Transfert: " + str(round(dt_transfert, 3)) + "s " + str(len(data)//1024) + "KB")
|
||||||
|
print("Total capture: " + str(round(time.time() - t0, 3)) + "s")
|
||||||
|
|
||||||
|
cam.exit()
|
||||||
Reference in New Issue
Block a user