cv2imshow


Namecv2imshow JSON
Version 0.10 PyPI version JSON
download
home_pagehttps://github.com/hansalemaos/cv2imshow
Summarycv2.imshow without freezing - Windows only
upload_time2023-05-25 04:13:39
maintainer
docs_urlNone
authorJohannes Fischer
requires_python
licenseMIT
keywords cv2 imshow
VCS
bugtrack_url
requirements hackyargparser keyboard kthread_sleep numpy opencv_python subprocess_alive subprocess_multipipe varpickler
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # cv2.imshow without freezing - Windows only 

#### Tested against Windows 10 / Python 3.10 / Anaconda

### pip install cv2imshow

This module provides a solution for the freezing issue encountered when updating images using OpenCV's cv2.imshow function
By addressing the freezing issue and providing non-blocking image display, this module enables smoother real-time image visualization 
in OpenCV applications and allows for improved user experience when working with image processing and computer vision tasks.

#### Non-blocking image display:

The module enables displaying images without freezing the execution of the program. 
It utilizes subprocess to offload the image display to a separate process, 
allowing the main program to continue running smoothly.

####  Multi-process support: 

The module supports displaying images in a multi-process environment, 
where multiple images can be shown simultaneously in separate windows without 
interfering with each other or causing freezing issues.
(Important: each window has to have a different title and a different combination for killkeys)

####  Keyboard control: 

The module provides an option to define a key combination that can be used to toggle the image display on and off. 
This allows for convenient control of image visualization during program execution.
When the specified kill shortcut is triggered, the module gracefully terminates the image display process, 
freeing system resources and ensuring a clean exit. This allows for easy and controlled termination 
of the image display functionality without causing any disruption or instability in the main program.

####  Memory efficiency: 

The module utilizes a queue-based mechanism to pass images between processes, 
ensuring efficient memory usage even when displaying large images or 
multiple images simultaneously.





### How to use it 

```python
from adbblitz import AdbShotTCP
from kthread_sleep import sleep
from cv2imshow.cv2imshow import cv2_imshow_single, cv2_imshow_multi
import numpy as np

shosho2 = AdbShotTCP(
    device_serial="localhost:5555",
    adb_path=r"C:\ProgramData\chocolatey\lib\scrcpy\tools\scrcpy-win64-v2.0\adb.exe",
    ip="127.0.0.1",
    port=5555,
    max_frame_rate=60,
    max_video_width=960,
    scrcpy_server_version="2.0",
    forward_port=None,
    frame_buffer=24,
    byte_package_size=131072,
    sleep_after_exception=0.01,
    log_level="info",
    lock_video_orientation=0,
)
bi = shosho2.get_one_screenshot()
cv2_imshow_single(
    title="pic2",
    image=bi.copy(),
    killkeys="ctrl+alt+q", # kills imshow
)
sleep(0.02)


with AdbShotTCP(
    device_serial="localhost:5555",
    adb_path=r"C:\ProgramData\chocolatey\lib\scrcpy\tools\scrcpy-win64-v2.0\adb.exe",
    ip="127.0.0.1",
    port=5555,
    max_frame_rate=60,
    max_video_width=960,
    scrcpy_server_version="2.0",
    forward_port=None,
    frame_buffer=24,
    byte_package_size=131072,
    sleep_after_exception=0.01,
    log_level="info",
    lock_video_orientation=0,
) as shosho:
    for bi in shosho:
        if bi.dtype == np.uint16:
            continue
        cv2_imshow_multi(
            title="pic3",
            image=bi,
            killkeys="ctrl+alt+h", # switch on/off
        )
        sleep(0.001)
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/hansalemaos/cv2imshow",
    "name": "cv2imshow",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "cv2,imshow",
    "author": "Johannes Fischer",
    "author_email": "aulasparticularesdealemaosp@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/3b/3f/412bddb465676288527e9ceee723173b7d4165ad39a4d3423a3e7072baba/cv2imshow-0.10.tar.gz",
    "platform": null,
    "description": "# cv2.imshow without freezing - Windows only \r\n\r\n#### Tested against Windows 10 / Python 3.10 / Anaconda\r\n\r\n### pip install cv2imshow\r\n\r\nThis module provides a solution for the freezing issue encountered when updating images using OpenCV's cv2.imshow function\r\nBy addressing the freezing issue and providing non-blocking image display, this module enables smoother real-time image visualization \r\nin OpenCV applications and allows for improved user experience when working with image processing and computer vision tasks.\r\n\r\n#### Non-blocking image display:\r\n\r\nThe module enables displaying images without freezing the execution of the program. \r\nIt utilizes subprocess to offload the image display to a separate process, \r\nallowing the main program to continue running smoothly.\r\n\r\n####  Multi-process support: \r\n\r\nThe module supports displaying images in a multi-process environment, \r\nwhere multiple images can be shown simultaneously in separate windows without \r\ninterfering with each other or causing freezing issues.\r\n(Important: each window has to have a different title and a different combination for killkeys)\r\n\r\n####  Keyboard control: \r\n\r\nThe module provides an option to define a key combination that can be used to toggle the image display on and off. \r\nThis allows for convenient control of image visualization during program execution.\r\nWhen the specified kill shortcut is triggered, the module gracefully terminates the image display process, \r\nfreeing system resources and ensuring a clean exit. This allows for easy and controlled termination \r\nof the image display functionality without causing any disruption or instability in the main program.\r\n\r\n####  Memory efficiency: \r\n\r\nThe module utilizes a queue-based mechanism to pass images between processes, \r\nensuring efficient memory usage even when displaying large images or \r\nmultiple images simultaneously.\r\n\r\n\r\n\r\n\r\n\r\n### How to use it \r\n\r\n```python\r\nfrom adbblitz import AdbShotTCP\r\nfrom kthread_sleep import sleep\r\nfrom cv2imshow.cv2imshow import cv2_imshow_single, cv2_imshow_multi\r\nimport numpy as np\r\n\r\nshosho2 = AdbShotTCP(\r\n    device_serial=\"localhost:5555\",\r\n    adb_path=r\"C:\\ProgramData\\chocolatey\\lib\\scrcpy\\tools\\scrcpy-win64-v2.0\\adb.exe\",\r\n    ip=\"127.0.0.1\",\r\n    port=5555,\r\n    max_frame_rate=60,\r\n    max_video_width=960,\r\n    scrcpy_server_version=\"2.0\",\r\n    forward_port=None,\r\n    frame_buffer=24,\r\n    byte_package_size=131072,\r\n    sleep_after_exception=0.01,\r\n    log_level=\"info\",\r\n    lock_video_orientation=0,\r\n)\r\nbi = shosho2.get_one_screenshot()\r\ncv2_imshow_single(\r\n    title=\"pic2\",\r\n    image=bi.copy(),\r\n    killkeys=\"ctrl+alt+q\", # kills imshow\r\n)\r\nsleep(0.02)\r\n\r\n\r\nwith AdbShotTCP(\r\n    device_serial=\"localhost:5555\",\r\n    adb_path=r\"C:\\ProgramData\\chocolatey\\lib\\scrcpy\\tools\\scrcpy-win64-v2.0\\adb.exe\",\r\n    ip=\"127.0.0.1\",\r\n    port=5555,\r\n    max_frame_rate=60,\r\n    max_video_width=960,\r\n    scrcpy_server_version=\"2.0\",\r\n    forward_port=None,\r\n    frame_buffer=24,\r\n    byte_package_size=131072,\r\n    sleep_after_exception=0.01,\r\n    log_level=\"info\",\r\n    lock_video_orientation=0,\r\n) as shosho:\r\n    for bi in shosho:\r\n        if bi.dtype == np.uint16:\r\n            continue\r\n        cv2_imshow_multi(\r\n            title=\"pic3\",\r\n            image=bi,\r\n            killkeys=\"ctrl+alt+h\", # switch on/off\r\n        )\r\n        sleep(0.001)\r\n```\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "cv2.imshow without freezing - Windows only",
    "version": "0.10",
    "project_urls": {
        "Homepage": "https://github.com/hansalemaos/cv2imshow"
    },
    "split_keywords": [
        "cv2",
        "imshow"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "44e251f4724c7683ad4972d8d17144cc39bc1897e349f763f21bf17935d63112",
                "md5": "0e4243af7ccbfc94a073d9a62dc77f07",
                "sha256": "81eb447bcbe33b42282343aaf680876da54308e6e075ff8e4f3468fd530207ba"
            },
            "downloads": -1,
            "filename": "cv2imshow-0.10-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "0e4243af7ccbfc94a073d9a62dc77f07",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 53205,
            "upload_time": "2023-05-25T04:13:37",
            "upload_time_iso_8601": "2023-05-25T04:13:37.143207Z",
            "url": "https://files.pythonhosted.org/packages/44/e2/51f4724c7683ad4972d8d17144cc39bc1897e349f763f21bf17935d63112/cv2imshow-0.10-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3b3f412bddb465676288527e9ceee723173b7d4165ad39a4d3423a3e7072baba",
                "md5": "69772dd0be9d6d31a66ba2ea51002738",
                "sha256": "453f990f5aa941a950b84a29a8d8eb130d5a41fcf680d14c51081e8d32a5fb6f"
            },
            "downloads": -1,
            "filename": "cv2imshow-0.10.tar.gz",
            "has_sig": false,
            "md5_digest": "69772dd0be9d6d31a66ba2ea51002738",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 52747,
            "upload_time": "2023-05-25T04:13:39",
            "upload_time_iso_8601": "2023-05-25T04:13:39.680515Z",
            "url": "https://files.pythonhosted.org/packages/3b/3f/412bddb465676288527e9ceee723173b7d4165ad39a4d3423a3e7072baba/cv2imshow-0.10.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-05-25 04:13:39",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "hansalemaos",
    "github_project": "cv2imshow",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "hackyargparser",
            "specs": []
        },
        {
            "name": "keyboard",
            "specs": []
        },
        {
            "name": "kthread_sleep",
            "specs": []
        },
        {
            "name": "numpy",
            "specs": []
        },
        {
            "name": "opencv_python",
            "specs": []
        },
        {
            "name": "subprocess_alive",
            "specs": []
        },
        {
            "name": "subprocess_multipipe",
            "specs": []
        },
        {
            "name": "varpickler",
            "specs": []
        }
    ],
    "lcname": "cv2imshow"
}
        
Elapsed time: 0.07195s