Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
fail-fast: false
max-parallel: 4
matrix:
python-version: [3.6, 3.7]
python-version: [3.7, 3.8]

steps:
- uses: actions/checkout@v1
Expand Down
2 changes: 1 addition & 1 deletion displayarray/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
display is a function that displays these in their own windows.
"""

__version__ = "1.1.1"
__version__ = "1.3.1"

from .window.subscriber_windows import display, breakpoint_display, read_updates, publish_updates
from . import effects
10 changes: 7 additions & 3 deletions displayarray/frame/frame_publishing.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ def pub_cam_loop_opencv(
sub = subscriber_dictionary.cam_cmd_sub(name)
sub.return_on_no_data = ""
msg = ""

if mjpg:
try:
cam.set(cv2.CAP_PROP_FOURCC, cv2.CAP_OPENCV_MJPEG)
Expand All @@ -174,7 +173,11 @@ def pub_cam_loop_opencv(
if frame_counter >= cam.get(cv2.CAP_PROP_FRAME_COUNT):
frame_counter = 0
cam = cv2.VideoCapture(cam_id)
subscriber_dictionary.CV_CAMS_DICT[name].frame_pub.publish(frame)
try:
subscriber_dictionary.CV_CAMS_DICT[name].frame_pub.publish(frame)
except KeyError: # we got deleted. Time to exit.
cam.release()
return False
msg = sub.get()
sub.release()

Expand All @@ -195,9 +198,10 @@ def pub_cam_thread(
"""Run pub_cam_loop in a new thread. Starts on creation."""

name = uid_for_source(cam_id)
t = None
if name in uid_dict.keys():
t = uid_dict[name]
else:
if t is None or not t.is_alive(): # Enables reopening cameras
if "cv" in force_backend.lower():
pub_cam_loop = pub_cam_loop_opencv
elif (
Expand Down
8 changes: 4 additions & 4 deletions displayarray/frame/frame_updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,10 @@ async def read_updates_zero_mq(
try:
md = s.recv_json(flags=flags)
msg = s.recv(flags=flags, copy=copy, track=track)
buf = memoryview(msg)
arr = np.frombuffer(buf, dtype=md["dtype"])
arr.reshape(md["shape"])
name = md["name"]
buf = memoryview(msg) # type: ignore
arr = np.frombuffer(buf, dtype=md["dtype"]) # type: ignore
arr.reshape(md["shape"]) # type: ignore
name = md["name"] # type: ignore
cb_val = end_callback(md)
yield name, arr
except zmq.ZMQError as e:
Expand Down
8 changes: 8 additions & 0 deletions displayarray/frame/subscriber_dictionary.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ def stop_cam(cam_id: Union[int, str]):
CV_CAM_HANDLERS_DICT[str(cam_id)].cmd_pub.publish("quit", blocking=True)


def del_cam(cam_id: Union[int, str]):
"""Delete camera "cam_id"."""
if str(cam_id) in CV_CAMS_DICT:
del CV_CAMS_DICT[str(cam_id)]
if str(cam_id) in CV_CAM_HANDLERS_DICT:
del CV_CAM_HANDLERS_DICT[str(cam_id)]


def cam_cmd_sub(cam_id, blocking=True):
"""Get a command subscriber for registered camera "cam_id"."""
if blocking:
Expand Down
2 changes: 1 addition & 1 deletion displayarray/window/subscriber_windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ def add_callback(self, callback):
def __stop_all_cams(self):
for c in self.source_names:
subscriber_dictionary.stop_cam(c)
subscriber_dictionary.del_cam(c)

def handle_keys(self, key_input: int):
"""Capture key input for the escape function and passing to key control subscriber threads."""
Expand Down Expand Up @@ -214,7 +215,6 @@ def __check_too_many_channels(self):
def update_frames(self):
"""Update the windows with the newest data for all frames."""
self.frames = {}

for i in range(len(self.input_vid_global_names)):
if self.input_vid_global_names[i] in self.FRAME_DICT and not isinstance(
self.FRAME_DICT[self.input_vid_global_names[i]], NoData
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
setup(
long_description=readme,
name="displayarray",
version="1.3.0",
version="1.3.1",
description="Tool for displaying numpy arrays.",
python_requires="==3.*,>=3.6.0",
python_requires="==3.*,>=3.7.0",
project_urls={"repository": "https://github.com/simleek/displayarray"},
author="SimLeek",
author_email="[email protected]",
Expand Down
4 changes: 2 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[tox]
envlist = py36, py37, mypy, pydocstyle
envlist = py37, py38, mypy, pydocstyle
isolated_build = false
skip_missing_interpreters = true
skipsdist=True

[gh-actions]
python =
3.6: py36, pydocstyle
3.7: py37, mypy, pydocstyle
3.8: py38, pydocstyle

[testenv]
whitelist_externals = coverage
Expand Down