def find_square(frame_in):
    frame_out = frame_in.copy()
    frame_gray = cv2.cvtColor(frame_in, cv2.COLOR_BGR2GRAY)
    #thresh = threshold(frame_gray,110)
    thresh = adap_threshold(frame_gray)
    frame_blur = cv2.blur(thresh, (3,3))
    #cv2.imshow('Threhold',thresh)
    contours, hry = cv2.findContours(frame_blur, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
    #identify squares
    squares = []
    for cnt in contours:
        # Calculate the perimeter
        cnt_len = cv2.arcLength(cnt, True)
        # Simpler Contour approximation 
        cnt = cv2.approxPolyDP(cnt, 0.01 * cnt_len, True)
        if  cv2.contourArea(cnt) > 10 and len(cnt) == 4 and cv2.isContourConvex(cnt) :
            cnt = cnt.reshape(-1, 2) # cnt is divided into two column 
            max_cos = np.max([angle_cos( cnt[i], cnt[4 % (i+1)], cnt[(i+2) % 4] ) for i in xrange(4)])
            if max_cos < 0.1 and equal(cnt[0], cnt[1], cnt[2],0.2):
                 squares.append(cnt)
    cv2.drawContours(frame_out , squares, -1, (0,255,0), 2)
   
    return frame_out
dataset/ETHPy150Open fatcloud/PyCV-time/challanges/shape-challenge/Square/Video_find_square_0702.py/find_square/swapped operands of `%`