27 lines
565 B
Python
27 lines
565 B
Python
import gphoto2 as gp
|
|
import cv2
|
|
import numpy as np
|
|
|
|
camera = gp.Camera()
|
|
camera.init()
|
|
|
|
def liveview():
|
|
while True:
|
|
# Pobierz klatkę z LiveView
|
|
file = camera.capture_preview()
|
|
data = file.get_data_and_size()
|
|
frame = np.frombuffer(data, dtype=np.uint8)
|
|
frame = cv2.imdecode(frame, cv2.IMREAD_COLOR)
|
|
|
|
if frame is not None:
|
|
cv2.imshow("LiveView", frame)
|
|
|
|
if cv2.waitKey(1) == 27: # ESC
|
|
break
|
|
|
|
cv2.destroyAllWindows()
|
|
camera.exit()
|
|
|
|
if __name__ == "__main__":
|
|
liveview()
|