import cv2
from PiRapidStream import PiRapidStream


vs = PiRapidStream(resolution=(576,512),fps=20,form='yuv',exp=30000,gain=1.15)
vs.startcapt()
    
def CallBackFunc(event,x,y,flags,param):
##    if event==cv2.EVENT_LBUTTONDOWN:
##        print "left button clicked at {} , {}".format(x,y)
##    if event==cv2.EVENT_RBUTTONDOWN:
##        print "right button clicked at {} , {}".format(x,y)
##    if event==cv2.EVENT_MBUTTONDOWN:
##        print "middle button clicked at {} , {}".format(x,y)
##    if event==cv2.EVENT_MOUSEMOVE:
##        print "mouse is at {} , {}".format(x,y)
    if flags==(cv2.EVENT_FLAG_LBUTTON+cv2.EVENT_FLAG_SHIFTKEY+cv2.EVENT_FLAG_CTRLKEY):
        print "while shift + ctrl, mouse is at {} , {}".format(x,y)

while cv2.waitKey(1) != ord("q") and vs.stream_done==False:
    
    img=vs.frame
    cv2.namedWindow('Spinndow',1)
    cv2.setMouseCallback('Spinndow', CallBackFunc)
    cv2.imshow('Spinndow',img)

vs.stopcapt()
cv2.destroyAllWindows()
