예제 #1
0
    gridshape = (30, 60)
    rows, cols = np.indices(gridshape)
    rows = (1080 * rows / gridshape[0]).astype(np.int32)
    cols = (1920 * cols / gridshape[1]).astype(np.int32)
    y_coords = rows.flatten()
    x_coords = cols.flatten()
else:
    y_coords = np.ones([1920]) * 1080 / 2
    x_coords = np.arange(1920)

k = Kinect()
k.start()

for i in range(500):
    start = time.time()
    rgb, d = k.get_current_rgbd_frame(copy=False)
    rgb[..., 2] = np.logical_or(d > 5000, d < 150) * 255
    print("kinect time: %f\t" % (time.time() - start), end="")
    cv2.imshow('color', rgb)
    cv2.waitKey(1)

    start = time.time()

    if GRID_VS_LINE:
        d_coord = d[rows, cols].flatten()
    else:
        d_coord = d[540, :]

    print(d_coord.shape, x_coords.shape, y_coords.shape)
    valid = np.logical_and(d_coord < 5000, d_coord > 150)
    d_coord_i = d_coord[valid]
예제 #2
0
import time
import pickle

from project_gl import Projector

width, height = 1920, 1080

M = pickle.load(open('direct_model/correspondances/one_matrix.pickle', 'rb'))
M = np.concatenate([M, [[0, 0, 0, 0]]], 0)

p = Projector(M,
              x_res=width,
              y_res=height,
              proj_x_res=1366,
              proj_y_res=768,
              monitor=1)

from kinect import Kinect
k = Kinect()
k.start()

# depth = 1000 * np.ones([height, width], dtype=np.float32)
while True:
    # rgb = 255*np.random.rand(height, width, 3)
    # rgb = np.random.randint(0, 255, size=[height, width, 3])
    rgb, depth = k.get_current_rgbd_frame()
    if p.draw_frame(255 - rgb[..., :3], depth):
        p.stop()

k.stop()
예제 #3
0
import numpy as np
from kinect import Kinect

k = Kinect()
k.start()

config_file = "mask_rcnn_demo/maskrcnn-benchmark/configs/caffe2/e2e_mask_rcnn_R_50_FPN_1x_caffe2.yaml"

# update the config options with the config file
cfg.merge_from_file(config_file)
# manual override some options
cfg.merge_from_list(["MODEL.DEVICE", "cuda"])

coco_demo = COCODemo(
    cfg,
    min_image_size=800,
    confidence_threshold=0.7,
)
# load image and then run prediction

while True:
    print('a')
    image, d = k.get_current_rgbd_frame(copy=True)
    image = image[..., :3]
    print('d')
    predictions = coco_demo.run_on_opencv_image(image)
    print('c')
    print(predictions.shape, predictions.dtype)

k.stop()
예제 #4
0
M = pickle.load(open('direct_model/correspondances/one_matrix.pickle', 'rb'))
# M = np.array([
#     [1, 0, 0, 0],
#     [0, 1, 0, 0],
#     [0, 0, 1, 0],
# ])

k = Kinect()
k.start()

dr = DrawingWindow()
dr.update()

for i in range(100):
    print(i)
    rgb, _ = k.get_current_rgbd_frame(copy=True)
    dr.last_kinect_frame = rgb[..., :3]
    dr.update()

dr.close()

w = Fullscreen_Window()
w.clear()
w.update()

for i in range(500):
    rgb, d = k.get_current_rgbd_frame(copy=False)

    locs = np.array(dr.circles)
    print('circle shapes', locs.shape)
    rgb[..., 2] = np.logical_or(d > 5000, d < 150) * 255