Exemplo n.º 1
0
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import cv2
from holdDetector import findHolds, findColors, plotColors, buildDetector

import os.path
import time
#cap = cv2.VideoCapture(0)
#path = "C:/Users/SeanC/Documents/GitHub/NeuralClimb/Hold Detection/2D Space/results.avi"

#abspath =  os.path.abspath(path)
#cap = cv2.VideoCapture(abspath)

i = 0
detector = buildDetector()

# Define the codec and create VideoWriter object
out = cv2.VideoWriter('results.avi', -1, 15.0, (568, 640), True)

while (True):
    i += 1

    file_path = "frames_" + "%04d" % i + ".png"
    print file_path
    frame = cv2.imread(file_path, 1)
    if frame == None:
        break

    #Find keypoints
    keypoints, _ = findHolds(frame, detector)
Exemplo n.º 2
0
import cv2
import numpy as np
import matplotlib.pyplot as plt
import math
from util import *
from holdDetector import buildDetector


ret, imgOrig = grab_from_file()
gray = cv2.cvtColor(imgOrig,cv2.COLOR_BGR2GRAY)
gray = resize(imgOrig,750)

detector = buildDetector()

th = 150
def draw(img, keypoints):
    # Draw detected blobs as red circles.
    # cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS ensures the 
    # size of the circle corresponds to the size of blob
    for i, key in enumerate(keypoints):
        x = int(key.pt[0])
        y = int(key.pt[1])

        size = int(math.ceil(key.size)) 

        #Finds a rectangular window in which the keypoint fits
        br = (x + size, y + size)   
        tl = (x - size, y - size)
        cv2.rectangle(img,tl,br,(0,0,255),2)

    #OpenCV uses BGR format, so that'll need to be reversed for display
Exemplo n.º 3
0
"""Example"""

import holdDetector as hd

#Open dialog to select image
img = hd.openImage()

# Set initial detector parameters
hd.buildDetector(minArea = 500)

# Finds each hold. Returns keypoints for each hold
# and the points that define the contours of each hold
holds, contours = hd.findHolds(img)

#Finds a color associated with each keypoint
colors = hd.findColors(img,holds)

#Draws keypoints onto image and plots colors in 3D space
hd.draw(img,holds)
hd.plotColors(colors)