Esempio n. 1
0
if __name__ == "__main__":
    thresh = 16
    cam = cv2.VideoCapture(0)
    cam.set(cv.CV_CAP_PROP_FRAME_WIDTH, 320)
    cam.set(cv.CV_CAP_PROP_FRAME_HEIGHT, 240)
    if cam.isOpened() == False:
        print "Cam isn't opened"
        exit()
    i = [None, None, None]
    for n in range(3):
        i[n] = motion.getGrayCameraImage(cam)
    flag = False
    checkFlag = 0
    while True:
        diff = motion.diffImage(i)
        ret,thrimg=cv2.threshold(diff, thresh, 1, cv2.THRESH_BINARY)
        count = cv2.countNonZero(thrimg)
        # if invader is checked
        if (count > 1):
            checkFlag += 1
        if checkFlag >= 10 and flag == False:
            sendmail(i[2])
            flag = True
            print "Invader is coming!"
        elif count == 0 and flag == True:
            flag = False
            checkFlag = 0

        # process next image
        motion.updateCameraImage(cam, i)
Esempio n. 2
0
    thresh=16
    cam=cv2.VideoCapture(0)
    cam.set(cv2.CAP_PROP_FRAME_WIDTH,320)
    cam.set(cv2.CAP_PROP_FRAME_HEIGHT,240)
    #if(cam.isOpened()==False):
    #    print("cam isnt opened")
    #    exit()
    i=[None,None,None]
    flag=False

    for n in range(3):
        i[n]=motion.getGrayCamImg(cam)
    checkFlag=0

    while True:
        diff=motion.diffImage(i)
        thrimg=cv2.threshold(diff,thresh,1,cv2.THRESH_BINARY)[1]
        count=cv2.countNonZero(thrimg)
        #if invader is checked.
        print(count)
        if count>1:
            checkFlag+=1
        if checkFlag>=10 and flag==False:
            sendMail(i[2])
            flag=True
            print("invader is coming!!!")
        elif count==0 and flag==True:
            flag=False
            checkFlag=0
        # process next image
        motion.updateCameraImage(cam, i)
Esempio n. 3
0
if __name__ == '__main__':
    thresh=16
    cam=cv2.VideoCapture(0)
    cam.set(cv2.CAP_PROP_FRAME_WIDTH, 320)
    cam.set(cv2.CAP_PROP_FRAME_HEIGHT, 240)

    if cam.isOpened()==False:
        print("cam isnt opened")
        exit()
    i = [None, None, None]
    flag=False
    for n in range(3):
        i[n] = motion.getGrayCamImg(cam)
    checkFlag = 0
    while True:
        diff = motion.diffImage(i[0], i[1], i[2])
        thrimg = cv2.threshold(diff, thresh, 1, cv2.THRESH_BINARY)[1]
        count = cv2.countNonZero(thrimg)

        # 움직임이 있다고 판단될 경우 카운트를 올리고, 10 프레임 관찰될 경우 메일 전송
        if count > 400:
            checkFlag += 1
            
        elif checkFlag >= 10:
            sendMail(i[2])
            flag=True
            print("메시지 전송")
            
        elif count==0 and flag==True:
            flag=False
            checkFlag=0