I have a tkinter application that reads images from a Basler camera and show the original image and the processed one on a frame of the GUI.
The function that does this is :
def begin_funct():
global image
global processed
global crease
global Horizontal
#open the camera and set the parameters
tlf = pylon.TlFactory.GetInstance()
cam = pylon.InstantCamera(tlf.CreateFirstDevice())
cam.Open()
cam.UserSetSelector = 'Default'
cam.UserSetLoad.Execute()
cam.PixelFormat.SetValue('Mono8')
cam.Gain.SetValue(17.9)
cam.ExposureTime.SetValue(80.0)
cam.TriggerMode.SetValue('On')
cam.TriggerSource.SetValue('Line1')
cam.TriggerActivation.SetValue('RisingEdge')
cam.LineSelector = "Line1"
cam.LineMode = "Input"
#start grabbing the image, process and then show it on the GUI
while True:
res = cam.GrabOne(10000)
img = res.GetArray()
#process_image_from_camera is a module that I wrote to process the image
original,processed,crease,Horizontal=process_image_from_camera(img)
#get the result
image=cv2.resize(original,(int(width_value/2),int(height_value/2)))
edged = cv2.resize(processed, (int(width_value/2),int(height_value/2)))
# OpenCV represents images in BGR order; however PIL represents
# images in RGB order, so we need to swap the channels
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
# convert the images to PIL format...
image = Image.fromarray(image)
edged = Image.fromarray(edged)
# ...and then to ImageTk format
image = ImageTk.PhotoImage(image)
edged = ImageTk.PhotoImage(edged)
#labels to put the image on
label = Label(frame2, image=image, bg='green')
label.image = image
label.grid(row=0,column=0)
label2 = Label(frame2, image=edged, bg='green')
label2.image = edged
label2.grid(row=0,column=1)
My problem is that the images are only displayed on the GUI if there's a timeout or an error in the processing, which means only the last image grabbed is displayed, only when there's an error of execution and the processing stops that we see the result.
I want every image grabbed to be displayed and then the next one and then the next one..
Can anyone see the problem here?