Showing
5 changed files
with
14 additions
and
16 deletions
... | @@ -44,7 +44,7 @@ class Client(tk.Frame): | ... | @@ -44,7 +44,7 @@ class Client(tk.Frame): |
44 | self.image_size = (image_size, image_size) | 44 | self.image_size = (image_size, image_size) |
45 | 45 | ||
46 | # cam에서 MTCNN 적용하는 영역 | 46 | # cam에서 MTCNN 적용하는 영역 |
47 | - self.detecting_square = (500, 300) | 47 | + self.detecting_square = (640, 480) |
48 | 48 | ||
49 | # 영상 위에 사각형 색상 지정 | 49 | # 영상 위에 사각형 색상 지정 |
50 | self.rectangle_color = (0, 0, 255) | 50 | self.rectangle_color = (0, 0, 255) |
... | @@ -100,7 +100,9 @@ class Client(tk.Frame): | ... | @@ -100,7 +100,9 @@ class Client(tk.Frame): |
100 | for (x, y, w, h) in faces: | 100 | for (x, y, w, h) in faces: |
101 | margin = int(self.margin / 2) | 101 | margin = int(self.margin / 2) |
102 | image = frame[y-margin:y+h+margin, x-margin:x+w+margin] | 102 | image = frame[y-margin:y+h+margin, x-margin:x+w+margin] |
103 | - return image, True | 103 | + # BGR to RGB |
104 | + converted = cv2.cvtColor(image, cv2.COLOR_BGR2RGB) | ||
105 | + return converted, True | ||
104 | return [], False | 106 | return [], False |
105 | 107 | ||
106 | def mainthread(self): | 108 | def mainthread(self): |
... | @@ -112,10 +114,8 @@ class Client(tk.Frame): | ... | @@ -112,10 +114,8 @@ class Client(tk.Frame): |
112 | y2 = int(self.cam_height / 2 + self.detecting_square[1] / 2) | 114 | y2 = int(self.cam_height / 2 + self.detecting_square[1] / 2) |
113 | while getattr(t, "do_run", True): | 115 | while getattr(t, "do_run", True): |
114 | ret, frame = self.cap.read() | 116 | ret, frame = self.cap.read() |
115 | - # BGR to RGB | ||
116 | - converted = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB) | ||
117 | # detect face | 117 | # detect face |
118 | - face, detected = self.detect_face(converted[y1:y2, x1:x2]) | 118 | + face, detected = self.detect_face(frame[y1:y2, x1:x2]) |
119 | if detected: | 119 | if detected: |
120 | self.event_loop.run_until_complete(self.send_face(face)) | 120 | self.event_loop.run_until_complete(self.send_face(face)) |
121 | # 사각형 영역 표시 | 121 | # 사각형 영역 표시 | ... | ... |
... | @@ -124,7 +124,9 @@ class Register(tk.Frame): | ... | @@ -124,7 +124,9 @@ class Register(tk.Frame): |
124 | for (x, y, w, h) in faces: | 124 | for (x, y, w, h) in faces: |
125 | margin = int(self.margin / 2) | 125 | margin = int(self.margin / 2) |
126 | image = frame[y-margin:y+h+margin, x-margin:x+w+margin] | 126 | image = frame[y-margin:y+h+margin, x-margin:x+w+margin] |
127 | - return image, True | 127 | + # BGR to RGB |
128 | + converted = cv2.cvtColor(image, cv2.COLOR_BGR2RGB) | ||
129 | + return converted, True | ||
128 | return [], False | 130 | return [], False |
129 | 131 | ||
130 | def mainthread(self): | 132 | def mainthread(self): |
... | @@ -136,12 +138,8 @@ class Register(tk.Frame): | ... | @@ -136,12 +138,8 @@ class Register(tk.Frame): |
136 | detected_time = None | 138 | detected_time = None |
137 | while getattr(t, "do_run", True): | 139 | while getattr(t, "do_run", True): |
138 | ret, frame = self.cap.read() | 140 | ret, frame = self.cap.read() |
139 | - | ||
140 | - # model에 이용하기 위해 convert | ||
141 | - converted = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB) | ||
142 | - | ||
143 | # 사각형 영역만 검사 | 141 | # 사각형 영역만 검사 |
144 | - face, detected = self.detect_face(converted[y1:y2, x1:x2]) | 142 | + face, detected = self.detect_face(frame[y1:y2, x1:x2]) |
145 | # 얼굴이 인식된 경우 파란색 사각형을 띄움 | 143 | # 얼굴이 인식된 경우 파란색 사각형을 띄움 |
146 | if detected: | 144 | if detected: |
147 | frame = cv2.rectangle(frame, (x1, y1), (x2, y2), (255, 0, 0), 3) | 145 | frame = cv2.rectangle(frame, (x1, y1), (x2, y2), (255, 0, 0), 3) | ... | ... |
-
Please register or login to post a comment