ich bin dabei modifikationen an einem Code vorzunehmen, den ich selbst nicht geschrieben habe.
Aktuell stürzt das Programm recht heufig ab bei gewissen Konfigurationseinstellungen.
Meine ersten Recherchen haben ergeben, dass es Wohl auf einen Fehler zurückzuführen ist der statt einem Tupel eine Variable/Liste/usw als inhaltArgs() verwendet.
Das habe ich dazu bereits gefunden:
Code: Alles auswählen
thread_01 = threading.Thread(target=calculate_the_square, args=(array))
thread_01 = threading.Thread(target=calculate_the_square, args=(array,))
Auszug aus dem Main Programm, wo der Thread gestartet wird:Windows fatal exception: access violation
Thread 0x00000480 (most recent call first):
File "C:\Users\LCTF\Desktop\experimental\run_camera.py", line 358 in get_frame_spots
File "C:\Users\LCTF\Desktop\experimental\run_camera.py", line 90 in run
File "C:\Users\LCTF\AppData\Local\Programs\Python\Python312\Lib\threading.py", line 1073 in _bootstrap_inner
File "C:\Users\LCTF\AppData\Local\Programs\Python\Python312\Lib\threading.py", line 1030 in _bootstrap
Current thread 0x00002cd0 (most recent call first):
File "C:\Users\LCTF\AppData\Local\Programs\Python\Python312\Lib\site-packages\pyqtgraph\graphicsItems\ViewBox\ViewBox.py", line ??? in <lambda>
File "C:\Users\LCTF\Desktop\experimental\main.py", line 4399 in <module>
Process finished with exit code -1073741819 (0xC0000005)
Code: Alles auswählen
def run_manual_mode(self):
print("Messung gestartet")
if self.init_camera is True:
self.IDS_AutoShutter(0)
wl_begin = self.spinBox_wl_begin_c_exposure.value()
wl_end = self.spinBox_wl_end_c_exposure.value()
frames = self.spinBox_frames.value()
avg = self.spinBox_avg.value()
self.plotitem_extinction.setLimits(xMin = wl_begin)
self.plotitem_extinction.setLimits(xMax = wl_end)
self.plotitem_extinction.setRange(xRange=[wl_begin, wl_end])
self.plotitem_extinction.setLimits(yMin=0)
# self.plotitem_extinction.setRange(yRange=[0, 0.25])
self.Centroid_list_camera=[]
self.Maximum_list_camera=[]
self.Maximum_wavelength_camera=[]
self.Time_list_camera = []
self.Create_spot_list()
self.Create_Extinction_list()
self.start_time = time.time()
self.camera_thread = CameraRun(self.hCam, self.pcImageMemory, self.width, self.height,
self.nBitsPerPixel, self.pitch, self.bytes_per_pixel, self.vario, self.spot_list,
self.cal_list, self.polynom_order, wl_begin, wl_end, frames, avg,
time=self.start_time)
self.camera_thread.start() # Startet den Camera_Thread
self.camera_timer.start(1000) # Ein Timer über 1 Sekunde. Startet die funktion Plot_time.(Aktualisieren der Daten in den Plots)
Code: Alles auswählen
class CameraRun(threading.Thread):
""" Camera running thread """
Centroid_list = []
Maximum_list = []
Maximum_wavelength_list = []
Time_List = []
Extinction_List = []
Wavelength_List = []
Ext_spots_List = []
def __init__(self, camera, pcImageMemory, width, height, nBitsPerPixel,
pitch, bytes_per_pixel, varioSpec, spot_list,
cal_list, polynom_order, wl_begin, wl_end, frames,
avg, fortschritt=0, time=0):
super().__init__()
# Werte für die Kamera
self.hCam = camera # Kamera
self.pcImageMemory = pcImageMemory
self.width = width
self.height = height
self.nBitsPerPixel = nBitsPerPixel
self.pitch = pitch
self.bytes_per_pixel = bytes_per_pixel
self.vario = varioSpec # Filter
self.spot_list = spot_list # Liste mit den Spots in Form: ((x, y), r,(o,g,b),gruppe)
self.cal_list = cal_list # Enthält Wl, Exp time und FPS: [wl_begin_c,temp_exp, temp_fps,histogram_mean]
self.polynom_order = polynom_order
self.wl_begin = wl_begin # Startwellenlänge
self.wl_end = wl_end # Endwellenlänge
self.frame_count = frames # Anzahl der Frames pro Wellenlänge
self.avg = avg # Anzahl der Wdh. bis zum Plot
self.time = time
self.fortschritt = fortschritt
self.killed = False
self.polyline = np.arange(self.wl_begin, self.wl_end, 0.001)
self.images = []
self.wavelength = []
self.low_ext_wl = 0
self.high_ext_wl = 0
self.centroid_boundary = True
self.spot_extinction_list = None
self.wavelength_list = None
self.cycle = None
def run(self):
""" Start the running thread """
Time_List = []
self.ids_auto_shutter(0)
self.cycle = 1
while not self.killed:
# Listen zur Wertemittlung
ext_mean = []
i = 1
if self.time is None:
start_proc = time.time()
else:
start_proc = self.time
while i <= self.avg:
# print("Durchlauf: ", i, " von ", reps)
self.get_frames()
list_bildverarbeitung = self.get_frame_spots(self.cal_list, self.images) # enthält [list_mean_spot,list_mean_bg,wavelength]
self.spot_extinction_list, self.wavelength_list = self.get_ext_values(list_bildverarbeitung)
ext_mean.append(self.spot_extinction_list)
i = i + 1
ext_mean = np.asarray(ext_mean)
ext_mean = np.mean(ext_mean, axis=0)
ext_mean = ext_mean.tolist()
# print("")
# print(ext_mean)
# print("")
CameraRun.Ext_spots_List.append(ext_mean)
centroid_list, maximum_list, maximum_wavelength_list, wl_list, spot_ext_list = self.math_calculation(self.wavelength_list, ext_mean)
Danke.