我有两个独立的文件,每个文件都有自己定义的类。
档案1:
class AndorCameraSDK:
def __init__(self):
self.count = 0
def LiveAcquisition(self,nframes,np.ndarray[np.unit16_t,ndim = 3,mode = 'c']image:
cdef unsigned char * pBuf #This has the data
#.......Initialisation of parameters..............#
for i in range(nframes):
pBuf = <unsigned char *>calloc(sizeinBytes,sizeof(unsigned char)
#-----Storing the data in pBuf into a 3-D array image....#
pus_image = <unsigned short*> pBuf
for j in range(self.width):
pus_image = <unsigned short*> pBuf
for k in range(self.height):
image[i][j][k] = pus_image[0]
pus_image += 1
_puc_image += self.stride
def function1(self):
#Something else to be done with another function在文件2中
import AndorCameraSDK as andorcamera
class AndorCameraGUI:
def __init__(self):
#Making use of Tkinter couple of widgets has been created, which includes a button named LiveImage which calls the function LiveImageGUI.
def LiveImageGUI (self):
self.camera = andorcamera()
#define a 3D array I
self.camera.LiveAcquisition(nframes,I) #called from File 1
def LivePlot(self)
# A function using FigurecanvasTkAgg to display the image processed from LiveAcquisition in the display area defined in the GUI panel我想达到的目标是:
pBuf存储到3D数组中的for循环必须是线程在同一数组中调用的函数。LivePlot函数,以便将存储的图像帧显示在GUI中。(i+1)st帧时,显示i第四帧,这样就不会有时间延迟。有人能帮我一下吗?任何帮助都是非常感谢的。
发布于 2018-05-18 10:39:49
我没有线程处理的经验,但是我在您的代码中没有看到线程的证据。我整理了关于缩进和删除超级代码的代码。左边是代码,说明了如何在类之间调用函数。
from tkinter import *
class AndorCameraSDK():
def __init__(self, master):
print('SDK Init') # Show that AndorCameraSDK.__init__ runs
self.master = master # Save reference to master
def LiveAcquisition(self):
print('SDK LiveAcquisition') # Show that AndorCameraSDK.LiveAcquisition runs
pBuf = 'Some data' # Dummy data
self.master.LivePlot() # Call instance of AndorCameraGUI.LivePlot
class AndorCameraGUI():
def __init__(self):
print('GUI Init') # Show that AndorCameraGUI.__init__ runs
def LiveImageGUI(self):
print('GUI LiveImageGUI') # Show that AndorCameraGUI.LiveImageGUI runs
self.camera = AndorCameraSDK(self) # Create instance of AndorCameraSDK
self.camera.LiveAcquisition() # Call AndorCameraSDK.LiveAcquisition
def LivePlot(self):
print('GUI LivePlot') # Show that AndorCameraGUI.LivePlot runs
app = AndorCameraGUI()
app.LiveImageGUI() # Instead of pressing a buttonhttps://stackoverflow.com/questions/50404195
复制相似问题