video = 'voiture.mp4'
cap = cv2.VideoCapture(video)

image_back = meth.take_back_ground_debut(cap)
cv2.imshow("hhh", image_back)
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):

video='voiture.mp4'
cap=cv2.VideoCapture(video)

image_back=meth.take_back_ground_debut(cap)
cv2.imshow("hhh",image_back)
cv2.waitKey(0)

##################
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)
image_back = meth.take_back_ground_debut(cap)
cv2.imshow("hhh", image_back)
cv2.waitKey(0)

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

state = False
while True:
    i = 0
    while ((i < NMBR_IMAGE_MAJ) and (not (state))):

        print("etiration ")
        ret, frame = cap.read()
        new_frame = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
        image_info = meth.sub_image(image_back, new_frame)
        state = meth.verrifier(image_info)
        if state != True:
            i += 1
    if i == NMBR_IMAGE_MAJ:
        meth.maj_back(image_back, new_frame)
        break

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