Exemplo n.º 1
0
import pymynt
import cv2

pymynt.init_camera()
while True:
    depth = pymynt.get_depth_image()
    left = pymynt.get_left_image()

    if left.size>10:
        cv2.imshow('left', left)
        cv2.waitKey(10)
Exemplo n.º 2
0
import cv2
import pymynt
import numpy as np
import time

watching_point = None


def printDepth(event, x, y, flags, param):
    global watching_point
    if event == cv2.EVENT_FLAG_LBUTTON:
        print((x, y), ' :', mat[y, x])
        watching_point = (x, y)


pymynt.init_camera('raw')
while True:
    mat = pymynt.get_depth_image()
    if mat.shape[0] < 10:
        continue
    print(mat.shape)
    out = mat / np.max(mat) * 255
    out = out.astype('uint8')
    out = cv2.cvtColor(out, cv2.COLOR_GRAY2RGB)
    if not watching_point is None:
        _ = watching_point
        print(_, ' depth :', mat[_[1], _[0]])
        cv2.circle(out, _, 8, (100, 100, 200), 2)
    cv2.imshow('depth', out)
    left = pymynt.get_left_image()
    cv2.imshow('left', left)
Exemplo n.º 3
0
import cv2
import pymynt
import numpy as np

pymynt.init_camera('gray')
while True:
    mat = pymynt.get_depth_image()
    gray = cv2.cvtColor(mat, cv2.COLOR_RGB2GRAY)
    binary = cv2.threshold(gray, 130, 255, cv2.THRESH_BINARY)[1]
    print(binary.shape)
    contours = cv2.findContours(binary, cv2.RETR_EXTERNAL,
                                cv2.CHAIN_APPROX_SIMPLE)[0]
    if not contours is None:
        good_contours = []
        for contour in contours:
            area = cv2.contourArea(contour)
            x, y, w, h = cv2.boundingRect(contour)
            rect_area = w * h
            extent = float(area) / rect_area
            if extent > 0.65 and rect_area > 40000:
                good_contours += [contour]
                cv2.putText(mat, str(rect_area), (x, y + 10),
                            cv2.FONT_HERSHEY_PLAIN, 1.2, (200, 200, 200), 1)
                cv2.rectangle(mat, (x, y), (x + w, y + h), (0, 0, 200), 2)
        cv2.drawContours(mat, good_contours, -1, (255, 255, 0), thickness=2)
        cv2.imshow('test', mat)
    cv2.waitKey(18)