diff --git a/README.md b/README.md index 6c32f766..0523437f 100755 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # PYGPT v2 -Release: **2.0.14** build: **2023.12.10** | Official website: https://pygpt.net | Docs: https://pygpt.readthedocs.io +Release: **2.0.15** build: **2023.12.10** | Official website: https://pygpt.net | Docs: https://pygpt.readthedocs.io PyPi: https://pypi.org/project/pygpt-net @@ -1062,6 +1062,10 @@ may consume additional tokens that are not displayed in the main window. # CHANGELOG +## 2.0.15 (2023-12-10) + +- Added camera release / disable on camera off + ## 2.0.14 (2023-12-10) - Added real-time video capture from camera in "Vision" mode diff --git a/docs/source/conf.py b/docs/source/conf.py index e525ff22..2ac2c2c6 100755 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -9,7 +9,7 @@ project = 'PYGPT' copyright = '2023, pygpt.net' author = 'szczyglis-dev, Marcin Szczygliński' -release = '2.0.14' +release = '2.0.15' # -- General configuration --------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration diff --git a/docs/source/index.rst b/docs/source/index.rst index 9f7c3f8a..c28723c4 100755 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -6,11 +6,11 @@ PYGPT v2 - pygpt.net ==================== -| **Last update:** 2023-12-10 18:00 +| **Last update:** 2023-12-10 21:00 | **Project website:** https://pygpt.net | **GitHub:** https://github.com/szczyglis-dev/py-gpt | **PyPI:** https://pypi.org/project/pygpt-net -| **Release:** 2.0.14 (2023-12-10) +| **Release:** 2.0.15 (2023-12-10) .. toctree:: :maxdepth: 3 diff --git a/pyproject.toml b/pyproject.toml index fd00fb86..72a91abd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "pygpt-net" -version = "2.0.14" +version = "2.0.15" description = "Desktop AI Assistant powered by GPT-4, GPT-4V, GPT-3, Whisper, TTS and DALL-E 3 with chatbot, assistant, text completion, vision and image generation, real-time internet access, commands and code execution, files upload and download and more" readme = "README.md" authors = [{ name = "Marcin Szczygliński", email = "info@pygpt.net" }] diff --git a/setup.py b/setup.py index d68ce39b..1fb0aad7 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ from setuptools import setup, find_packages -VERSION = '2.0.14' +VERSION = '2.0.15' DESCRIPTION = 'Desktop AI Assistant powered by GPT-4, GPT-4V, GPT-3, Whisper, TTS and DALL-E 3 with chatbot, assistant, text completion, ' \ 'vision and image generation, real-time internet access, commands and code execution, files upload and download and more' LONG_DESCRIPTION = 'Package containing a GPT-4, GPT-4V, GPT-3, Whisper, TTS and DALL-E 3 AI desktop assistant with chatbot, ' \ diff --git a/src/pygpt_net/CHANGELOG.txt b/src/pygpt_net/CHANGELOG.txt index dd669ec3..b645b86b 100755 --- a/src/pygpt_net/CHANGELOG.txt +++ b/src/pygpt_net/CHANGELOG.txt @@ -1,3 +1,7 @@ +2.0.15 (2023-12-10) + +- Added camera release / disable on camera off + 2.0.14 (2023-12-10) - Added real-time video capture from camera in "Vision" mode diff --git a/src/pygpt_net/__init__.py b/src/pygpt_net/__init__.py index bbf8d518..dc86ee77 100755 --- a/src/pygpt_net/__init__.py +++ b/src/pygpt_net/__init__.py @@ -13,7 +13,7 @@ __copyright__ = "Copyright 2023, Marcin Szczygliński" __credits__ = ["Marcin Szczygliński"] __license__ = "MIT" -__version__ = "2.0.14" +__version__ = "2.0.15" __build__ = "2023.12.10" __maintainer__ = "Marcin Szczygliński" __github__ = "https://github.com/szczyglis-dev/py-gpt" diff --git a/src/pygpt_net/core/camera.py b/src/pygpt_net/core/camera.py index d9b35a23..4378122b 100644 --- a/src/pygpt_net/core/camera.py +++ b/src/pygpt_net/core/camera.py @@ -27,7 +27,7 @@ def __init__(self, config=None): class CameraThread(QObject): - finished = Signal(object) + finished = Signal() destroyed = Signal() started = Signal() stopped = Signal() @@ -57,11 +57,17 @@ def run(self): try: if not self.initialized: self.setup_camera() + self.started.emit() self.initialized = True - print("Starting video capture thread....") while True: - if self.window.is_closing or self.capture is None: + if self.window.is_closing \ + or self.capture is None \ + or not self.capture.isOpened()\ + or self.window.controller.camera.stop: + # release camera + self.release() + self.stopped.emit() break _, frame = self.capture.read() frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB) @@ -69,4 +75,17 @@ def run(self): self.window.controller.camera.frame = frame # update frame except Exception as e: print("Camera thread exception:", e) - self.finished.emit(e) + + # release camera + self.release() + self.finished.emit() + + def release(self): + """ + Release camera + """ + if self.capture is not None and self.capture.isOpened(): + self.capture.release() + self.capture = None + self.frame = None + self.initialized = False diff --git a/src/pygpt_net/core/controller/camera.py b/src/pygpt_net/core/controller/camera.py index 79809e32..a9286afc 100644 --- a/src/pygpt_net/core/controller/camera.py +++ b/src/pygpt_net/core/controller/camera.py @@ -6,12 +6,13 @@ # GitHub: https://github.com/szczyglis-dev/py-gpt # # MIT License # # Created By : Marcin Szczygliński # -# Updated Date: 2023.12.10 17:00:00 # +# Updated Date: 2023.12.10 21:00:00 # # ================================================== # import datetime import os import threading import cv2 +from PySide6.QtCore import Slot from PySide6.QtGui import QImage, QPixmap, Qt from ..camera import CameraThread @@ -30,6 +31,7 @@ def __init__(self, window=None): self.frame = None self.thread_started = False self.is_capture = False + self.stop = False self.auto = False def setup(self): @@ -45,11 +47,37 @@ def start(self): """ if self.thread_started: return + self.stop = False thread = CameraThread(window=self.window) + thread.finished.connect(self.handle_stop) + thread.stopped.connect(self.handle_stop) self.thread = threading.Thread(target=thread.run) self.thread.start() self.thread_started = True + def stop_capture(self): + """ + Stop camera thread + """ + if not self.thread_started: + return + self.stop = True + + @Slot() + def handle_stop(self): + """ + On stopped + """ + self.thread_started = False + self.thread = None + + def blank_screen(self): + """ + Blank screen + """ + self.window.data['video.preview'].video.setPixmap(QPixmap.fromImage(QImage())) + # self.window.data['video.preview'].setVisible(False) + def update(self): """ Update camera frame @@ -94,6 +122,7 @@ def hide_camera(self): Hide camera """ self.window.data['video.preview'].setVisible(False) + self.stop_capture() def enable_capture(self): """ @@ -114,6 +143,8 @@ def disable_capture(self): return self.is_capture = False self.window.config.data['vision.capture.enabled'] = False + self.stop_capture() + self.blank_screen() def toggle(self, state): """ diff --git a/version.rc b/version.rc index 5743c4ae..2f4bad58 100755 --- a/version.rc +++ b/version.rc @@ -1,7 +1,7 @@ VSVersionInfo( ffi=FixedFileInfo( - filevers=(2, 0, 13, 0), - prodvers=(2, 0, 13, 0), + filevers=(2, 0, 15, 0), + prodvers=(2, 0, 15, 0), mask=0x3f, flags=0x0, OS=0x4, @@ -16,12 +16,12 @@ StringFileInfo( u'040904B0', [StringStruct(u'CompanyName', u'pygpt.net'), StringStruct(u'FileDescription', u'Desktop AI Assistant powered by GPT-4, GPT-3 and DALL-E 3: assistant, chatbot, text completion, image generation and analyze and more'), - StringStruct(u'FileVersion', u'2.0.13'), + StringStruct(u'FileVersion', u'2.0.15'), StringStruct(u'InternalName', u'Py-GPT'), StringStruct(u'LegalCopyright', u'(c) 2023 pygpt.net, Marcin Szczygliński'), StringStruct(u'OriginalFilename', u'Py-GPT.exe'), StringStruct(u'ProductName', u'pygpt.net'), - StringStruct(u'ProductVersion', u'2.0.13')]) + StringStruct(u'ProductVersion', u'2.0.15')]) ]), VarFileInfo([VarStruct(u'Translation', [1033, 1200])]) ]