提交 c2671079 编写于 作者: H HinGwenWoong

Add [ time left ] while predicting the image for user to know the situation

上级 d843d59e
...@@ -6,6 +6,8 @@ except ImportError: ...@@ -6,6 +6,8 @@ except ImportError:
from PyQt4.QtGui import * from PyQt4.QtGui import *
from PyQt4.QtCore import * from PyQt4.QtCore import *
import time
import datetime
import json import json
import cv2 import cv2
import numpy as np import numpy as np
...@@ -80,8 +82,9 @@ class AutoDialog(QDialog): ...@@ -80,8 +82,9 @@ class AutoDialog(QDialog):
self.parent = parent self.parent = parent
self.ocr = ocr self.ocr = ocr
self.mImgList = mImgList self.mImgList = mImgList
self.lender = lenbar
self.pb = QProgressBar() self.pb = QProgressBar()
self.pb.setRange(0, lenbar) self.pb.setRange(0, self.lender)
self.pb.setValue(0) self.pb.setValue(0)
layout = QVBoxLayout() layout = QVBoxLayout()
...@@ -108,10 +111,16 @@ class AutoDialog(QDialog): ...@@ -108,10 +111,16 @@ class AutoDialog(QDialog):
self.thread_1.progressBarValue.connect(self.handleProgressBarSingal) self.thread_1.progressBarValue.connect(self.handleProgressBarSingal)
self.thread_1.listValue.connect(self.handleListWidgetSingal) self.thread_1.listValue.connect(self.handleListWidgetSingal)
self.thread_1.endsignal.connect(self.handleEndsignalSignal) self.thread_1.endsignal.connect(self.handleEndsignalSignal)
self.time_start = time.time() # save start time
def handleProgressBarSingal(self, i): def handleProgressBarSingal(self, i):
self.pb.setValue(i) self.pb.setValue(i)
# calculate time left of auto labeling
avg_time = (time.time() - self.time_start) / i # Use average time to prevent time fluctuations
time_left = str(datetime.timedelta(seconds=avg_time * (self.lender - i)))
self.setWindowTitle("PPOCRLabel -- " + f"Time Left: {time_left}") # show
def handleListWidgetSingal(self, i): def handleListWidgetSingal(self, i):
self.listWidget.addItem(i) self.listWidget.addItem(i)
titem = self.listWidget.item(self.listWidget.count() - 1) titem = self.listWidget.item(self.listWidget.count() - 1)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册