Test
This commit is contained in:
1 parent
a7f340497b
commit
cbccc651bd
1 file changed
+43
@@ -0,0 +1,43 @@
|
|||||||
|
import cv2
|
||||||
|
from pyk4a import PyK4A, Config, ColorResolution
|
||||||
|
|
||||||
|
def main():
|
||||||
|
# Konfiguration der Kamera (Standard: 1080p RGB)
|
||||||
|
k4a = PyK4A(
|
||||||
|
Config(
|
||||||
|
color_resolution=ColorResolution.RES_1080P,
|
||||||
|
synchronized_images_only=True,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
# Kamera starten
|
||||||
|
print("Starte Azure Kinect...")
|
||||||
|
k4a.start()
|
||||||
|
|
||||||
|
try:
|
||||||
|
while True:
|
||||||
|
# Frame von der Kamera abrufen
|
||||||
|
capture = k4a.get_capture()
|
||||||
|
|
||||||
|
# Prüfen, ob ein Farbbild vorhanden ist
|
||||||
|
if capture.color is not None:
|
||||||
|
# Das RGB-Bild der Kinect kommt im BGRA-Format
|
||||||
|
# OpenCV benötigt BGR für die korrekte Anzeige
|
||||||
|
frame = cv2.cvtColor(capture.color, cv2.COLOR_BGRA2BGR)
|
||||||
|
|
||||||
|
# Bild im Fenster anzeigen
|
||||||
|
cv2.imshow("Azure Kinect - Live Stream", frame)
|
||||||
|
|
||||||
|
# Beenden mit der Taste 'q' oder ESC (Taste 27)
|
||||||
|
key = cv2.waitKey(1) & 0xFF
|
||||||
|
if key == ord('q') or key == 27:
|
||||||
|
print("Beende Stream...")
|
||||||
|
break
|
||||||
|
|
||||||
|
finally:
|
||||||
|
# Kamera sauber stoppen und Fenster schließen
|
||||||
|
k4a.stop()
|
||||||
|
cv2.destroyAllWindows()
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
Reference in new issue
Block a user