Skip to content

Commit

Permalink
Average FPS over all images with all actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Avasam committed Dec 6, 2021
1 parent 96938cd commit c27bbda
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 10 deletions.
8 changes: 4 additions & 4 deletions res/design.ui
Original file line number Diff line number Diff line change
Expand Up @@ -263,15 +263,15 @@
<rect>
<x>5</x>
<y>225</y>
<width>53</width>
<height>21</height>
<width>54</width>
<height>23</height>
</rect>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="text">
<string>Max FPS</string>
<string>Avg. FPS</string>
</property>
</widget>
<widget class="QLabel" name="fps_label">
Expand Down Expand Up @@ -662,7 +662,7 @@
<widget class="QLabel" name="fps_value_label">
<property name="geometry">
<rect>
<x>58</x>
<x>60</x>
<y>225</y>
<width>26</width>
<height>20</height>
Expand Down
28 changes: 22 additions & 6 deletions src/AutoSplit.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"github.com/Toufool/Auto-Split/issues</a>, describe what happened, and copy & paste the error message below"
START_IMAGE_TEXT = "Start Image"
START_AUTO_SPLITTER_TEXT = "Start Auto Splitter"
CHECK_FPS_ITERATIONS = 10

# Needed when compiled, along with the custom hook-requests PyInstaller hook
os.environ["REQUESTS_CA_BUNDLE"] = certifi.where()
Expand Down Expand Up @@ -452,15 +453,30 @@ def __check_fps(self):

# run X iterations of screenshotting capture region + comparison + displaying.
t0 = time()
while count < 10:
capture = self.__get_capture_for_comparison()
_ = image.compare_with_capture(self, capture)
count += 1
for image in images:
count = 0
while count < CHECK_FPS_ITERATIONS:
capture = self.__get_capture_for_comparison()
_ = image.compare_with_capture(self, capture)
# Fallback to capture bytes just for test and type safety
numpy_array = image.bytes if image.bytes is not None else capture
# Set current split image in UI
split_image_display = cv2.cvtColor(numpy_array, cv2.COLOR_BGRA2RGBA)
qimage = QtGui.QImage(split_image_display.data,
split_image_display.shape[1],
split_image_display.shape[0],
split_image_display.shape[1] * split_image_display.shape[2],
QtGui.QImage.Format.Format_RGBA8888)
self.current_split_image.setPixmap(QtGui.QPixmap(qimage).scaled(
self.current_split_image.size(),
QtCore.Qt.AspectRatioMode.IgnoreAspectRatio))
count += 1
self.current_split_image.clear()

# calculate FPS
t1 = time()
fps = str(int(10 / (t1 - t0)))
self.fps_value_label.setText(fps)
fps = int((CHECK_FPS_ITERATIONS * len(images)) / (t1 - t0))
self.fps_value_label.setText(str(fps))

def __is_current_split_out_of_range(self):
return self.split_image_number < 0 \
Expand Down

0 comments on commit c27bbda

Please sign in to comment.