##################
state=False
while True:
    i=0
    while i<NMBR_IMAGE_MAJ:
        ret, frame=cap.read()
        state=meth.sub_image(image_back,frame)
        if a ==True:
            i=0
            break
        else:
            i+=1
            if i ==NMBR_IMAGE_MAJ:
                i=0
                meth.maj_back(image_back,frame)
"""




def calcule_matricule(image):
    cv2.imshow('frame', image)
    cv2.waitKey()
    cap.release()
    cv2.destroyAllWindows()


##########################     main

cv2.waitKey(0)

##################

state = False
while True:
    i = 0
    while ((i < NMBR_IMAGE_MAJ) and (not (state))):
        ret, frame = cap.read()
        new_frame = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
        state = meth.sub_image(image_back, new_frame)
        if state != True:
            i += 1

    if i == NMBR_IMAGE_MAJ:
        meth.maj_back(image_back, new_frame)
        break

    if state == True:
        print("mouvemment")
"""




def calcule_matricule(image):
    cv2.imshow('frame', image)
    cv2.waitKey()
    cap.release()
    cv2.destroyAllWindows()