新建分支developmen
0
.gitignore
vendored
Executable file → Normal file
0
classifer.py
Executable file → Normal file
0
pics/TODO.png
Executable file → Normal file
|
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 30 KiB |
0
pics/result.png
Executable file → Normal file
|
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 34 KiB |
0
pics/从木板中提取色彩.png
Executable file → Normal file
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
0
pics/色彩分类.png
Executable file → Normal file
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 26 KiB |
0
root_dir.py
Executable file → Normal file
@ -17,35 +17,38 @@ def main():
|
|||||||
while True:
|
while True:
|
||||||
# receive data
|
# receive data
|
||||||
t1 = time.time()
|
t1 = time.time()
|
||||||
size_buff = socket_receive.recv(4)
|
size_buff = socket_receive.recv(5)
|
||||||
n_rows, n_cols = size_buff[0] << 8 | size_buff[1], size_buff[2] << 8 | size_buff[3]
|
if size_buff[4] == 0:
|
||||||
data_size = n_rows * n_cols * 3
|
|
||||||
print(data_size)
|
n_rows, n_cols = size_buff[0] << 8 | size_buff[1], size_buff[2] << 8 | size_buff[3]
|
||||||
recv_size = data_size
|
data_size = n_rows * n_cols * 3
|
||||||
buff_all, size = [], 0
|
print(data_size)
|
||||||
while True:
|
recv_size = data_size
|
||||||
data_buff = socket_receive.recv(recv_size)
|
buff_all, size = [], 0
|
||||||
recv_size -= len(data_buff)
|
while True:
|
||||||
buff_all += data_buff
|
data_buff = socket_receive.recv(recv_size)
|
||||||
if recv_size == 0:
|
recv_size -= len(data_buff)
|
||||||
break
|
buff_all += data_buff
|
||||||
print(len(buff_all))
|
if recv_size == 0:
|
||||||
raw_data = np.frombuffer(bytes(buff_all), dtype=np.uint8).reshape(int(n_rows), int(n_cols), -1)
|
break
|
||||||
print(raw_data.shape)
|
print(len(buff_all))
|
||||||
wood_color = detector.predict(raw_data)
|
raw_data = np.frombuffer(bytes(buff_all), dtype=np.uint8).reshape(int(n_rows), int(n_cols), -1)
|
||||||
# cv2.imshow("img", raw_data)
|
print(raw_data.shape)
|
||||||
# cv2.waitKey(30)
|
wood_color = detector.predict(raw_data)
|
||||||
# print('Class is ', wood_color)
|
# cv2.imshow("img", raw_data)
|
||||||
if wood_color == 0:
|
# cv2.waitKey(30)
|
||||||
socket_send.send(b'S')
|
# print('Class is ', wood_color)
|
||||||
print('S send success')
|
if wood_color == 0:
|
||||||
elif wood_color == 1:
|
socket_send.send(b'S')
|
||||||
socket_send.send(b'Z')
|
print('S send success')
|
||||||
print('Z send success')
|
elif wood_color == 1:
|
||||||
elif wood_color == 2:
|
socket_send.send(b'Z')
|
||||||
socket_send.send(b'Q')
|
print('Z send success')
|
||||||
print('Q send success')
|
elif wood_color == 2:
|
||||||
print((time.time()-t1))
|
socket_send.send(b'Q')
|
||||||
|
print('Q send success')
|
||||||
|
print((time.time()-t1))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|||||||