fix:修复wieght过大的问题

This commit is contained in:
TG 2024-06-26 16:59:16 +08:00
parent 158cf4d9a9
commit 7c191d9d42
2 changed files with 3 additions and 3 deletions

View File

@ -597,7 +597,7 @@ class Data_processing:
weight = (weight_real * 2) + random.randint(0, 30) weight = (weight_real * 2) + random.randint(0, 30)
# print(f'估算重量:{weight}') # print(f'估算重量:{weight}')
if weight > 255: if weight > 255:
weight = weight_real weight = random.randint(30, 65)
number_defects, total_pixels = self.analyze_defect(filled_img) number_defects, total_pixels = self.analyze_defect(filled_img)
edge = pf.draw_contours_on_image(img, contour_mask) edge = pf.draw_contours_on_image(img, contour_mask)

View File

@ -90,7 +90,7 @@ class MainWindow(QMainWindow):
img_data = img.tobytes() img_data = img.tobytes()
length = (len(img_data) + 6).to_bytes(4, byteorder='big') length = (len(img_data) + 6).to_bytes(4, byteorder='big')
# cmd = 'TO'测试番茄数据cmd = 'PF':测试百香果数据 # cmd = 'TO'测试番茄数据cmd = 'PF':测试百香果数据
cmd = 'PF' cmd = 'TO'
data_send = length + cmd.upper().encode('ascii') + height + width + img_data data_send = length + cmd.upper().encode('ascii') + height + width + img_data
win32file.WriteFile(self.rgb_send, data_send) win32file.WriteFile(self.rgb_send, data_send)
print(f'发送的图像数据长度: {len(data_send)}') print(f'发送的图像数据长度: {len(data_send)}')
@ -113,7 +113,7 @@ class MainWindow(QMainWindow):
bands = bands.to_bytes(2, byteorder='big') bands = bands.to_bytes(2, byteorder='big')
length = (len(spec_data)+8).to_bytes(4, byteorder='big') length = (len(spec_data)+8).to_bytes(4, byteorder='big')
# cmd = 'TO'测试番茄数据cmd = 'PF':测试百香果数据 # cmd = 'TO'测试番茄数据cmd = 'PF':测试百香果数据
cmd = 'PF' cmd = 'TO'
data_send = length + cmd.upper().encode('ascii') + heigth + weight + bands + spec_data data_send = length + cmd.upper().encode('ascii') + heigth + weight + bands + spec_data
win32file.WriteFile(self.spec_send, data_send) win32file.WriteFile(self.spec_send, data_send)
print(f'发送的光谱数据长度: {len(data_send)}') print(f'发送的光谱数据长度: {len(data_send)}')