def openFile():
    capture = cv2.VideoCapture(0)
    dddd = tk.Tk()  #the initialisation of the window
    dddd.title("NUS")
    dddd.after(300,
               lambda: dddd.destroy())  # Destroy the widget after 30 seconds

    while True:
        _, frame = capture.read()

        if _:
            imagedFrame = objectTracker.findVehicle(frame)
            imagedFrame = scaleFunction.rescale(imagedFrame, 20)
            cv2.imshow("Frame", imagedFrame)
            lightConditions = tk.Label(root, text=lightReading)

        if cv2.waitKey(5) == ord('q'):
            break
예제 #2
0
    isSuccessful, frame = capture.read()

    if isSuccessful:

        grayFrame = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
        faces = faceReg.detectMultiScale(grayFrame)
        eye = eyeReg.detectMultiScale(grayFrame)
        frame = cv2.rectangle(frame, (20 + counter, 20), (60, 60),
                              (255, 255, 255), -1)

        for (x1, y1, w1, h1) in faces:
            frame = cv2.rectangle(frame, (x1, y1), (x1 + w1, y1 + h1),
                                  (255, 0, 255), 2)
            cv2.putText(frame, "This is a face", (x1 + 5, y1 + 5),
                        cv2.FONT_HERSHEY_DUPLEX, 0.5, (240, 40, 255), 1)

            for (x2, y2, w2, h2) in eye:
                frame = cv2.rectangle(frame, (x2, y2), (x2 + w2, y2 + h2),
                                      (255, 0, 255), 2)
                cv2.putText(frame, "Eye", (x2 + 5, y2 + 5),
                            cv2.FONT_HERSHEY_DUPLEX, 0.5, (240, 40, 255), 1)

        frame = scaleFunction.rescale(frame, 50)
        cv2.imshow("Frame", frame)

    if cv2.waitKey(60) == ord('q'):
        break

capture.release()
cv2.destroyAllWindows()