Esempio n. 1
0
def generate_descriptor_stack(image_folder):
    print(image_folder)
    gesture_types = ["A", "B", "C", "Five", "Point", "V"]
    stack_of_descriptors = []
    labels_array = []
    for gesture_type in gesture_types:
        gesture_path = image_folder + gesture_type
        print("gesture_path", gesture_path)
        for gesture_image in glob.glob(gesture_path + '/uniform/*.ppm'):
            hand = cv.imread(
                gesture_image)  # Replace hand.jpg with gesture_image
            #print("hand", hand)

            detector = skinDetector(gesture_image)
            detector.find_skin()

            palmX, palmY = findPalmPoint(detector.binary_mask_image)
            print("Palm X: ", palmX, " Palm Y: ", palmY)

            mcX, mcY = findMassCenter(detector.binary_mask_image)
            print("Mc X: ", mcX, " Mc Y: ", mcY)

            thresh_mask = detector.binary_mask_image.astype(np.uint8)
            im, contours, hierarchy = cv.findContours(
                detector.binary_mask_image, cv.RETR_EXTERNAL,
                cv.CHAIN_APPROX_NONE)
            cv.drawContours(hand, contours, -1, (255, 0, 0), 3)

            distSig = findHandDistanceSignature((palmX, palmY), (mcX, mcY),
                                                contours)
            print("Contour Shape: ", len(contours))

            f = plt.figure()
            f.add_subplot(1, 2, 1)
            handPlt = cv.drawMarker(hand, (palmX, palmY), (255, 0, 0),
                                    markerType=cv.MARKER_CROSS,
                                    markerSize=15,
                                    thickness=2,
                                    line_type=cv.LINE_AA)
            handPlt = cv.drawMarker(handPlt, (mcX, mcY), (0, 255, 0),
                                    markerType=cv.MARKER_CROSS,
                                    markerSize=15,
                                    thickness=2,
                                    line_type=cv.LINE_AA)
            plt.imshow(handPlt)
            f.add_subplot(1, 2, 2)
            plt.imshow(detector.binary_mask_image)
            stack_of_descriptors.append(distSig)
            labels_array.append(gesture_type)
            print("DEscriptor sHape", np.array(stack_of_descriptors).shape)
    return stack_of_descriptors, labels_array
Esempio n. 2
0
def show_webcam():
    cam = cv2.VideoCapture(0)
    while True:
        ret, img = cam.read()
        if not ret:
            break
        cv2.imshow('Cam input', img)
        k = cv2.waitKey(1)
        if k % 256 == 27:  # esc to exit
            break
        elif k % 256 == 32:  # space to capture frame
            detector = skinDetector(img)
            detector.find_skin()
    cv2.destroyAllWindows()
    cam.release()
Esempio n. 3
0
def generate_descriptor(gesture_image):
    print("gesture_image", gesture_image)
    hand = cv.imread(gesture_image)  # Replace hand.jpg with gesture_image
    #print("hand", hand)

    detector = skinDetector(gesture_image)
    detector.find_skin()

    palmX, palmY = findPalmPoint(detector.binary_mask_image)
    print("Palm X: ", palmX, " Palm Y: ", palmY)

    mcX, mcY = findMassCenter(detector.binary_mask_image)
    print("Mc X: ", mcX, " Mc Y: ", mcY)

    thresh_mask = detector.binary_mask_image.astype(np.uint8)
    im, contours, hierarchy = cv.findContours(detector.binary_mask_image,
                                              cv.RETR_EXTERNAL,
                                              cv.CHAIN_APPROX_NONE)
    cv.drawContours(hand, contours, -1, (255, 0, 0), 3)

    distSig = findHandDistanceSignature((palmX, palmY), (mcX, mcY), contours)
    print("Contour Shape: ", len(contours))
    return distSig
Esempio n. 4
0
def main():
    if (len(sys.argv) < 2):
        show_webcam()
    else:
        detector = skinDetector(cv2.imread(sys.argv[1]))
        detector.find_skin()
Esempio n. 5
0
import sys # for Command Line Arguments
from jeanCV import skinDetector


imageName = sys.argv[1]

detector = skinDetector(imageName)
detector.find_skin()