이재빈

모듈수정

1 import socket 1 import socket
2 import cv2 2 import cv2
3 import numpy as np 3 import numpy as np
4 -from multiprocessing import Queue 4 +#from queue import Queue
5 -from queue import Queue
6 from _thread import * 5 from _thread import *
7 -from labeling_module import LabelingModule as lm 6 +from multiprocessing import Queue
7 +from labeling_module import LabelingModule
8 +
8 enclose_q = Queue() 9 enclose_q = Queue()
10 +lm = LabelingModule()
9 #socket에서 수신한 버퍼를 반환 11 #socket에서 수신한 버퍼를 반환
10 def recvall(sock, count): 12 def recvall(sock, count):
11 # 바이트 문자열 13 # 바이트 문자열
...@@ -33,7 +35,8 @@ def send_threaded(Client_socket, addr, queue): ...@@ -33,7 +35,8 @@ def send_threaded(Client_socket, addr, queue):
33 35
34 if __name__ == "__main__": 36 if __name__ == "__main__":
35 lm.predict_process.start() 37 lm.predict_process.start()
36 - RECV_HOST='127.0.0.1' 38 +
39 + RECV_HOST='192.168.35.227'
37 RECV_PORT=9999 #RECV PORT 40 RECV_PORT=9999 #RECV PORT
38 41
39 #TCP 사용 42 #TCP 사용
...@@ -50,7 +53,7 @@ if __name__ == "__main__": ...@@ -50,7 +53,7 @@ if __name__ == "__main__":
50 #연결, conn 소켓 객체, addr socket binded addr 53 #연결, conn 소켓 객체, addr socket binded addr
51 conn,addr=s.accept() 54 conn,addr=s.accept()
52 55
53 - SEND_HOST = '127.0.0.1' 56 + SEND_HOST = '192.168.35.87'
54 SEND_PORT = 9998 #SEND PORT 57 SEND_PORT = 9998 #SEND PORT
55 58
56 server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 59 server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
......
1 + # -*- coding: euc-kr -*-
1 import socket 2 import socket
2 import cv2 3 import cv2
3 import numpy as np 4 import numpy as np
...@@ -5,9 +6,7 @@ from queue import Queue ...@@ -5,9 +6,7 @@ from queue import Queue
5 from _thread import * 6 from _thread import *
6 enclose_q = Queue() 7 enclose_q = Queue()
7 recv_enclose_q = Queue() 8 recv_enclose_q = Queue()
8 -import time
9 def filter_img(img): 9 def filter_img(img):
10 - #이미지의 RGB값을 분석하여 찾는 실내 Tag가 맞는지 판별
11 img = cv2.resize(img, (10,10)) 10 img = cv2.resize(img, (10,10))
12 first = [0,0,0] 11 first = [0,0,0]
13 for x_loc in range(0, 10): 12 for x_loc in range(0, 10):
...@@ -27,7 +26,6 @@ def filter_img(img): ...@@ -27,7 +26,6 @@ def filter_img(img):
27 return False 26 return False
28 27
29 def bboxes(inp): 28 def bboxes(inp):
30 - #Frame을 인자로 전달받음
31 img = inp 29 img = inp
32 start = time.time() 30 start = time.time()
33 curTime = time.time() 31 curTime = time.time()
...@@ -38,7 +36,7 @@ def bboxes(inp): ...@@ -38,7 +36,7 @@ def bboxes(inp):
38 ret, new_img = cv2.threshold(img_final, 180, 255, cv2.THRESH_BINARY) # Nfor black text , cv.THRESH_BINARY_IV 36 ret, new_img = cv2.threshold(img_final, 180, 255, cv2.THRESH_BINARY) # Nfor black text , cv.THRESH_BINARY_IV
39 newimg = cv2.cvtColor(new_img, cv2.COLOR_BGR2GRAY) #Gray Image converting 37 newimg = cv2.cvtColor(new_img, cv2.COLOR_BGR2GRAY) #Gray Image converting
40 _,contours, _ = cv2.findContours(newimg, cv2.RETR_CCOMP, cv2.CHAIN_APPROX_NONE) # get contours 38 _,contours, _ = cv2.findContours(newimg, cv2.RETR_CCOMP, cv2.CHAIN_APPROX_NONE) # get contours
41 - #cv2.CHAIN_APPROX_NONE: 모든 컨투어 포인트를 반환 39 + #cv2.CHAIN_APPROX_NONE: All of contour point
42 for contour in contours: 40 for contour in contours:
43 [x, y, w, h] = cv2.boundingRect(contour) 41 [x, y, w, h] = cv2.boundingRect(contour)
44 42
...@@ -89,7 +87,7 @@ def webcam(queue): ...@@ -89,7 +87,7 @@ def webcam(queue):
89 if key == 27: 87 if key == 27:
90 break 88 break
91 def recvall(sock, count): 89 def recvall(sock, count):
92 - # 바이트 문자열 90 + # byte string
93 buf = b'' 91 buf = b''
94 while count: 92 while count:
95 newbuf = sock.recv(count) 93 newbuf = sock.recv(count)
...@@ -99,7 +97,7 @@ def recvall(sock, count): ...@@ -99,7 +97,7 @@ def recvall(sock, count):
99 return buf 97 return buf
100 98
101 if __name__ == '__main__': 99 if __name__ == '__main__':
102 - SEND_HOST = '127.0.0.1' #CORE CLOUD 100 + SEND_HOST = '192.168.35.87' #CORE CLOUD
103 SEND_PORT = 9999 101 SEND_PORT = 9999
104 102
105 server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 103 server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
...@@ -107,7 +105,7 @@ if __name__ == '__main__': ...@@ -107,7 +105,7 @@ if __name__ == '__main__':
107 server_socket.bind((SEND_HOST, SEND_PORT)) 105 server_socket.bind((SEND_HOST, SEND_PORT))
108 server_socket.listen() 106 server_socket.listen()
109 107
110 - RECV_HOST = '127.0.0.1' #CORE CLOUD 108 + RECV_HOST = '192.168.35.227' #CORE CLOUD
111 RECV_PORT = 9998 109 RECV_PORT = 9998
112 110
113 recv_server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 111 recv_server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
...@@ -122,13 +120,13 @@ if __name__ == '__main__': ...@@ -122,13 +120,13 @@ if __name__ == '__main__':
122 print('wait') 120 print('wait')
123 121
124 client_socket, addr = server_socket.accept() 122 client_socket, addr = server_socket.accept()
125 - start_new_thread(send_threaded, (client_socket, addr, enclose_q,)) #전처리 데이터 송신 123 + start_new_thread(send_threaded, (client_socket, addr, enclose_q,)) #preprocessed data recieve.
126 - conn,addr = recv_server_socket.accept() #수신 대기 124 + conn,addr = recv_server_socket.accept() #waiting receiving...
127 if(conn): 125 if(conn):
128 length = recvall(conn, 16) 126 length = recvall(conn, 16)
129 stringData = recvall(conn, int(length)) 127 stringData = recvall(conn, int(length))
130 - data = np.fromstring(stringData, dtype = 'uint8') #주행정보 수신 128 + data = np.fromstring(stringData, dtype = 'uint8') #receive driving info.
131 - if(conn): #연결 끊어질 경우 loop 탈출 129 + if(conn): #loop ex
132 break 130 break
133 else: 131 else:
134 pass 132 pass
......