[Chennaipy] How to increase the speed of plotting in GUI(using Tkinter) using FigureCanvasTkAGG?

aishwarya selvaraj aishwaryaselvaraj1708 at gmail.com
Thu Jun 7 08:17:53 EDT 2018


Dear all,

I have 2 files created, one a .pyx file with a class named AndorCamersSDK
which has a function named LiveAcquisition(). The second file, a .py file
with a Class AndorCameraGUI which makes use of Tkinter to create a GUI.
This class has function LivePlot(), and RepeatPlot().Inside
LiveAcquisition() I am acquiring N number of frames and after acquiring
each frame I need to display it using LivePlot() and RepeatPlot(). Without
the display, just acquiring and storing for 300 frames takes 6.2 for
execution, which is fine by me. But When I start displaying it exceeds this
time limit. eg, it takes around 9 seconds for acquiring and displaying 300
images of size 512 x 512. I need to acquire and display within 6 sec for
300 frames.
How do I solve this?

-- 
Regards,
Aishwarya Selvaraj
ᐧ
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/chennaipy/attachments/20180607/f250287b/attachment.html>
-------------- next part --------------
                                                                                                                                                                                           
File 1: .pyx code ; Present inside class AndorCameraSDK
def  LiveAcquisition(self):
        for i in range(no_of_frames): 
			data[i,:,:] = PyArray_NewFromDescr(<PyTypeObject *> np.ndarray, np.dtype('<H'), 2,dims, strides,pBuf, np.NPY_C_CONTIGUOUS, None)
				if (i==0):
					self.master.LivePlot(data[i,:,:])
				else:
					self.master.RepeatPlot(data[i,:,:] 
			   
File 2 : .py code; Below functions are present inside a class named AndorCameraGUI  
                                                                                  
def LivePlot(self,image):
		self.count = 0
		self.fig = Figure(figsize = (4, 5))
		self.fig.patch.set_facecolor('xkcd:light grey') # When this is removed a white color is seen in the background of the figure
		self.a = self.fig.add_subplot(111)
		self.a.set_xlim([0, self.image_width/int(self.HBin)])
		self.a.set_ylim([0, self.image_height/int(self.VBin)])
		image = image.transpose()
		self.a.imshow(image,'gray')
		self.canvas = FigureCanvasTkAgg(self.fig,self.master)
		self.canvas.draw()
		self.canvas.get_tk_widget().pack(side =LEFT)
		self.toolbar =    NavigationToolbar2TkAgg(self.canvas,self.master)
		self.toolbar.update()
		self.canvas._tkcanvas.pack(side = LEFT)                                 
																																					 
def RepeatPlot(self,image):
		self.im.set_data(image)
		self.a.draw_artist(self.im)
		self.canvas.blit()
		self.fig.canvas.flush_events()



More information about the Chennaipy mailing list