Howdy,
What happens if you add the cv2 item to the view after you fully initialize
it?
If you use the imread method with an image file does this work correctly?
This may help identify if this is an issue with the un-official openCV
release or pyqtgraph
something like:
import cv2 as cv
img = cv.imread(cv.samples.findFile("something.jpg")
cv.imshow("something", img)
Cheers,
J-
On Wed, Aug 19, 2020 at 8:02 AM [email protected] <[email protected]>
wrote:
>
> Hi All,
>
> I have some issues with color using pyqtgraph.
> I have a basic code for displaying a RGBA image.
> I am expecting to have a color image but instead I have a graylevel image
> Do you see an obvious explanation to this behavior in this code ?
>
> from pyqtgraph.Qt import QtCore, QtGui
>
> import pyqtgraph as pg
>
> import cv2
>
>
>
> pg.setConfigOptions(imageAxisOrder='row-major')
>
>
>
> app = QtGui.QApplication([])
>
> ## Create window with GraphicsView widget
>
> win = pg.GraphicsLayoutWidget()
>
> win.show() ## show widget alone in its own window
>
> win.setWindowTitle('pyqtgraph example: ImageItem')
>
> view = win.addViewBox()
>
> view.invertY(True)
>
>
>
> ## lock the aspect ratio so pixels are always square
>
> view.setAspectLocked(True)
>
>
>
> ## Create image item
>
> l_img_item = pg.ImageItem(border='w')
>
> view.addItem(l_img_item)
>
> l_img_item.setCompositionMode(QtGui.QPainter.CompositionMode_Plus)
>
> # l_img_item.setZValue(10)
>
> # l_img_item.setOpacity(0.5)
>
>
>
> l_image = cv2.imread('_test.png')
>
> l_image = cv2.cvtColor(l_image, cv2.COLOR_RGBA2RGB)
>
>
>
> ## Set initial view bounds
>
> view.setRange(QtCore.QRectF(0, 0, 375, 400))
>
>
>
> # timer = QtCore.QTimer()
>
> # timer.timeout.connect(self._update)
>
> # timer.start(50)
>
> l_img_item.setImage(l_image, autoLevels=False)
>
> l_img_item.setCompositionMode(QtGui.QPainter.CompositionMode_Plus)
>
> app.exec_()
>
>
> Thanks for your help
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "pyqtgraph" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/pyqtgraph/28bcd3c1-bf68-495a-be2d-65e0021f4cd1n%40googlegroups.com
> <https://groups.google.com/d/msgid/pyqtgraph/28bcd3c1-bf68-495a-be2d-65e0021f4cd1n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
--
You received this message because you are subscribed to the Google Groups
"pyqtgraph" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/pyqtgraph/CAKEVg3FvwyAgLWBtJiSmbkg0mwvaok39356Z2HyHySYfe9qf2A%40mail.gmail.com.