Exemplo n.º 1
0
    def time_add_remove(count):
        if count < 0:
            playsound.playsound("sounds/ANSWER_FALSE_CLOCK.wav", False)
            for i in range(-count):
                playsound.playsound("sounds/POINTS_DOWN.wav", 0)
                a = ui.lcd_time.text()
                ui.lcd_time.setText(str(int(a) - 1))
                loop = QtCore.QEventLoop()
                QtCore.QTimer.singleShot(10, loop.quit)
                loop.exec_()
        elif count > 0:
            playsound.playsound("sounds/ANSWER_TRUE_CLOCK.wav", False)
            for i in range(count):
                playsound.playsound("sounds/POINTS_UP.wav", 0)
                a = ui.lcd_time.text()
                ui.lcd_time.setText(str(int(a) + 1))
                loop = QtCore.QEventLoop()
                QtCore.QTimer.singleShot(10, loop.quit)
                loop.exec_()

            if main.Q_INDEX == len(main.DATA) - 1:
                playsound.playsound("sounds/SPECIAL.wav", 0)
                loop = QtCore.QEventLoop()
                QtCore.QTimer.singleShot(2000, loop.quit)
                loop.exec_()
                main.start_break()
            else:
                main.btn_seek_pressed(index=1)
Exemplo n.º 2
0
 def onAppQuit(self):
     """ Close running threads """
     loop1 = QtCore.QEventLoop()
     loop2 = QtCore.QEventLoop()
     self.thread1.finished.connect(loop1.quit)
     self.thread2.finished.connect(loop2.quit)
     self.thread1.quit()
     loop1.exec_()
     self.thread2.quit()
     loop2.exec_()
Exemplo n.º 3
0
    def time_timer():
        while main.Q_GAMETYPE == "time" and ui.lcd_time.text() != "0":
            a = ui.lcd_time.text()
            ui.lcd_time.setText(str(int(a) - 1))
            if int(a) - 1 <= 15:
                playsound.playsound("sounds/POINTS_DOWN.wav", 0)
            loop = QtCore.QEventLoop()
            QtCore.QTimer.singleShot(1000, loop.quit)
            loop.exec_()

        playsound.playsound("sounds/SPECIAL.wav", 0)
        loop = QtCore.QEventLoop()
        QtCore.QTimer.singleShot(2000, loop.quit)
        loop.exec_()
        main.start_break()
Exemplo n.º 4
0
    def run(self):
        """
        Reimplemented from `QRunnable.run`
        """
        self.eventLoop = QtCore.QEventLoop()
        self.eventLoop.processEvents()

        # Move the task to the current thread so it's events, signals, slots
        # are triggered from this thread.
        assert self.task.thread() is _TaskDepotThread.instance()

        QtCore.QMetaObject.invokeMethod(
            self.task.thread(), "transfer", QtCore.Qt.BlockingQueuedConnection,
            QtCore.Q_ARG(object, self.task),
            QtCore.Q_ARG(object, QtCore.QThread.currentThread())
        )

        self.eventLoop.processEvents()

        # Schedule task.run from the event loop.
        self.task.start()

        # Quit the loop and exit when task finishes or is cancelled.
        self.task.finished.connect(self.eventLoop.quit)
        self.task.cancelled.connect(self.eventLoop.quit)
        self.eventLoop.exec_()
Exemplo n.º 5
0
    def __init__(
        self,
        parent: Optional[QtWidgets.QWidget] = None,
        name: Optional[str] = None,
        embedInParent: bool = False,
        rptEngine: Optional[FLReportEngine] = None,
    ) -> None:
        """Inicialize."""

        super(FLReportViewer, self).__init__(parent)
        self.logger = logging.getLogger("FLReportViewer")
        self.loop_ = False
        self.eventloop = QtCore.QEventLoop()
        self.reportPrinted_ = False
        self.rptEngine_: Optional[Any] = None
        self.report_ = []
        self.slotsPrintDisabled_ = False
        self.slotsExportedDisabled_ = False
        self.printing_ = False
        self.embedInParent_ = True if parent and embedInParent else False
        self.ui_: Dict[str, QtCore.QObject] = {}

        self.Display = 1
        self.Append = 1
        self.PageBreak = 1

        self.rptViewer_ = internalReportViewer(self)
        self.setReportEngine(FLReportEngine(self) if rptEngine is None else rptEngine)

        if self.rptViewer_ is None:
            raise Exception("self.rptViewer_ is empty!")

        self.report_ = self.rptViewer_.reportPages()
Exemplo n.º 6
0
    def startVideo(self):
        global face_image, counter_image

        run_video = True

        while run_video:
            face_ret, face_image = self.face_camera.read()
            counter_ret, counter_image = self.counter_camera.read()

            Fcolor_swapped_image = cv2.cvtColor(face_image, cv2.COLOR_BGR2RGB)
            Ccolor_swapped_image = cv2.cvtColor(counter_image,
                                                cv2.COLOR_BGR2RGB)
            # 무한반복되면서
            # 입력받은 영상을 프레임 단위의 이미지로 받는다
            # 받은 이미지를 처리하기 위해서 cvtColor 메소드 사용

            qt_image1 = QtGui.QImage(Fcolor_swapped_image.data, self.Fwidth,
                                     self.Fheight,
                                     Fcolor_swapped_image.strides[0],
                                     QtGui.QImage.Format_RGB888)
            # color_swapped_image의 데이터를 pyqt에 보내기 위한 객체 설정
            self.FVideoSignal.emit(qt_image1)
            # 이 객체가 실행될때 신호 VideoSignal1으로 보낸다.

            qt_image2 = QtGui.QImage(Ccolor_swapped_image.data, self.Cwidth,
                                     self.Cheight,
                                     Ccolor_swapped_image.strides[0],
                                     QtGui.QImage.Format_RGB888)
            # color_swapped_image의 데이터를 pyqt에 보내기 위한 객체 설정
            self.CVideoSignal.emit(qt_image2)
            # 이 객체가 실행될때 신호 VideoSignal2으로 보낸다.

            loop = QtCore.QEventLoop()
            QtCore.QTimer.singleShot(25, loop.quit)  # 25 ms단위로 루프 결과를 가져옴
            loop.exec_()
Exemplo n.º 7
0
 def genMastClicked(self):
     """Runs the main function."""
     print('Running...')
     self.search()
     loop = QtCore.QEventLoop()
     QtCore.QTimer.singleShot(2000, loop.quit)
     loop.exec_()
Exemplo n.º 8
0
    def execute(self, context):
        logging.debug('execute operator')

        self.app = QtWidgets.QApplication.instance()
        # instance() gives the possibility to have multiple windows and close it one by one
        if not self.app:
            self.app = QtWidgets.QApplication(['blender'])
        self.event_loop = QtCore.QEventLoop()

        self.widget = EXAMPLE_Widget()
        #self.widget = QtWidgets.QWidget()
        #self.widget.setFixedSize(200,100)
        #self.widget.show()

        self.widget.context = context

        logging.debug(self.app)
        logging.debug(self.widget)

        # run modal
        wm = context.window_manager
        self._timer = wm.event_timer_add(1 / 120, context.window)
        context.window_manager.modal_handler_add(self)

        return {'RUNNING_MODAL'}
Exemplo n.º 9
0
    def user_retry(self, call_name):
        response = show_error_message()

        loop = QtCore.QEventLoop()
        QtCore.QTimer.singleShot(
            1500,
            loop.quit)  # wait 1.5 seconds before making the next requests
        loop.exec_()

        if call_name != 'update_table':
            self.close_request_thread()

        if call_name == 'update_table':
            self.close_table_thread()
            if response:
                self.prepare_update()
            else:
                self.timer_pause = False
        elif call_name == 'message' and response:
            self.prepare_message_send()
        elif call_name == 'quit_table' and response:
            self.prepare_quit_table()
        elif call_name == 'call' and response:
            self.prepare_call_action()
        elif call_name == 'check' and response:
            self.prepare_check_action()
        elif call_name == 'fold' and response:
            self.prepare_fold_action()
        elif call_name == 'raise' and response:
            self.prepare_raise_action()
Exemplo n.º 10
0
    def startVideo(self):  # 영상을 출력하는 함수 (어플리케이션 실행과 동시에 시작됨)
        global image  # 출력할 이미지 변수
        global text  # 타이머 변수
        global color_swapped_image  # 화면에 출력하기 위한 이미지
        global is_trans  # 추론 및 번역이 끝났는지를 확인하기 위한 변수
        global trans_text  # 번역된 텍스트를 받아오기 위한 변수
        global is_stop

        is_trans = False  # 초기값 설정
        text = ""

        while True:
            ret, image = self.camera.read()  # 카메라로 부터 입력을 받아와 이미지로 저장
            color_swapped_image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)  # 화면에 출력하기 위하여 BGR 패턴의 이미지를 RGB 패턴으로 변환

            if is_trans:  # 번역이 완료됐다면
                font = ImageFont.truetype("C:\\Windows\\Fonts\\NanumSquareB.ttf", 70)  # 나눔스퀘어
                img_pil = Image.fromarray(color_swapped_image)  # color_swapped_image에
                draw = ImageDraw.Draw(img_pil)  # draw를 한다.
                draw.text((20, 630), trans_text, font=font,
                          fill=(255, 255, 255, 0))  # 50, 400의 위치에 trans_text(번역된 텍스트)를 빨간색으로 뿌려준다.
                color_swapped_image = np.array(img_pil)  # 글씨가 그려진 이미지를 다시 기존 이미지에 저장

            qt_image1 = QtGui.QImage(color_swapped_image.data,  # 전달할 QImage 객체를 생성
                                     self.width,
                                     self.height,
                                     color_swapped_image.strides[0],
                                     QtGui.QImage.Format_RGB888)
            self.VideoSignal1.emit(qt_image1)  # 기존에 만들었던 시그널을 통해 QImage 객체를 전송.

            loop = QtCore.QEventLoop()  # 1ms 마다 반복
            QtCore.QTimer.singleShot(1, loop.quit)  # 25 ms
            loop.exec_()
Exemplo n.º 11
0
 def turn_off(self):
     self.client.turn_off(1)
     # let enought time for modbus signal to be processed by the plc
     loop = QtCore.QEventLoop()
     QtCore.QTimer.singleShot(OPTIONS['pb_delay'], loop.quit)
     loop.exec_()
     self.client.turn_off(0)
Exemplo n.º 12
0
 def update_status(self, msg):
     self.status_label.setText(msg["msg"])
     if msg["msg"] == "Browser Ready":
         self.browser_url, self.browser_cookies = msg["url"], msg["cookies"]
         self.running = False
         self.start_btn.raise_()
         self.browser_label.show()
         logger.alt(self.task_id, msg["msg"])
         loop = QtCore.QEventLoop()
         QtCore.QTimer.singleShot(1000, loop.quit)
         loop.exec_()
         self.task.stop()
         return
     if msg["status"] == "idle":
         self.status_label.setStyleSheet("color: rgb(255, 255, 255);")
         logger.normal(self.task_id, msg["msg"])
     elif msg["status"] == "normal":
         self.status_label.setStyleSheet("color: rgb(163, 149, 255);")
         logger.normal(self.task_id, msg["msg"])
     elif msg["status"] == "alt":
         self.status_label.setStyleSheet("color: rgb(242, 166, 137);")
         logger.alt(self.task_id, msg["msg"])
     elif msg["status"] == "error":
         self.status_label.setStyleSheet("color: rgb(252, 81, 81);")
         logger.error(self.task_id, msg["msg"])
     elif msg["status"] == "success":
         self.status_label.setStyleSheet("color: rgb(52, 198, 147);")
         logger.success(self.task_id, msg["msg"])
         self.running = False
         self.start_btn.raise_()
         checkouts_count.setText(str(int(checkouts_count.text()) + 1))
     elif msg["status"] == "carted":
         self.status_label.setStyleSheet("color: rgb(163, 149, 255);")
         logger.alt(self.task_id, msg["msg"])
         carted_count.setText(str(int(carted_count.text()) + 1))
Exemplo n.º 13
0
def qt4():
    """PyOS_InputHook python hook for Qt4.

    Process pending Qt events and if there's no pending keyboard
    input, spend a short slice of time (50ms) running the Qt event
    loop.

    As a Python ctypes callback can't raise an exception, we catch
    the KeyboardInterrupt and temporarily deactivate the hook,
    which will let a *second* CTRL+C be processed normally and go
    back to a clean prompt line.
    """
    try:
        allow_CTRL_C()
        app = QtCore.QCoreApplication.instance()
        if not app:
            return 0
        app.processEvents(QtCore.QEventLoop.AllEvents, 300)
        if not stdin_ready():
            # Generally a program would run QCoreApplication::exec()
            # from main() to enter and process the Qt event loop until
            # quit() or exit() is called and the program terminates.
            #
            # For our input hook integration, we need to repeatedly
            # enter and process the Qt event loop for only a short
            # amount of time (say 50ms) to ensure that Python stays
            # responsive to other user inputs.
            #
            # A naive approach would be to repeatedly call
            # QCoreApplication::exec(), using a timer to quit after a
            # short amount of time. Unfortunately, QCoreApplication
            # emits an aboutToQuit signal before stopping, which has
            # the undesirable effect of closing all modal windows.
            #
            # To work around this problem, we instead create a
            # QEventLoop and call QEventLoop::exec(). Other than
            # setting some state variables which do not seem to be
            # used anywhere, the only thing QCoreApplication adds is
            # the aboutToQuit signal which is precisely what we are
            # trying to avoid.
            timer = QtCore.QTimer()
            event_loop = QtCore.QEventLoop()
            timer.timeout.connect(event_loop.quit)
            while not stdin_ready():
                timer.start(50)
                event_loop.exec_()
                timer.stop()
    except KeyboardInterrupt:
        print("\nKeyboardInterrupt - Press Enter for new prompt"
              )  # trex: test-skip
    except:  # NO exceptions are allowed to escape from a ctypes callback
        ignore_CTRL_C()
        from traceback import print_exc
        print_exc()
        print(
            "Got exception from inputhook, unregistering.")  # trex: test-skip
        clear_inputhook()
    finally:
        allow_CTRL_C()
    return 0
Exemplo n.º 14
0
    def wait_signal(
            self, signal
    ):  # fonction qui bloque le thread jusqu'a reception du signal

        loop = QtCore.QEventLoop()
        signal.connect(loop.quit)
        loop.exec_()
Exemplo n.º 15
0
    def startVideo(self):
        global image

        run_video = True
        while run_video:
            ret, image = self.camera.read()


            color_swapped_image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)

            qt_image1 = QtGui.QImage(color_swapped_image.data,
                                    self.width,
                                    self.height,
                                    color_swapped_image.strides[0],
                                    QtGui.QImage.Format_RGB888)
            self.VideoSignal1.emit(qt_image1)


            if self.flag:
                img_gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
                img_canny = cv2.Canny(img_gray, 50, 100)

                qt_image2 = QtGui.QImage(img_canny.data,
                                         self.width,
                                         self.height,
                                         img_canny.strides[0],
                                         QtGui.QImage.Format_Grayscale8)

                self.VideoSignal2.emit(qt_image2)


            loop = QtCore.QEventLoop()
            QtCore.QTimer.singleShot(25, loop.quit) #25 ms
            loop.exec_()
Exemplo n.º 16
0
    def assignvalues(self, index):
        if self.allowclick:
            self.allowclick = False
            # button clicked
            current_button = self.buttons[index]

            # show image assigned to button
            current_button.setStyleSheet(
                f"border-image: url({self.buttons_images[current_button]}.jpg) 0 0 0 0 stretch stretch"
            )

            self.clickedbuttons.append(current_button)

            if len(self.clickedbuttons) == 2:
                if self.clickedbuttons[0] == self.clickedbuttons[1]:
                    self.clickedbuttons.pop(-1)
                    self.allowclick = True
                    print("Don't push the same button!")
                    return
                loop = QtCore.QEventLoop()
                QtCore.QTimer.singleShot(500, loop.quit)
                loop.exec_()
                self.match()
                self.clickedbuttons = []
            self.allowclick = True
Exemplo n.º 17
0
Arquivo: main.py Projeto: VoyakinH/CG
 def wait(self):
     t = int(self.lineEditDelay.text())
     if t > 0:
         self.update_image()
     loop = QtCore.QEventLoop()
     QtCore.QTimer.singleShot(t, loop.quit)
     loop.exec_()
Exemplo n.º 18
0
  def waitForGrblProbe(self):
    ''' Attente d'une réponse de Grbl, Probe ou error ou Alarm '''
    self.__probeRecu = "Coucou"
    
    def quitOnProbe(data: str):
      resultatProbe = []
      tblData   = data.split(":")
      tblValues = tblData[1].split(",")
      resultatProbe.append(tblData[2] == "1]")
      resultatProbe.append([])
      for v in tblValues:
        resultatProbe[1].append(float(v))
      resultatProbe.append(SIG_PROBE)
      self.__probeRecu = resultatProbe
      loop.quit()

    def quitOnError():
      self.__probeRecu = [False, [], SIG_ERROR]
      loop.quit()

    def quitOnAlarm():
      self.__probeRecu = [False, [], SIG_ALARM]
      loop.quit()

    loop = QtCore.QEventLoop()
    self.__grblCom.sig_probe.connect(quitOnProbe)
    self.__grblCom.sig_error.connect(quitOnError)
    self.__grblCom.sig_alarm.connect(quitOnAlarm)
    loop.exec()
    self.__grblCom.sig_probe.disconnect(quitOnProbe)
    self.__grblCom.sig_error.disconnect(quitOnError)
    self.__grblCom.sig_alarm.disconnect(quitOnAlarm)
    
    return self.__probeRecu
Exemplo n.º 19
0
    def save(self):  # 수화 촬영을 시작하는 함수

        global image  # 출력할 이미지 변수
        global is_run  # 수화번역을 시작했는지 파악하기 위한 변수
        global num  # 이미지의 개수를 파악하기 위한 변수
        global text  # 타이머를 표시하기 위한 변수
        global is_trans  # 추론 및 번역이 끝났는지를 확인하기 위한 변수

        # is_trans = False  # 수화 촬영 중이기 때문에 번역 중인 변수를 False로 초기화

        push_button1.setEnabled(False)

        is_run = True  # 수화 촬영변수를 True로 변경
        num = 1  # 촬영된 이미지 수를 1로 초기화
        timer = 1  # 타이머를 5초로 초기화
        push_button1.setToolTip('촬영중입니다.')
        if not os.path.isdir("image"):  # 초기 이미지를 저장할 image 폴더가 없다면 폴더 생성
            os.mkdir("image")

        while is_run:  # 수화를 촬영하는 동안
            text = str(timer)  # text에 타이머를 저장
            timer = timer - 1  # 1초에 한번씩 감소

            if timer == 0:  # 타이머가 0이 되면
                path = "image/1.jpg"
                cv2.imwrite(path, image)  # image를 저장한다.
                timer = 1  # 사진을 3장 찍고 나면 타이머를 다시 5초로 초기화
                self.Api_trans()

            loop = QtCore.QEventLoop()  # 1초마다 한번씩 반복
            QtCore.QTimer.singleShot(1000, loop.quit)  # 25 ms
            loop.exec_()
Exemplo n.º 20
0
    def setupUi(self, MainForm):
        MainForm.setObjectName("MainForm")
        MainForm.resize(400, 265)
        self.status_label = QtWidgets.QLabel(MainForm)
        self.status_label.setGeometry(QtCore.QRect(135, 140, 241, 161))
        font = QtGui.QFont()
        font.setPointSize(18)
        self.status_label.setFont(font)
        self.status_label.setObjectName("status_label")

        self.Refresh_label = QtWidgets.QLabel(MainForm)
        self.Refresh_label.setGeometry(QtCore.QRect(50, 51, 241, 161))
        self.Refresh_label.setObjectName("Refresh_label")

        self.gif = QtGui.QMovie('loadingBar.gif')
        self.Refresh_label.setMovie(self.gif)
        self.gif.start()

        loop = QtCore.QEventLoop()
        self.time = QtCore.QTimer()
        self.time.singleShot(8000, loop.quit)
        self.time.singleShot(4000, self.Checkfile)

        self.retranslateUi(MainForm)
        QtCore.QMetaObject.connectSlotsByName(MainForm)
Exemplo n.º 21
0
Arquivo: utils.py Projeto: l5x5l/cps
def sleep(n):
    """
    wait function
    """
    loop = QtCore.QEventLoop()
    QtCore.QTimer.singleShot(int(n * 1000), loop.quit)
    loop.exec_()
Exemplo n.º 22
0
    def run(self):
        realTimePrev = None
        while self.parent.encoder_pt < self.parent.total_frames and self.parent.isRunning:
            if self.parent.frame_buffer[self.parent.encoder_pt] is not None:
                self.parent.writer.append_data(np.asarray(self.parent.frame_buffer[self.parent.encoder_pt]))
                realTimePrev = self.parent.frame_buffer[self.parent.encoder_pt]
                self.parent.frame_buffer[self.parent.encoder_pt] = None
                self.parent.encoder_pt = self.parent.encoder_pt + 1
            else:
                if realTimePrev:
                    self.parent.previewRealTime(realTimePrev)
                    realTimePrev = None
                self.parent.log("Processing:{0}/{1}".format(self.parent.encoder_pt, self.parent.total_frames))
                self.parent.progress(self.parent.encoder_pt, self.parent.total_frames)

                # The following 3 lines can be replaced by time.sleep(0.5) if you are not using PyQt5
                loop = QtCore.QEventLoop()
                QtCore.QTimer.singleShot(500, loop.quit)
                loop.exec_()

        self.parent.previewRealTime(realTimePrev)
        realTimePrev = None
        self.parent.log("Processing:{0}/{1}".format(self.parent.encoder_pt, self.parent.total_frames))
        self.parent.progress(self.parent.encoder_pt, self.parent.total_frames)
        if self.parent.encoder_pt >= self.parent.total_frames:
            self.parent.log("Rendering Done!")
Exemplo n.º 23
0
 def handleLoadFinished(self):
     self.set_MathJax_Message()
     #waiting for parsing math formulas
     loop = QtCore.QEventLoop()
     QtCore.QTimer.singleShot(1000, loop.quit)
     loop.exec_()
     self.toHtml(self.printpdf)
Exemplo n.º 24
0
    def check_for_updates(self):
        self.labelCurrentTask.setText("Checking for updates...")

        wait = QtCore.QEventLoop()
        QtCore.QTimer.singleShot(2000, wait.quit)
        wait.exec_()
        self.close()
Exemplo n.º 25
0
    def __init__(self, mem, syms=None, parent=None, **kwargs):
        e_memcanvas.MemoryCanvas.__init__(self, mem=mem, syms=syms)
        QWebEngineView.__init__(self, parent=parent, **kwargs)

        self._canv_cache = None
        self._canv_curva = None
        self._canv_rendtagid = '#memcanvas'
        self._canv_rend_middle = False
        self.fname = None

        # DEV: DO NOT DELETE THIS REFERENCE TO THESE
        # Otherwise they'll get garbage collected and things like double click
        # to navigate and logging won't work
        # (but pyqt5 won't throw an exception, because ugh).
        self._log_page = LoggerPage()
        self.setPage(self._log_page)
        self.channel = QWebChannel()
        self.page().setWebChannel(self.channel)
        self.channel.registerObject('vnav', self)

        htmlpage = e_q_html.template.replace('{{hotexamples_com}}', e_q_jquery.jquery_2_1_0)
        page = self.page()
        page.setHtml(htmlpage)
        loop = QtCore.QEventLoop()
        page.loadFinished.connect(loop.quit)
        loop.exec()
        QtCore.QCoreApplication.processEvents(QtCore.QEventLoop.ExcludeUserInputEvents | QtCore.QEventLoop.ExcludeSocketNotifiers)
        page.runJavaScript(e_q_jquery.jquery_2_1_0)
        self.forceSync()

        page.contentsSizeChanged.connect(self._frameContentsSizeChanged)

        # Allow our parent to handle these...
        self.setAcceptDrops(False)
Exemplo n.º 26
0
    def run(self):
        try:
            while True:
                ret, color_image, _, depth_image = self.camera.get_frames()
                if ret == False:
                    continue

                if color_image is not None:
                    color_image = cv2.cvtColor(color_image, cv2.COLOR_BGR2RGB)
                    color_image = cv2.resize(color_image, dsize=(640, 480), interpolation=cv2.INTER_LINEAR)
                    height, width, _ = color_image.shape
                    qt_rgb_image = QtGui.QImage(color_image.data,
                                            width,
                                            height,
                                            color_image.strides[0],
                                            QtGui.QImage.Format_RGB888)

                    self.rgb_signal.emit(qt_rgb_image)

                if depth_image is not None:
                    depth_image = cv2.cvtColor(depth_image, cv2.COLOR_BGR2RGB)
                    depth_image = cv2.resize(depth_image, dsize=(640, 480), interpolation=cv2.INTER_LINEAR)
                    height, width, _ = depth_image.shape
                    qt_depth_image = QtGui.QImage(depth_image.data,
                                            width,
                                            height,
                                            depth_image.strides[0],   
                                            QtGui.QImage.Format_RGB888)
                    self.depth_signal.emit(qt_depth_image)

                loop = QtCore.QEventLoop()
                QtCore.QTimer.singleShot(1, loop.quit)
                loop.exec_()
        finally:
            self.camera.stop()
Exemplo n.º 27
0
    def save(self):
        global image
        global is_run
        global num
        global text

        is_run = True
        num = 1
        timer = 3

        if not os.path.isdir("image"):
            os.mkdir("image")

        while is_run:
            text = str(timer)
            timer = timer - 1

            if timer == 0:
                for i in range(1, 4):
                    path = "image/" + str(num) + ".jpg"
                    cv2.imwrite(path, image)
                    num = num + 1
                    time.sleep(0.1)
                timer = 3
            loop = QtCore.QEventLoop()
            QtCore.QTimer.singleShot(1000, loop.quit)  # 25 ms
            loop.exec_()
Exemplo n.º 28
0
    def start(self):
        try:
            while True:
                color_image, depth_image, depth_colormap = self.camera.get_frames(
                )

                # display rgb image
                color_image = cv2.cvtColor(color_image, cv2.COLOR_BGR2RGB)
                height, width, channel = color_image.shape

                qt_rgb_image = QtGui.QImage(color_image.data, width, height,
                                            color_image.strides[0],
                                            QtGui.QImage.Format_RGB888)

                self.rgb_signal.emit(qt_rgb_image)

                # display depth image
                depth_image = cv2.cvtColor(depth_colormap, cv2.COLOR_BGR2RGB)
                height, width, channel = depth_colormap.shape
                qt_depth_image = QtGui.QImage(depth_colormap.data, width,
                                              height,
                                              depth_colormap.strides[0],
                                              QtGui.QImage.Format_RGB888)

                self.depth_signal.emit(qt_depth_image)

                loop = QtCore.QEventLoop()
                QtCore.QTimer.singleShot(1, loop.quit)
                loop.exec_()
        finally:
            self.camera.stop()
Exemplo n.º 29
0
    def invoke(self, context, event):
        """
        :param context: bpy.types.Context
        :param event: bpy.types.Event
        """

        cls = self.__class__

        wm = context.window_manager
        wm.modal_handler_add(self)
        self.timer_add(context)
        self.prev_time = time.perf_counter()

        self.init_queue()
        app = QtWidgets.QApplication.instance()
        if not app:
            app = QtWidgets.QApplication(['blender'])
        cls.app = app
        app.setWheelScrollLines(1)

        cls.event_loop = QtCore.QEventLoop()

        cls.win = SplashDialog()
        app.installEventFilter(cls.win)

        return {'RUNNING_MODAL'}
Exemplo n.º 30
0
 def run(self):
     realTimePrev = None
     while self.parent.encoder_pt < self.parent.total_frames and self.parent.isRunning:
         if self.parent.frame_buffer[self.parent.encoder_pt] is not None:
             self.parent.writer.append_data(
                 np.asarray(
                     self.parent.frame_buffer[self.parent.encoder_pt]))
             realTimePrev = self.parent.frame_buffer[self.parent.encoder_pt]
             self.parent.frame_buffer[self.parent.encoder_pt] = None
             self.parent.encoder_pt = self.parent.encoder_pt + 1
         else:
             if realTimePrev:
                 self.parent.previewRealTime(realTimePrev)
                 realTimePrev = None
             self.parent.log("Processing:{0}/{1}".format(
                 self.parent.encoder_pt, self.parent.total_frames))
             self.parent.progress(self.parent.encoder_pt,
                                  self.parent.total_frames)
             loop = QtCore.QEventLoop()
             QtCore.QTimer.singleShot(500, loop.quit)
             loop.exec_()
     self.parent.previewRealTime(realTimePrev)
     realTimePrev = None
     self.parent.log("Processing:{0}/{1}".format(self.parent.encoder_pt,
                                                 self.parent.total_frames))
     self.parent.progress(self.parent.encoder_pt, self.parent.total_frames)
     if self.parent.encoder_pt >= self.parent.total_frames:
         self.parent.log("Blending Done!")