Exemple #1
0
def think_and_decide(ann, img_bin, img_orig):
    # img_orig, shape, rectangle, distances = regF.select_roi(img.copy(), img_bin)
    # _, shape, rectangle, _ = regF.select_roi(None, img_bin)
    shape, _ = regF.select_roi_new(img_orig, img_bin)

    if not shape:
        return

    inputs = simF.prepare_for_ann(shape)
    results = ann.predict(np.array(inputs, np.float32))

    return results
Exemple #2
0
show_video_bin = True
first_iter = True
work = False
left_down = False
right_down = False
scr_w, scr_h = pagui.size()
prev_x1, prev_y1, prev_x2, prev_y2 = 0, 0, 0, 0
imgNum = 30
img_text = ''

# Obucavanje mreze
hand_state = annFs.prepare_training_data(merge_images)
img_train = annFs.load_training_image()
img_train_bin = simF.get_image_bin(simF.get_image_gray(img_train))
_, shapes, rectangles, _ = regF.select_roi(img_train.copy(), img_train_bin)
inputs = simF.prepare_for_ann(shapes)
outputs = simF.convert_output(hand_state)
ann = annFs.create_ann()
ann = annFs.train_ann(ann, inputs, outputs)

# Priprema i snimanje kamerom
videoCapture = cv2.VideoCapture()
videoCapture.open(0)

while videoCapture.isOpened():
    _, img = videoCapture.read()
    cnt, center = regF.select_contour(img)
    drawing = np.zeros((np.size(img, 0), np.size(img, 1)), np.uint8)
    cv2.drawContours(drawing, [cnt], 0, (255, 255, 255), 2)

    if show_video_gray:
Exemple #3
0
show_video_bin = True
first_iter = True
work = False
left_down = False
right_down = False
scr_w, scr_h = pagui.size()
prev_x1, prev_y1, prev_x2, prev_y2 = 0, 0, 0, 0
imgNum = 30
img_text = ""

# Obucavanje mreze
hand_state = annFs.prepare_training_data(merge_images)
img_train = annFs.load_training_image()
img_train_bin = simF.get_image_bin(simF.get_image_gray(img_train))
_, shapes, rectangles, _ = regF.select_roi(img_train.copy(), img_train_bin)
inputs = simF.prepare_for_ann(shapes)
outputs = simF.convert_output(hand_state)
ann = annFs.create_ann()
ann = annFs.train_ann(ann, inputs, outputs)

# Priprema i snimanje kamerom
videoCapture = cv2.VideoCapture()
videoCapture.open(0)

while videoCapture.isOpened():
    _, img = videoCapture.read()
    cnt, center = regF.select_contour(img)
    drawing = np.zeros((np.size(img, 0), np.size(img, 1)), np.uint8)
    cv2.drawContours(drawing, [cnt], 0, (255, 255, 255), 2)

    if show_video_gray: