-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbackround_photo.py
27 lines (24 loc) · 937 Bytes
/
backround_photo.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
"""
Author: Konstantinos Angelopoulos
Date: 04/02/2020
All rights reserved.
Feel free to use and modify and if you like it give it a star.
Capture background and store it for fabric localization
"""
from pykinect2.PyKinectV2 import *
from pykinect2 import PyKinectV2
from pykinect2 import PyKinectRuntime
import cv2
import numpy as np
import os
# Create Kinect
kinect = PyKinectRuntime.PyKinectRuntime(PyKinectV2.FrameSourceTypes_Depth | PyKinectV2.FrameSourceTypes_Color)
shot = True # Flag for shot
# Loop until photo taken
while shot is True:
# wait until frame is returned
if kinect.has_new_color_frame():
color_frame = kinect.get_last_color_frame()
colorImage = color_frame.reshape((kinect.color_frame_desc.Height, kinect.color_frame_desc.Width, 4)).astype(np.uint8)
cv2.imwrite(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'images/background.png'), colorImage)
shot = False