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
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)
Metadata
Release files for cv2imshow 0.10
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cv2imshow-0.10.tar.gz | 52.7 kB | Without provenance | Details for cv2imshow-0.10.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cv2imshow-0.10-py3-none-any.whl | Python 3 | none | any | Details for cv2imshow-0.10-py3-none-any.whl |
Total release size: 106.0 kB
Release files / cv2imshow-0.10.tar.gz
| Download URL | cv2imshow-0.10.tar.gz |
|---|---|
| Size | 52.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
453f990f5aa941a950b84a29a8d8eb130d5a41fcf680d14c51081e8d32a5fb6f
|
|
BLAKE2b-256 checksum How to use checksums |
3b3f412bddb465676288527e9ceee723173b7d4165ad39a4d3423a3e7072baba
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.10
|
Release files / cv2imshow-0.10-py3-none-any.whl
| Download URL | cv2imshow-0.10-py3-none-any.whl |
|---|---|
| Size | 53.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
81eb447bcbe33b42282343aaf680876da54308e6e075ff8e4f3468fd530207ba
|
|
BLAKE2b-256 checksum How to use checksums |
44e251f4724c7683ad4972d8d17144cc39bc1897e349f763f21bf17935d63112
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.10
|
Security for cv2imshow 0.10
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.