Skip to content

Commit

Permalink
fix: monkypatch qimage2ndarray
Browse files Browse the repository at this point in the history
  • Loading branch information
JSS95 committed Nov 29, 2022
1 parent 0640122 commit 2b096b4
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions civiq6/capture.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import numpy as np
import numpy.typing as npt
import os
from qimage2ndarray import array2qimage # type: ignore[import]
import qimage2ndarray # type: ignore[import]
from typing import Optional, List
import vimba # type: ignore[import]
from .camera import VimbaCamera
Expand All @@ -29,6 +29,13 @@
]


# Monkeypatch qimage2ndarray until new version (> 1.9.0)
# https://github.com/hmeine/qimage2ndarray/issues/29
for name, qimage_format in qimage2ndarray.qimageview_python.FORMATS.items():
if name in dir(QtGui.QImage.Format):
qimage_format.code = getattr(QtGui.QImage, name)


VIMBA_LOGGER = vimba.Log.get_instance()


Expand Down Expand Up @@ -182,7 +189,7 @@ def setArray(self, array: npt.NDArray[np.uint8]):
if array.size == 0:
img = QtGui.QImage()
else:
img = array2qimage(array)
img = qimage2ndarray.array2qimage(array)
self.imageChanged.emit(img)

oldsize = self.arraySize()
Expand Down

0 comments on commit 2b096b4

Please sign in to comment.