PYQT Qlabel pixmap from PyCamera
up vote
0
down vote
favorite
I am working with a python multiprocessing program with three processes. The first one captures images from a pyCamera module, the second one is a GUI and the third one does some simple image processing. I am trying to show the current image taken by the camera in a Qlabel. I don't need to have more than 10 fps, it could be even as slow as 1fps. But every time I use setPixmap it looks like the updated image takes too long to show.
class Ui_MainWindow(QtWidgets.QMainWindow):
def __init__(self):
super(Ui_MainWindow,self).__init__()
uic.loadUi('/usr/local/bin/meltingPoints/GUI.ui',self)
#variables that contain the captured image
self.Gimage = mp.Array('B',768*1024*3,lock = mp.Lock())
#Image update timer
self.updateTimer = QtCore.QTimer()
self.updateTimer.timeout.connect(self.update_labels)
self.updateTimer.start(1000)
def update_labels(self):
#Reading the image from mp.Array
self.Gimage.acquire()
imageD = np.frombuffer(self.Gimage.get_obj(),dtype=np.uint8)
self.Gimage.release()
#Converting the image to Qimage
imageD.shape = [768,1024,3]
imageP = Image.fromarray(imageD[0:564,149:901,:].astype('uint8'), 'RGB')
imageQ = ImageQt(imageP.resize((400,300)))
#Setting Pixmap
self.imageDisplay.setPixmap(QtGui.QPixmap.fromImage(imageQ))
#Other simple label text updates go on after this
I do get an image in the Qlabel widget but instead of taking one second to update as the Timer configuration suggests, it takes about 5 seconds to show any change in the image. I have tried to use the OwnImageWidget shown here https://www.kurokesu.com/main/2016/08/01/opencv-usb-camera-widget-in-pyqt/ and it does update images on time, but the GUI gets unresponsive while the image update happens.
Any Ideas on what could be happening? I'll also include the function that captures the images (this function is called as a process in the main script and captures the image into two different multiprocessing arrays)
from time import sleep
import numpy as np
import picamera
def fotografo(Gimage,Oimage):
#Configuracion y encendido de la camara
with picamera.PiCamera() as camera:
#Fotos en blanco y negro
camera.color_effects = (128,128)
#Resolucion maxima
camera.resolution = (1024,768)
#Cambio de los parametros para fotos consistentes
camera.iso = 600
sleep(2)
camera.shutter_speed = camera.exposure_speed
camera.exposure_mode = 'off'
g = camera.awb_gains
camera.awb_mode = 'off'
camera.awb_gains = g
Pic = np.empty((768*1024*3), dtype = np.uint8)
while True:
camera.capture(Pic,'rgb')
Gimage[:] = Pic
Oimage[:] = Pic
sleep(0.25)
Thanks
unlucky_code
pyqt5 qlabel qpixmap
add a comment |
up vote
0
down vote
favorite
I am working with a python multiprocessing program with three processes. The first one captures images from a pyCamera module, the second one is a GUI and the third one does some simple image processing. I am trying to show the current image taken by the camera in a Qlabel. I don't need to have more than 10 fps, it could be even as slow as 1fps. But every time I use setPixmap it looks like the updated image takes too long to show.
class Ui_MainWindow(QtWidgets.QMainWindow):
def __init__(self):
super(Ui_MainWindow,self).__init__()
uic.loadUi('/usr/local/bin/meltingPoints/GUI.ui',self)
#variables that contain the captured image
self.Gimage = mp.Array('B',768*1024*3,lock = mp.Lock())
#Image update timer
self.updateTimer = QtCore.QTimer()
self.updateTimer.timeout.connect(self.update_labels)
self.updateTimer.start(1000)
def update_labels(self):
#Reading the image from mp.Array
self.Gimage.acquire()
imageD = np.frombuffer(self.Gimage.get_obj(),dtype=np.uint8)
self.Gimage.release()
#Converting the image to Qimage
imageD.shape = [768,1024,3]
imageP = Image.fromarray(imageD[0:564,149:901,:].astype('uint8'), 'RGB')
imageQ = ImageQt(imageP.resize((400,300)))
#Setting Pixmap
self.imageDisplay.setPixmap(QtGui.QPixmap.fromImage(imageQ))
#Other simple label text updates go on after this
I do get an image in the Qlabel widget but instead of taking one second to update as the Timer configuration suggests, it takes about 5 seconds to show any change in the image. I have tried to use the OwnImageWidget shown here https://www.kurokesu.com/main/2016/08/01/opencv-usb-camera-widget-in-pyqt/ and it does update images on time, but the GUI gets unresponsive while the image update happens.
Any Ideas on what could be happening? I'll also include the function that captures the images (this function is called as a process in the main script and captures the image into two different multiprocessing arrays)
from time import sleep
import numpy as np
import picamera
def fotografo(Gimage,Oimage):
#Configuracion y encendido de la camara
with picamera.PiCamera() as camera:
#Fotos en blanco y negro
camera.color_effects = (128,128)
#Resolucion maxima
camera.resolution = (1024,768)
#Cambio de los parametros para fotos consistentes
camera.iso = 600
sleep(2)
camera.shutter_speed = camera.exposure_speed
camera.exposure_mode = 'off'
g = camera.awb_gains
camera.awb_mode = 'off'
camera.awb_gains = g
Pic = np.empty((768*1024*3), dtype = np.uint8)
while True:
camera.capture(Pic,'rgb')
Gimage[:] = Pic
Oimage[:] = Pic
sleep(0.25)
Thanks
unlucky_code
pyqt5 qlabel qpixmap
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am working with a python multiprocessing program with three processes. The first one captures images from a pyCamera module, the second one is a GUI and the third one does some simple image processing. I am trying to show the current image taken by the camera in a Qlabel. I don't need to have more than 10 fps, it could be even as slow as 1fps. But every time I use setPixmap it looks like the updated image takes too long to show.
class Ui_MainWindow(QtWidgets.QMainWindow):
def __init__(self):
super(Ui_MainWindow,self).__init__()
uic.loadUi('/usr/local/bin/meltingPoints/GUI.ui',self)
#variables that contain the captured image
self.Gimage = mp.Array('B',768*1024*3,lock = mp.Lock())
#Image update timer
self.updateTimer = QtCore.QTimer()
self.updateTimer.timeout.connect(self.update_labels)
self.updateTimer.start(1000)
def update_labels(self):
#Reading the image from mp.Array
self.Gimage.acquire()
imageD = np.frombuffer(self.Gimage.get_obj(),dtype=np.uint8)
self.Gimage.release()
#Converting the image to Qimage
imageD.shape = [768,1024,3]
imageP = Image.fromarray(imageD[0:564,149:901,:].astype('uint8'), 'RGB')
imageQ = ImageQt(imageP.resize((400,300)))
#Setting Pixmap
self.imageDisplay.setPixmap(QtGui.QPixmap.fromImage(imageQ))
#Other simple label text updates go on after this
I do get an image in the Qlabel widget but instead of taking one second to update as the Timer configuration suggests, it takes about 5 seconds to show any change in the image. I have tried to use the OwnImageWidget shown here https://www.kurokesu.com/main/2016/08/01/opencv-usb-camera-widget-in-pyqt/ and it does update images on time, but the GUI gets unresponsive while the image update happens.
Any Ideas on what could be happening? I'll also include the function that captures the images (this function is called as a process in the main script and captures the image into two different multiprocessing arrays)
from time import sleep
import numpy as np
import picamera
def fotografo(Gimage,Oimage):
#Configuracion y encendido de la camara
with picamera.PiCamera() as camera:
#Fotos en blanco y negro
camera.color_effects = (128,128)
#Resolucion maxima
camera.resolution = (1024,768)
#Cambio de los parametros para fotos consistentes
camera.iso = 600
sleep(2)
camera.shutter_speed = camera.exposure_speed
camera.exposure_mode = 'off'
g = camera.awb_gains
camera.awb_mode = 'off'
camera.awb_gains = g
Pic = np.empty((768*1024*3), dtype = np.uint8)
while True:
camera.capture(Pic,'rgb')
Gimage[:] = Pic
Oimage[:] = Pic
sleep(0.25)
Thanks
unlucky_code
pyqt5 qlabel qpixmap
I am working with a python multiprocessing program with three processes. The first one captures images from a pyCamera module, the second one is a GUI and the third one does some simple image processing. I am trying to show the current image taken by the camera in a Qlabel. I don't need to have more than 10 fps, it could be even as slow as 1fps. But every time I use setPixmap it looks like the updated image takes too long to show.
class Ui_MainWindow(QtWidgets.QMainWindow):
def __init__(self):
super(Ui_MainWindow,self).__init__()
uic.loadUi('/usr/local/bin/meltingPoints/GUI.ui',self)
#variables that contain the captured image
self.Gimage = mp.Array('B',768*1024*3,lock = mp.Lock())
#Image update timer
self.updateTimer = QtCore.QTimer()
self.updateTimer.timeout.connect(self.update_labels)
self.updateTimer.start(1000)
def update_labels(self):
#Reading the image from mp.Array
self.Gimage.acquire()
imageD = np.frombuffer(self.Gimage.get_obj(),dtype=np.uint8)
self.Gimage.release()
#Converting the image to Qimage
imageD.shape = [768,1024,3]
imageP = Image.fromarray(imageD[0:564,149:901,:].astype('uint8'), 'RGB')
imageQ = ImageQt(imageP.resize((400,300)))
#Setting Pixmap
self.imageDisplay.setPixmap(QtGui.QPixmap.fromImage(imageQ))
#Other simple label text updates go on after this
I do get an image in the Qlabel widget but instead of taking one second to update as the Timer configuration suggests, it takes about 5 seconds to show any change in the image. I have tried to use the OwnImageWidget shown here https://www.kurokesu.com/main/2016/08/01/opencv-usb-camera-widget-in-pyqt/ and it does update images on time, but the GUI gets unresponsive while the image update happens.
Any Ideas on what could be happening? I'll also include the function that captures the images (this function is called as a process in the main script and captures the image into two different multiprocessing arrays)
from time import sleep
import numpy as np
import picamera
def fotografo(Gimage,Oimage):
#Configuracion y encendido de la camara
with picamera.PiCamera() as camera:
#Fotos en blanco y negro
camera.color_effects = (128,128)
#Resolucion maxima
camera.resolution = (1024,768)
#Cambio de los parametros para fotos consistentes
camera.iso = 600
sleep(2)
camera.shutter_speed = camera.exposure_speed
camera.exposure_mode = 'off'
g = camera.awb_gains
camera.awb_mode = 'off'
camera.awb_gains = g
Pic = np.empty((768*1024*3), dtype = np.uint8)
while True:
camera.capture(Pic,'rgb')
Gimage[:] = Pic
Oimage[:] = Pic
sleep(0.25)
Thanks
unlucky_code
pyqt5 qlabel qpixmap
pyqt5 qlabel qpixmap
edited Nov 13 at 7:15
asked Nov 13 at 7:08
Hugo Jiménez García
13
13
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53275624%2fpyqt-qlabel-pixmap-from-pycamera%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown