Skip to content

Commit

Permalink
Merge pull request #51 from locaal-ai/roy.cam_res_setstyle
Browse files Browse the repository at this point in the history
Camera highest res & App Style setting
  • Loading branch information
royshil authored Nov 7, 2024
2 parents 141ba55 + 280f8c0 commit 9610f0f
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 39 deletions.
6 changes: 3 additions & 3 deletions src/about.ui
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@
<rect>
<x>0</x>
<y>0</y>
<width>366</width>
<height>984</height>
<width>374</width>
<height>830</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;About ScoreSight&lt;/span&gt;&lt;/p&gt;&lt;p&gt;ScoreSight is a cutting-edge software solution designed to simplify visual reading of scoreboards.&lt;/p&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;License&lt;/span&gt;&lt;/p&gt;&lt;p&gt;MIT License&lt;br/&gt;&lt;br/&gt;Copyright (c) 2024 OCC AI: Open tools for Content Creators and Streamers&lt;/p&gt;&lt;p&gt;Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the &amp;quot;Software&amp;quot;), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:&lt;br/&gt;&lt;br/&gt;The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.&lt;br/&gt;&lt;br/&gt;THE SOFTWARE IS PROVIDED &amp;quot;AS IS&amp;quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.&lt;/p&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Third-Party Software&lt;/span&gt;&lt;br/&gt;ScoreSight incorporates components from third-party sources under their respective licenses:&lt;/p&gt;&lt;ul style=&quot;margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; -qt-list-indent: 1;&quot;&gt;&lt;li style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;OpenCV&lt;/span&gt; is used under the Apache 2 License, permitting the use, distribution, and modification of the software provided that certain conditions are met. More information can be found at OpenCV License.&lt;/li&gt;&lt;li style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Tesseract OCR&lt;/span&gt; is used under the Apache 2 License, which allows for the use, distribution, and modification of the software in accordance with the terms set forth in the license. More details are available at Tesseract OCR License.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Detailed licensing information for these components is included within the software distribution.&lt;/p&gt;&lt;p&gt;&lt;span style=&quot; font-weight:696;&quot;&gt;Qt Application Framework&lt;/span&gt;&lt;/p&gt;&lt;p&gt;This application uses the Qt application framework, which is a comprehensive C++ library for cross-platform development of GUI applications. Qt is used under the terms of the GNU Lesser General Public License (LGPL) version 3. Qt is a registered trademark of The Qt Company Ltd and is developed and maintained by The Qt Project and various contributors.&lt;/p&gt;&lt;p&gt;For more information about Qt, including source code of Qt libraries used by this application and guidance on how to obtain or replace Qt libraries, please visit the Qt Project's official website at &lt;a href=&quot;http://www.qt.io/&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#007af4;&quot;&gt;http://www.qt.io&lt;/span&gt;&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;We are committed to ensuring compliance with the LGPL v3 license and support the principles of open source software development. If you have any questions or concerns regarding our use of Qt, please contact us directly.&lt;/p&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Disclaimer of Warranty&lt;/span&gt;&lt;br/&gt;ScoreSight is provided &amp;quot;AS IS&amp;quot;, without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose, and noninfringement. In no event shall Roy Shilkrot be liable for any claim, damages, or other liability, whether in an action of contract, tort or otherwise, arising from, out of, or in connection with the software or the use or other dealings in the software.&lt;/p&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Contact Information&lt;/span&gt;&lt;br/&gt;For support, feedback, or more information, please visit &lt;a href=&quot;https://scoresight.live/&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;https://scoresight.live&lt;/span&gt;&lt;/a&gt; or contact us at &lt;a href=&quot;mailto:[email protected]&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;[email protected]&lt;/span&gt;&lt;/a&gt;.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;About ScoreSight&lt;/span&gt;&lt;/p&gt;&lt;p&gt;ScoreSight is an OCR software designed to simplify visual reading of scoreboards and live screencasts.&lt;/p&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;License&lt;/span&gt;&lt;/p&gt;&lt;p&gt;MIT License&lt;br/&gt;&lt;br/&gt;Copyright (c) 2024 &lt;a href=&quot;https://locaal.ai&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#007af4;&quot;&gt;Locaal AI&lt;/span&gt;&lt;/a&gt;: AI tools for Developers and Creators&lt;/p&gt;&lt;p&gt;Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the &amp;quot;Software&amp;quot;), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:&lt;br/&gt;&lt;br/&gt;The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.&lt;br/&gt;&lt;br/&gt;THE SOFTWARE IS PROVIDED &amp;quot;AS IS&amp;quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.&lt;/p&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Third-Party Software&lt;/span&gt;&lt;br/&gt;ScoreSight incorporates components from third-party sources under their respective licenses:&lt;/p&gt;&lt;ul style=&quot;margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; -qt-list-indent: 1;&quot;&gt;&lt;li style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;OpenCV&lt;/span&gt; is used under the Apache 2 License, permitting the use, distribution, and modification of the software provided that certain conditions are met. More information can be found at OpenCV License.&lt;/li&gt;&lt;li style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Tesseract OCR&lt;/span&gt; is used under the Apache 2 License, which allows for the use, distribution, and modification of the software in accordance with the terms set forth in the license. More details are available at Tesseract OCR License.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Detailed licensing information for these components is included within the software distribution.&lt;/p&gt;&lt;p&gt;&lt;span style=&quot; font-weight:696;&quot;&gt;Qt Application Framework&lt;/span&gt;&lt;/p&gt;&lt;p&gt;This application uses the Qt application framework, which is a comprehensive C++ library for cross-platform development of GUI applications. Qt is used under the terms of the GNU Lesser General Public License (LGPL) version 3. Qt is a registered trademark of The Qt Company Ltd and is developed and maintained by The Qt Project and various contributors.&lt;/p&gt;&lt;p&gt;For more information about Qt, including source code of Qt libraries used by this application and guidance on how to obtain or replace Qt libraries, please visit the Qt Project's official website at &lt;a href=&quot;http://www.qt.io/&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#007af4;&quot;&gt;http://www.qt.io&lt;/span&gt;&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;We are committed to ensuring compliance with the LGPL v3 license and support the principles of open source software development. If you have any questions or concerns regarding our use of Qt, please contact us directly.&lt;/p&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Disclaimer of Warranty&lt;/span&gt;&lt;br/&gt;ScoreSight is provided &amp;quot;AS IS&amp;quot;, without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose, and noninfringement. In no event shall Roy Shilkrot be liable for any claim, damages, or other liability, whether in an action of contract, tort or otherwise, arising from, out of, or in connection with the software or the use or other dealings in the software.&lt;/p&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Contact Information&lt;/span&gt;&lt;br/&gt;For support, feedback, or more information, please visit &lt;a href=&quot;https://scoresight.live/&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;https://scoresight.live&lt;/span&gt;&lt;/a&gt; or contact us at &lt;a href=&quot;mailto:[email protected]&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;[email protected]&lt;/span&gt;&lt;/a&gt;.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="wordWrap">
<bool>true</bool>
Expand Down
3 changes: 2 additions & 1 deletion src/camera_thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,13 @@ class OpenCVVideoCaptureWithSettings(BaseVideoCapture):
def __init__(self, capture_id: int | str, capture_backend: int = cv2.CAP_ANY):
super().__init__(capture_id, capture_backend)
self.video_capture = cv2.VideoCapture(capture_id, capture_backend)
set_camera_highest_resolution(self.video_capture)
self.video_capture_mutex = threading.Lock()
self.fps = fetch_data("scoresight.json", "fps", 30)
self.width = fetch_data("scoresight.json", "width", 0)
self.height = fetch_data("scoresight.json", "height", 0)
self.fourcc = fetch_data("scoresight.json", "fourcc", "MJPG")
self.backend = fetch_data("scoresight.json", "backend", cv2.CAP_ANY)
self.backend = fetch_data("scoresight.json", "backend", capture_backend)
subscribe_to_data("scoresight.json", "fps", self.setFps)
subscribe_to_data("scoresight.json", "width", self.setWidth)
subscribe_to_data("scoresight.json", "height", self.setHeight)
Expand Down
23 changes: 10 additions & 13 deletions src/mainwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
QMenu,
QMessageBox,
QTableWidgetItem,
QStyleFactory,
)
from PySide6.QtGui import QIcon, QDesktopServices
from PySide6.QtCore import (
Expand Down Expand Up @@ -137,8 +138,13 @@ def __init__(self, translator: QTranslator, parent: QObject):
self.addLanguageOption(languageMenu, "Russian", "ru_RU")
self.addLanguageOption(languageMenu, "Chinese (Simplified)", "zh_CN")

# add a menu item to change the theme
theme_menu = file_menu.addMenu("Theme")
for theme in QStyleFactory.keys():
theme_menu.addAction(theme, lambda theme=theme: self.setStyleTheme(theme))

# Hide the menu bar by default
self.menubar.setVisible(False)
self.menubar.setVisible(True)

# Show the menu bar when the Alt key is pressed
self.installEventFilter(self)
Expand Down Expand Up @@ -367,6 +373,9 @@ def __init__(self, translator: QTranslator, parent: QObject):
self.get_sources.connect(self.getSources)
self.get_sources.emit()

def setStyleTheme(self, theme):
QApplication.instance().setStyle(theme)

def toggleSpeed(self):
# check the current speed and toggle it
# possible speeds are x2, x4, x8, x16, x32 and back to x1
Expand Down Expand Up @@ -436,25 +445,13 @@ def globalSettingsChanged(self, settingName, value):

def eventFilter(self, obj, event):
if event.type() == QEvent.KeyPress:
if event.key() == Qt.Key_Alt:
self.menubar.setVisible(True)
if event.key() == Qt.Key_Escape:
self.menubar.setVisible(False)
# deselect any selected item
self.itemSelected(None)
if self.image_viewer is not None:
self.image_viewer.selectBox(None)
elif event.type() == QEvent.FocusOut and self.menubar.isVisible():
self.menubar.setVisible(False)
elif event.type() == QEvent.WindowDeactivate and self.menubar.isVisible():
self.menubar.setVisible(False)
return super().eventFilter(obj, event)

def focusOutEvent(self, event):
if self.menubar.isVisible():
self.menubar.setVisible(False)
super().focusOutEvent(event)

def changeEvent(self, event):
if event.type() == QEvent.WindowDeactivate and self.menubar.isVisible():
self.menubar.setVisible(False)
Expand Down
25 changes: 7 additions & 18 deletions src/mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,17 @@
<x>0</x>
<y>0</y>
<width>963</width>
<height>733</height>
<height>718</height>
</rect>
</property>
<property name="windowTitle">
<string>ScoreSight</string>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QHBoxLayout" name="horizontalLayout_31">
<property name="topMargin">
<number>0</number>
</property>
<item>
<widget class="QFrame" name="frame">
<property name="sizePolicy">
Expand All @@ -32,7 +35,7 @@
<property name="lineWidth">
<number>0</number>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<layout class="QVBoxLayout" name="_2">
<property name="spacing">
<number>3</number>
</property>
Expand Down Expand Up @@ -160,7 +163,6 @@
<property name="font">
<font>
<pointsize>14</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
Expand All @@ -180,7 +182,6 @@
<property name="font">
<font>
<pointsize>14</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
Expand Down Expand Up @@ -1740,13 +1741,10 @@
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<layout class="QVBoxLayout" name="_3">
<property name="spacing">
<number>0</number>
</property>
<property name="topMargin">
<number>6</number>
</property>
<item>
<widget class="QWidget" name="widget_4" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_4">
Expand Down Expand Up @@ -2236,16 +2234,7 @@
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>963</width>
<height>21</height>
</rect>
</property>
</widget>
<widget class="QMenuBar" name="menubar"/>
</widget>
<resources/>
<connections/>
Expand Down
14 changes: 10 additions & 4 deletions src/sc_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,26 @@ def setup_logging():

current_time = datetime.now().strftime("%Y-%m-%d_%H-%M-%S")

# basic config - send all logs to a file
# basic config - send all logs to a file with UTF-8 encoding
logging.basicConfig(
filename=os.path.join(data_dir, f"scoresight_std_{current_time}.log"),
level=logging.INFO,
encoding="utf-8", # Add explicit UTF-8 encoding
errors="replace", # Replace invalid characters instead of crashing
)

# prepend the user data directory
log_file_path = os.path.join(data_dir, f"scoresight_{current_time}.log")

# Create a file handler
file_handler = logging.FileHandler(log_file_path)
# Create a file handler with UTF-8 encoding
file_handler = logging.FileHandler(
log_file_path,
encoding="utf-8", # Add explicit UTF-8 encoding
errors="replace", # Replace invalid characters instead of crashing
)
file_handler.setLevel(logging.DEBUG)

# Create a formatter
# Create a formatter that can handle Unicode
formatter = logging.Formatter(
"%(asctime)s - %(levelname)s - %(module)s - %(message)s"
)
Expand Down

0 comments on commit 9610f0f

Please sign in to comment.