if yawtick<0:
ytx="脸部右转"+str(round((0-yawtick), 2))+'度'
elif yawtick>0:
ytx="脸部左转"+str(round(yawtick,2))+'度'
else:
ytx="正向0度"
self.label_yaw_valueL.setText(ytx)
# Handle srcfilepathlist
for imgpath in self.srcfilepathlist:
try:
img = cv2.imdecode(numpy.fromfile(imgpath, dtype=numpy.uint8), -1)
if img is not None:
itemname = Path(imgpath).stem
self.add_item_to_Qlistwiget_safety(self.listWidget_main, itemname, img, tootip=str(imgpath))
except FileNotFoundError:
print(f"Warning: File not found {imgpath}")
except Exception as e:
print(f"Error loading image {imgpath}: {str(e)}")
# Handle dstfilepathlist
for imgpath1 in self.dstfilepathlist:
try:
img = cv2.imdecode(numpy.fromfile(imgpath1, dtype=numpy.uint8), -1)
if img is not None:
itemname = Path(imgpath1).stem
self.add_item_to_Qlistwiget_safety(self.listWidget_second, itemname, img, tootip=str(imgpath1))
except FileNotFoundError:
print(f"Warning: File not found {imgpath1}")
except Exception as e:
print(f"Error loading image {imgpath1}: {str(e)}")
if self.srcfilepathlist is None or len(self.srcfilepathlist)==0:
self.pushButton_main_delsel.setDisabled(True)
self.pushButton_main_copyall.setDisabled(True)
self.pushButton_main_copysel.setDisabled(True)
if self.dstfilepathlist is None or len(self.dstfilepathlist)==0:
self.pushButton_sec_delsel.setDisabled(True)
self.pushButton_sec_copyall.setDisabled(True)
self.pushButton_sec_copysel.setDisabled(True)
# Exit early if there are no files to process
if len(srcfilepathlist) == 0 and len(dstfilepathlist) == 0:
return
try:
# Create and display the preview dialog
previewdlg = previewDlgClass()
MainWindow = QtWidgets.QDialog()
previewdlg.setupUi(MainWindow)
previewdlg.loadList(item) # Make sure loadList can handle exceptions gracefully
MainWindow.exec_()
except Exception as e:
print(f"Error during preview dialog execution: {str(e)}")
# Optionally provide a user-friendly error message or log the error appropriately
# Reload face info into the frame, ensure this call is safe
try:
self.frame.loadfacesinfo(self.facesgrid)
except Exception as e:
print(f"Error reloading face info: {str(e)}")