def main():
    orig_imgs = glob.glob('photoset/cleaned/*/*.JPG')
    
    for filename in orig_imgs:
        # Find all cards in each image
        image = cv2.imread(filename)
        cards = get_white_rectangles(image)
        for card in cards:
            image, corners = card
            # For each card, detect the shape
            shape = detect_shape(image)
            print shape
	
	shapes = []
	distances = []

	start = time.time()
	for shape in all_locations[location]:

		image_name = all_locations[location][shape]
		image = cv2.imread(image_name)

		# start2 = time.time()
		cleaned_image, rectangle_coordinates = white_rect_finder.get_white_rectangles(image)[0]
		# elapsed2 = time.time() - start2

		# start3 = time.time()
		estimated_shape = identify_shapes.detect_shape(cleaned_image)
		# elapsed3 = time.time() - start3

		print shape, estimated_shape #, elapsed2, elapsed3

		shapes.append(shape)

		# find y-coordinates of rectangle
		low_y = (rectangle_coordinates[0][1] + rectangle_coordinates[1][1]) / 2.
		high_y = (rectangle_coordinates[2][1] + rectangle_coordinates[3][1]) / 2.

		# find pixel height
		pixels = high_y - low_y

		estimated_distance = get_distance(pixels)
# A short test to verify the shapes are correctly identified

import os
import cv2

from white_rect_finder import get_white_rectangles
from identify_shapes import detect_shape

base_dir = "photoset_labeled/cleaned"
correctly_classified = 0
incorrectly_classified = 0

for dir in os.listdir(base_dir):
    shape_dir = base_dir + "/" + dir
    for shape_folder in os.listdir(shape_dir):
        photo_dir = shape_dir + "/" + shape_folder
        for photo in os.listdir(photo_dir):
            image = cv2.imread(photo_dir + "/" + photo)
            cards = get_white_rectangles(image)
            for card in cards:
                image, corners = card
                shape = detect_shape(image)
                if shape == shape_folder:
                    correctly_classified += 1
                else:
                    shape = detect_shape(image, show_shape=True)
                    incorrectly_classified +=1
                    print "Incorrect:",shape,shape_folder,photo_dir,photo

print "Correct: ", correctly_classified
print "Incorrect: ", incorrectly_classified