import cv2

def cb(event, x, y, flags, param):
    if event == cv2.EVENT_LBUTTONDOWN:
        print str(x) + " " + str(y)
#img = cv2.imread('tests/img_1525.jpg')
vc = cv2.VideoCapture('tests/m2s1.mov')
_, img = vc.read()
imgcpy = img.copy()
cv2.namedWindow('image', cv2.WINDOW_NORMAL)
cv2.setMouseCallback('image', cb)
frame = 0
while True:
    cv2.putText(img, "Frame #" + str(frame), (10, 30), cv2.FONT_HERSHEY_PLAIN, 3, (0, 0, 255))
    cv2.imshow('image', img)
    k = cv2.waitKey(20) & 0xFF
    if k == 27:
        break
    if k == ord('s'):
        cv2.imwrite('screenshots/' + str(frame) + '.png', imgcpy)
    elif k == 32:
        _,  img = vc.read()
        imgcpy = img.copy()
        frame += 1
cv2.destroyAllWindows()
