儲存原始影像

This commit is contained in:
JEFF 2025-02-26 21:46:08 +08:00
parent 92d16344e2
commit 38f5dde3b8
2 changed files with 5 additions and 6 deletions

View File

@ -125,7 +125,6 @@ class ScrewDrive(QThread):
# print(f'self.Pre_ROI_Dic = {self.Myini.Pre_ROI_Dic}') # print(f'self.Pre_ROI_Dic = {self.Myini.Pre_ROI_Dic}')
print(f'self.Identity = {self.Identity}') print(f'self.Identity = {self.Identity}')
# print(f'self.ROI_List = {self.Myini.ROI_List}') # print(f'self.ROI_List = {self.Myini.ROI_List}')
# 根據recipe名稱找INI檔內座標的絕對位置切割影像 切第一次圖
self.image_AI = self.image_AI[self.Myini.Pre_ROI_Dic[self.Identity][1]:self.Myini.Pre_ROI_Dic[self.Identity][1] + self.Myini.Pre_ROI_Dic[self.Identity][3], self.Myini.Pre_ROI_Dic[self.Identity][0]:self.Myini.Pre_ROI_Dic[self.Identity][0] + self.Myini.Pre_ROI_Dic[self.Identity][2]] self.image_AI = self.image_AI[self.Myini.Pre_ROI_Dic[self.Identity][1]:self.Myini.Pre_ROI_Dic[self.Identity][1] + self.Myini.Pre_ROI_Dic[self.Identity][3], self.Myini.Pre_ROI_Dic[self.Identity][0]:self.Myini.Pre_ROI_Dic[self.Identity][0] + self.Myini.Pre_ROI_Dic[self.Identity][2]]
self.Result = self.Result[self.Myini.Pre_ROI_Dic[self.Identity][1]:self.Myini.Pre_ROI_Dic[self.Identity][1] + self.Myini.Pre_ROI_Dic[self.Identity][3], self.Myini.Pre_ROI_Dic[self.Identity][0]:self.Myini.Pre_ROI_Dic[self.Identity][0] + self.Myini.Pre_ROI_Dic[self.Identity][2]] self.Result = self.Result[self.Myini.Pre_ROI_Dic[self.Identity][1]:self.Myini.Pre_ROI_Dic[self.Identity][1] + self.Myini.Pre_ROI_Dic[self.Identity][3], self.Myini.Pre_ROI_Dic[self.Identity][0]:self.Myini.Pre_ROI_Dic[self.Identity][0] + self.Myini.Pre_ROI_Dic[self.Identity][2]]
# print(f'self.Result.shape = {self.Result.shape}') # print(f'self.Result.shape = {self.Result.shape}')
@ -169,7 +168,6 @@ class ScrewDrive(QThread):
while self.AOIimage_ISREADY == False: while self.AOIimage_ISREADY == False:
time.sleep(0.01) time.sleep(0.01)
print('.') print('.')
# 根據recipe名稱找INI檔內座標的絕對位置切割影像 切第二次圖
self.image_AOI = self.image_AOI[self.Myini.Pre_ROI_Dic[self.Identity][1]:self.Myini.Pre_ROI_Dic[self.Identity][1] + self.Myini.Pre_ROI_Dic[self.Identity][3], self.Myini.Pre_ROI_Dic[self.Identity][0]:self.Myini.Pre_ROI_Dic[self.Identity][0] + self.Myini.Pre_ROI_Dic[self.Identity][2]] self.image_AOI = self.image_AOI[self.Myini.Pre_ROI_Dic[self.Identity][1]:self.Myini.Pre_ROI_Dic[self.Identity][1] + self.Myini.Pre_ROI_Dic[self.Identity][3], self.Myini.Pre_ROI_Dic[self.Identity][0]:self.Myini.Pre_ROI_Dic[self.Identity][0] + self.Myini.Pre_ROI_Dic[self.Identity][2]]
# cv2.imwrite(f'./imageprocess/{self.Identity}.png', self.image_AOI) # cv2.imwrite(f'./imageprocess/{self.Identity}.png', self.image_AOI)

View File

@ -201,7 +201,7 @@ class Screwdriver_Detection(QtWidgets.QMainWindow, Ui_Screwdriver_Detection_Wind
self.recipe_model = 'Milwaukee' self.recipe_model = 'Milwaukee'
elif self.engineer_mode_window.comboBox_recipe.currentText() == 'KleinTool': elif self.engineer_mode_window.comboBox_recipe.currentText() == 'KleinTool':
# ----------------------20250224修改 調整為更改單後會換成對應模型-------------------------- # ----------------------20250224修改 調整為更改單後會換成對應模型--------------------------
self.recipe_model = 'KleinTool' self.recipe_model = 'KleinTool'
# self.awm_Key_for_Recipe = 'M11-2303002' # self.awm_Key_for_Recipe = 'M11-2303002'
# self.dbwindow.awm_key = 'M11-2303002' # self.dbwindow.awm_key = 'M11-2303002'
@ -544,14 +544,14 @@ class Screwdriver_Detection(QtWidgets.QMainWindow, Ui_Screwdriver_Detection_Wind
def Start(self): def Start(self):
# if self.awm_Key_for_Recipe == 'M11-2303001' and self.dbwindow.awm_key == 'M11-2303001': # if self.awm_Key_for_Recipe == 'M11-2303001' and self.dbwindow.awm_key == 'M11-2303001':
# print(self.awm_Key_for_Recipe) # print(self.awm_Key_for_Recipe)
self.Time_for_Record = time.strftime('%Y%m%d_%H%M%S')
if self.recipe_model == 'Milwaukee': #公單為Milwaukee if self.recipe_model == 'Milwaukee': #公單為Milwaukee
threading.Thread(target=self.Start_Thread_Milwaukee, args=()).start() #進入Milwaukee線程 threading.Thread(target=self.Start_Thread_Milwaukee, args=()).start() #進入Milwaukee線程
# -------------------學長之前寫的測試工單------------------------- # -------------------學長之前寫的測試工單-------------------------
# if self.awm_Key_for_Recipe == 'M11-2303002': # if self.awm_Key_for_Recipe == 'M11-2303002':
# threading.Thread(target=self.Start_Thread_KleinTools_Gray, args=()).start() # threading.Thread(target=self.Start_Thread_KleinTools_Gray, args=()).start()
# -------------------20250117修改------------------------- # -------------------20250117修改-------------------------
if self.recipe_model == 'KleinTool' or self.recipe_model == 'KleinToolblack': #單為KleinTool或KleinToolblack if self.recipe_model == 'KleinTool' or self.recipe_model == 'KleinToolblack': #單為KleinTool或KleinToolblack
threading.Thread(target=self.Start_Thread_KleinTools_Gray, args=()).start() #進入KleinTool線程 threading.Thread(target=self.Start_Thread_KleinTools_Gray, args=()).start() #進入KleinTool線程
self.real_detect_amount += 1 self.real_detect_amount += 1
def Start_Thread_Milwaukee(self): def Start_Thread_Milwaukee(self):
@ -584,6 +584,7 @@ class Screwdriver_Detection(QtWidgets.QMainWindow, Ui_Screwdriver_Detection_Wind
self.inputimage = copy.deepcopy(self.camera.Image_RealTime) self.inputimage = copy.deepcopy(self.camera.Image_RealTime)
threading.Thread(target=self.camera.SetExposureTime, args=(self.MYINI.Camera_Setting['exposuretime_aoi'],)).start() threading.Thread(target=self.camera.SetExposureTime, args=(self.MYINI.Camera_Setting['exposuretime_aoi'],)).start()
self.Result = cv2.flip(copy.deepcopy(self.inputimage), 1) self.Result = cv2.flip(copy.deepcopy(self.inputimage), 1)
cv2.imwrite(f'./imageprocess/Milwaukee/Origin_image/{self.Time_for_Record}.png', self.Result) #存原圖
for sd in self.screwdrives: for sd in self.screwdrives:
sd.Result = self.Result sd.Result = self.Result
sd.image_AI = cv2.cvtColor(self.Result, cv2.COLOR_BGR2GRAY) sd.image_AI = cv2.cvtColor(self.Result, cv2.COLOR_BGR2GRAY)
@ -637,7 +638,7 @@ class Screwdriver_Detection(QtWidgets.QMainWindow, Ui_Screwdriver_Detection_Wind
self.All_Report_count = 0 self.All_Report_count = 0
self.inputimage = copy.deepcopy(self.camera.Image_RealTime) self.inputimage = copy.deepcopy(self.camera.Image_RealTime)
self.Result = cv2.flip(copy.deepcopy(self.inputimage), 1) self.Result = cv2.flip(copy.deepcopy(self.inputimage), 1)
cv2.imwrite(f'./imageprocess/KleinTool/Origin_image/{self.Time_for_Record}.png', self.Result) #存原圖
for sd in self.screwdrives: for sd in self.screwdrives:
sd.Result = self.Result sd.Result = self.Result
sd.image_AI = cv2.cvtColor(self.Result, cv2.COLOR_BGR2GRAY) sd.image_AI = cv2.cvtColor(self.Result, cv2.COLOR_BGR2GRAY)