Ejemplo n.º 1
0
def kinfu_demo():
    parser = ArgumentParser()
    parser.add_argument(
        "-i",
        "--input",
        help="Required. Path to folder with a input image file",
        required=True,
        type=str)
    parser.add_argument("-t",
                        "--large_kinfu",
                        help="Required. Name of KinFu type",
                        required=False,
                        type=str)
    parser.add_argument("-ocl",
                        "--use_opencl",
                        help="Required. Flag of OpenCL use",
                        required=False,
                        type=int,
                        default=1)

    args = parser.parse_args()
    print("Args: ", args)

    cv.ocl.setUseOpenCL(args.use_opencl)

    if (args.large_kinfu == None or args.large_kinfu == "0"):
        params = cv.kinfu_Params.defaultParams()
        kf = cv.kinfu_KinFu.create(params)
    elif (args.large_kinfu == "1"):
        params = cv.kinfu_Params.hashTSDFParams(False)
        kf = cv.kinfu_KinFu.create(params)
    else:
        raise ValueError("Incorrect kinfu type name")

    depth_list = get_depth_list(args.input)
    for path in depth_list:

        image = cv.imread(path, cv.IMREAD_ANYDEPTH)
        (height, width) = image.shape

        cv.imshow('input', image)

        size = height, width, 4
        cvt8 = np.zeros(size, dtype=np.uint8)

        if not kf.update(image):
            kf.reset()
        else:
            kf.render(cvt8)
            cv.imshow('render', cvt8)
        cv.pollKey()
    cv.waitKey(0)
Ejemplo n.º 2
0
def show_img(img, win_title='-', wait4key=True):
    cv2.setWindowTitle(winname=WIN_NAME, title=win_title)
    cv2.imshow(WIN_NAME, img)
    if wait4key:
        key = chr(cv2.waitKey())
    else:
        key = cv2.pollKey()
        if key >= 0:
            key = chr(key)
    return key
Ejemplo n.º 3
0
    img_rep = represent.represent(img_aln, input_shape)

    retrieved_img = img_rep[0][:, :, ::-1]
    plt.imshow(retrieved_img)
    plt.show()

    return "Registered"


video_capture = cv2.VideoCapture(0)
while True:

    ret, frame = video_capture.read()

    detections = detect.getDetections(frame, face_detector)
    if detections != None:
        orig_frame = frame.copy()
        for detection in detections:
            x, y, w, h = detection["box"]
            cv2.rectangle(frame, (x, y + h), (x + w, y), (0, 0, 255), 2)
            cv2.imshow('Video', frame)

    keyPress = cv2.pollKey() & 0xFF
    if keyPress == ord('r'):
        register(face_detector, model, input_shape, orig_frame, detections)
    elif keyPress == ord('q'):  # Hit 'q' on the keyboard to quit!
        print("..... Quiting")
        break

video_capture.release()
cv2.destroyAllWindows()
Ejemplo n.º 4
0
Archivo: test.py Proyecto: jddes/pyebus
while 1:
    t1 = time.perf_counter()
    kImage += 1
    (img_buffer, img_info) = ebus.getImage(timeoutMS)
    # print(img_info)
    t2 = time.perf_counter()
    info = expand_img_info_tuple(img_info)
    # print(info)
    # TODO: processing goes here
    # hint: map the image into a numpy array by doing np.frombuffer(img_buffer, np.uint16)
    img_np = np.frombuffer(img_buffer, np.uint16)
    img_np = img_np.reshape(info['Height'], info['Width'])
    t3 = time.perf_counter()
    cv2.imshow('Press any key to stop', img_np)
    if cv2.pollKey() != -1:
        break
    t4 = time.perf_counter()
    print(
        "kImage=%d, t(getImage)=%.3f ms, t(numpy)=%.3f ms, t(cv)=%.3f ms, min, max: %d, %d"
        % (kImage, (t2 - t1) * 1e3, (t3 - t2) * 1e3,
           (t4 - t3) * 1e3, np.min(img_np), np.max(img_np)))

    ebus.releaseImage()
##################### End   image processing loop #####################

# ebus.openDeviceSerialPort()
ebus.writeSerialPort('test string\n')
result = ebus.readSerialPort(10, 500)
print(result)
ebus.closeDeviceSerialPort()