import numpy as np
import cv2
from PiRapidStream import PiRapidStream
from TheSquaire import TheSquaire

def nothing(*x):
    pass
ts=TheSquaire()
cv2.namedWindow('detection',cv2.WINDOW_AUTOSIZE)
cv2.createTrackbar('minar','detection',20000,250000,nothing)
cv2.createTrackbar('maxar','detection',100000,250000,nothing)
vs = PiRapidStream(resolution=(576,512),fps=30,form='yuv',exp=30000,gain=1.15)
vs.startcapt()

while cv2.waitKey(1) != ord("q") and vs.stream_done==False:
    minar=cv2.getTrackbarPos('maxar','detection')
    maxar=cv2.getTrackbarPos('minar','detection')
    blank=np.zeros((512,576,1),dtype=np.uint8)
    img=vs.frame
    #retval, binary = cv2.threshold(src, 200, 255, cv2.THRESH_BINARY_INV)
    r=ts.rechtecke(src=img)
    cv2.drawContours( blank, r, -1, 128, 3 )
    cv2.imshow('blank', blank)
    

vs.stopcapt()
cv2.destroyAllWindows()


