Hi,
Oh, I see now you are plotting the histogram in a separate PlotWindow and
the QLabel is just for the image.
Your lines 46 and 90:
self.mask = np.zeros((self.cameraHeight,self.cameraWidth),np.uint8)
Shouldn't height and width be swapped around? I changed these to
self.mask = np.zeros((self.cameraWidth,self.cameraHeight),np.uint8)
and the code seemed to run OK (I did also fake the data acquired in the
capture.read() as I don't have a webcam).
Patrick
On Tuesday, 2 April 2019 02:30:41 UTC+10:30, Iman Afrouzeh wrote:
>
> I am displaying the image in the function above in displayImage but I
> cannot display my data in hist function inside my gui as graphicsview or
> something else
>
> On Monday, April 1, 2019 at 3:53:44 PM UTC+1, Jim Crowell wrote:
>>
>> Do you just want to display the image, or have a plot on top of it? I use
>> this utility function to set up both, with a histogram (only tested with
>> PyQt5, 'pg' is of course pyqtgraph):
>>
>> To update the image data, you would later call
>>
>> widget.imageItem.setImage(...)
>>
>>
>>
>> def add_plot_image_histogram(widget, image_data, show_plot_axes=False,
>> add_scale_buttons=False):
>> """
>> Add a PlotItem, attached ImageItem, and HistogramLUTWidget to a
>> QWidget.
>> (e.g. created in QTDesigner)
>>
>> The image is offset such that integer plot coordinates correspond
>> to pixel centers rather than corners (which is the default).
>>
>> widget: a QWidget
>> image_data: initial image data
>> show_plot_axes: if False, hide all the plot axes. If True, show
>> the default ('left' & 'bottom' are shown).
>> add_scale_buttons: if True, add up- and down-triangle buttons to
>> increase and decrease image color map limits and
>> a square button for resetting them (see
>> ImageItemUpdater).
>>
>> returns None
>> """
>>
>> layout = QtGui.QGridLayout()
>> widget.setLayout(layout)
>> layout.setSpacing(0)
>>
>> widget.plotView = pg.GraphicsView()
>> layout.addWidget(widget.plotView, 0, 0, 3, 1)
>>
>> widget.plotItem = pg.PlotItem()
>> widget.plotItem.setAspectLocked()
>> widget.plotItem.resize = widget.resize
>> if not show_plot_axes:
>> for axis in ('left','bottom','top','right'):
>> widget.plotItem.showAxis(axis, False)
>> widget.plotView.setCentralItem(widget.plotItem)
>>
>> widget.imageItem = pg.ImageItem(image=image_data)
>> # to make plotted points _centered_ on corresponding image pixels
>> widget.imageItem.translate(-.5,-.5)
>> # put image _behind_ plot
>> widget.imageItem.setZValue(-100)
>> if add_scale_buttons:
>> button_radius = 12 # pixels
>> image_height = widget.imageItem.height()
>>
>> # 'up' button in upper-left corner
>> widget.up_button = Button(button_radius, typ='tu', \
>> parent=widget.imageItem)
>> widget.up_button.setPos(0, 0.95*image_height)
>>
>> # 'down' button just below it
>> widget.down_button = Button(button_radius, typ='td', \
>> parent=widget.imageItem)
>> widget.down_button.setPos(0, 0.80*image_height)
>>
>> # 'reset' (square) button in lower-left corner
>> widget.reset_button = Button(button_radius, typ='s',
>> parent=widget.imageItem)
>>
>> widget.plotItem.addItem(widget.imageItem)
>>
>> widget.histogramView = pg.GraphicsView()
>>
>>
>>
>>
>> On Monday, April 1, 2019 at 7:35:26 AM UTC-4, Iman Afrouzeh wrote:
>>>
>>> Thank you very much for your response.
>>> I have already done that but my problem is that I don't know how to call
>>> the data in it in the python script.
>>> I don't knwo what should I write instead if this:
>>>
>>> self.curve.setData(self.data)
>>> self.l = (self.l+self.n)
>>> self.line.setValue(self.bufferSize)
>>>
>>> ##########this is the place that I don't have any Idea to do
>>>
>>> I know it seems a silly question but I really couldn't find it with a
>>> lot of searches.
>>>
>>> Thank you in advance for your help.
>>>
>>> On Monday, April 1, 2019 at 1:34:16 AM UTC+1, Patrick wrote:
>>>>
>>>> Hi,
>>>>
>>>> Have you followed the instructions here?
>>>> http://www.pyqtgraph.org/documentation/how_to_use.html#embedding-widgets-inside-pyqt-applications
>>>>
>>>> Change your existing imgLabel to a GraphicsView object and then promote
>>>> it to a PlotWidget or GraphicsLayoutWidget as described there.
>>>>
>>>> Patrick
>>>>
>>>> On Saturday, 30 March 2019 02:10:55 UTC+10:30, Iman Afrouzeh wrote:
>>>>>
>>>>> Dear all,
>>>>> I am new in Python and maybe it seems that this question has been
>>>>> answered in other ways before but I could not figure it out after 2 days.
>>>>> I have a qtgraph plot and I want to show it in a QLabel, Qwidget or
>>>>> Graphicsview in a gui that I made in Qtdesigner but I can not find a
>>>>> direct
>>>>> way that shows that graph. I am streaming a video from a camera and I
>>>>> could
>>>>> easily show it in my GUI but I am struggling with this one.
>>>>> Thank you in advance for your help and comments.
>>>>>
>>>>> the problem is in showing
>>>>>
>>>>
--
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/842412d1-0359-4eed-91dd-e6426c54af42%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.