Пример #1
0
def option2_start():
    # TODO: function to pick up/set all appropriate values
    # check if os join of path and name folder exists, and if it does, return a message box
    # if os.path.isdir(os.path.join(cfg.userPath, nameFolder.get())):
    # 	tkMessageBox.showinfo("ERROR", "Folder already exists! Pick another")
    # 	return
    # # check for empty strings
    # elif len(nameFolder.get()) ==0  or duration.get() is None or len(userpath.get()) == 0 or cfg.unoPath is '' or cfg.megaPath is '' or cfg.megaPath is cfg.unoPath:
    # 	tkMessageBox.showinfo("ERROR", "Missing data, please fill in everything")
    # 	return
    cfg.userFolder = nameFolder.get()
    os.mkdir(os.path.join(cfg.userPath, cfg.userFolder))
    clearOut(root)
    frame0A = Tkinter.Frame(root).grid()
    # maybe make a thing that flashes based on tempo in recording adjustment thread? if tempo is set, that is
    nowRecording = Tkinter.Label(frame0A, text="FINISHED RECORDING", bg="YELLOW", font=("Helvetica", 72)).grid()

    # time.sleep(0.1)
    global i
    mega = readHits.megaComm(i, "MegaComm", spoof=True)
    i += 1
    uno = readHits.unoComm(i, "UnoComm", spoof=True)
    i += 1
    uno.start()
    time.sleep(0.0001)
    mega.start()
    # debug printing TODO: dummy out, and set spoof to False
    # print "RECORDING NOW AT"
    # print time.localtime()
    if showVar.get() or recVar.get():
        cap = cv2.VideoCapture(0)
        # first read to get the size
        _, image = cap.read()
        # print cap.get(cv2.cv.CV_CAP_PROP_FPS)
        if recVar.get() == 1:
            height, width, _ = image.shape
            vid = cv2.VideoWriter()
            suc = vid.open(
                filename=os.path.join(cfg.userPath, cfg.userFolder, "CamView.avi"),
                fourcc=cv2.cv.CV_FOURCC(*"XVID"),
                fps=15,
                frameSize=(width, height),
            )

            # print "Recording {}".format(cfg.recording)
        while cfg.recording:
            _, image = cap.read()
            print image.shape
            if showVar.get():
                # print image.shape
                cv2.imshow("Webcam View", image)
            if recVar.get():
                vid.write(image)
                # time.sleep(0.011)
            cv2.waitKey(33)
            # vid.close()

        cap.release()
        cv2.destroyWindow("Webcam View")
    uno.join()
    mega.join()
    # print "FINISHING RECORDING"
    # print time.localtime()
    cameraInstructions(choice=2)
    pass
Пример #2
0
def option0_start():
    clearOut(root)
    frame0A = Tkinter.Frame(root)
    frame0A.grid()
    nowRecording = Tkinter.Label(frame0A, text="FINISHED RECORDING", bg="YELLOW", font=("Helvetica", 72))
    nowRecording.grid()

    cfg.userFolder = nameFolder.get()
    os.mkdir(os.path.join(cfg.userPath, cfg.userFolder))
    # global i
    if debug:
        mega = readHits.megaComm(1, "MegaComm", spoof=True)
        # i += 1
        uno = readHits.unoComm(2, "UnoComm", spoof=True)
        # i += 1
    else:
        mega = readHits.megaComm(1, "MegaComm", spoof=False)
        # i += 1
        uno = readHits.unoComm(2, "UnoComm", spoof=False)
        # i += 1

    uno.start()
    # time.sleep(.0001)
    root.after(1)
    # web.start()
    mega.start()
    # run opencv vidcapture in main thread
    # print "Recording {0}, Showing {1}".format(recVar.get(), showVar.get())
    if showVar.get() or recVar.get():
        cap = cv2.VideoCapture(0)
        # first read to get the size
        _, image = cap.read()
        tStart = datetime.now()
        # print cap.get(cv2.cv.CV_CAP_PROP_FPS)
        cv2.waitKey(33)
        _, image = cap.read()
        timeElp = (datetime.now() - tStart).microseconds
        frameRate = 1 / (4 * timeElp / 1e6)
        # print "TIME BETWEEN FRAMES IS {}".format(timeElp/1e6)
        # print "SUGGESTED FPS = {}".format(frameRate)
        if recVar.get() == 1:
            height, width, _ = image.shape
            vid = cv2.VideoWriter()
            suc = vid.open(
                filename=os.path.join(cfg.userPath, cfg.userFolder, "CamView.avi"),
                fourcc=cv2.cv.CV_FOURCC(*"DIVX"),
                fps=frameRate,
                frameSize=(width, height),
            )

        while cfg.recording:
            _, image = cap.read()

            if showVar.get():
                # print image.shape
                cv2.imshow("Webcam View", image)
            if recVar.get():
                vid.write(image)
                # time.sleep(0.011)
            cv2.waitKey(1)
            # vid.close()

        cap.release()
        cv2.destroyWindow("Webcam View")

        # debug printing TODO: dummy out, and set spoof to False
        # print "RECORDING NOW AT"
        # print time.localtime()
    uno.join()
    mega.join()
    # print "FINISHING RECORDING"
    # print time.localtime()
    cameraInstructions(choice=0)
    return