Skip to content

Commit

Permalink
Multiple screenshots and load/save (#214)
Browse files Browse the repository at this point in the history
* Multiple screenshot and load/save
* fixed bug when cropping goes wrong
* Fixed bug in test_all
* is "cropped" handling improved.
* Normalized the click rect
  • Loading branch information
KingKnecht committed Dec 6, 2023
1 parent 025138c commit 2878a27
Show file tree
Hide file tree
Showing 5 changed files with 446 additions and 68 deletions.
177 changes: 165 additions & 12 deletions poker/gui/ui/table_setup_form.ui
Expand Up @@ -28,7 +28,7 @@
</sizepolicy>
</property>
<property name="currentIndex">
<number>0</number>
<number>3</number>
</property>
<widget class="QWidget" name="tab_2">
<attribute name="title">
Expand Down Expand Up @@ -2933,6 +2933,12 @@ Then check the console output for error messages.</string>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<property name="leftMargin">
<number>9</number>
</property>
<property name="rightMargin">
<number>9</number>
</property>
<item>
<widget class="QPushButton" name="take_screenshot_button">
<property name="font">
Expand Down Expand Up @@ -2997,6 +3003,128 @@ Then check the console output for error messages.</string>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2" stretch="0,0,0,0,0,0,0,0,0">
<property name="leftMargin">
<number>9</number>
</property>
<property name="rightMargin">
<number>9</number>
</property>
<item>
<widget class="QLabel" name="label_10">
<property name="text">
<string>Screenshot interval (s)</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBox_nthSecond">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string/>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="value">
<number>1</number>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_13">
<property name="text">
<string>Amount screenshots</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBox_xTimes">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>1000</number>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="append_checkbox">
<property name="toolTip">
<string>If checked, current screenshot(s) will be kept.</string>
</property>
<property name="text">
<string>Append Screenshots</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="load_screenshots_button">
<property name="toolTip">
<string>Load screenshots (PNGs) from selected folder.</string>
</property>
<property name="text">
<string>Load screenshots</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="save_screenshots_button">
<property name="toolTip">
<string>Save screenshots as PNGs to a folder.
Saving screenshots will not override exisiting screenshots.</string>
</property>
<property name="text">
<string>Save Screenshots</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="label_16">
<property name="font">
Expand All @@ -3008,6 +3136,9 @@ Then check the console output for error messages.</string>
<property name="text">
<string>Selection after clicking top left and bottom right of below screenshot</string>
</property>
<property name="margin">
<number>0</number>
</property>
</widget>
</item>
<item>
Expand All @@ -3026,7 +3157,7 @@ Then check the console output for error messages.</string>
<rect>
<x>0</x>
<y>0</y>
<width>803</width>
<width>879</width>
<height>69</height>
</rect>
</property>
Expand Down Expand Up @@ -3055,6 +3186,16 @@ Then check the console output for error messages.</string>
</property>
</widget>
</item>
<item>
<widget class="QSlider" name="screenshot_slider">
<property name="maximum">
<number>0</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QScrollArea" name="scrollArea_2">
<property name="sizePolicy">
Expand All @@ -3063,6 +3204,9 @@ Then check the console output for error messages.</string>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="sizeAdjustPolicy">
<enum>QAbstractScrollArea::AdjustIgnored</enum>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
Expand All @@ -3071,22 +3215,31 @@ Then check the console output for error messages.</string>
<rect>
<x>0</x>
<y>0</y>
<width>803</width>
<height>674</height>
<width>879</width>
<height>666</height>
</rect>
</property>
<property name="acceptDrops">
<bool>true</bool>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<layout class="QGridLayout" name="gridLayout_22">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="screenshot_label">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="styleSheet">
<string notr="true">border: 4px dashed #aaa</string>
</property>
Expand Down
5 changes: 3 additions & 2 deletions poker/main.py
Expand Up @@ -12,6 +12,7 @@
from PyQt6 import QtGui, QtWidgets

from poker.restapi_local import local_restapi
from poker.tools import constants as const

if platform not in ["linux", "linux2"]:
matplotlib.use('Qt5Agg')
Expand Down Expand Up @@ -241,8 +242,8 @@ def run(self):

filename = str(history.GameID) + "_" + str(table.gameStage) + "_" + str(history.round_number) + ".png"
log.debug("Saving screenshot: " + filename)
pil_image = table.crop_image(table.entireScreenPIL, table.tlc[0], table.tlc[1], table.tlc[0] + 1500,
table.tlc[1] + 1100)
pil_image = table.crop_image(table.entireScreenPIL, table.tlc[0], table.tlc[1], table.tlc[0] + const.CROP_WIDTH,
table.tlc[1] + const.CROP_HEIGHT)
pil_image.save("log/screenshots/" + filename)

self.gui_signals.signal_status.emit("Logging data")
Expand Down

0 comments on commit 2878a27

Please sign in to comment.