use ai
This commit is contained in:
@@ -120,7 +120,7 @@ class FaceDetect:
|
||||
|
||||
remotepath = self.ftp_info.location + os.sep + self.ftp_info.file_face + '.jpg'
|
||||
|
||||
#sftp.put(AI_CONST.FTP_FR_RESULT, remotepath)
|
||||
sftp.put(AI_CONST.FTP_FR_RESULT, remotepath)
|
||||
|
||||
sftp.close()
|
||||
transprot.close()
|
||||
@@ -155,6 +155,7 @@ class FaceDetect:
|
||||
|
||||
def _result_update(self, matched_list: list):
|
||||
"""
|
||||
|
||||
:param matched_list: detect 된 object list
|
||||
"""
|
||||
self.mqtt_status = self.thread_value.STATUS_NONE # status init
|
||||
@@ -330,8 +331,14 @@ class FaceDetect:
|
||||
'encoding' : face_recognition.face_encodings(worker22_image)[0]
|
||||
}
|
||||
|
||||
worker100_image = face_recognition.load_image_file(AI_CONST.WORKER100_IMG_PATH)
|
||||
no000100 = {
|
||||
'target_names' : 'no000100',
|
||||
'encoding' : face_recognition.face_encodings(worker100_image)[0]
|
||||
}
|
||||
|
||||
encoding_list = [
|
||||
#no000001,no000002,no000003 # kepco 1
|
||||
# no000001,no000002,no000003, # test 1
|
||||
# ,
|
||||
no000004 # jangys
|
||||
,no000005 # whangsj
|
||||
@@ -343,7 +350,7 @@ class FaceDetect:
|
||||
# ,no000010,no000011,no000012,no000015,no000018 #Helmet on kepco2
|
||||
,no000019,no000020 #Helmet off kepco 2
|
||||
,no000021 #,no000022
|
||||
|
||||
,no000100 # test
|
||||
]
|
||||
result = []
|
||||
|
||||
@@ -352,7 +359,7 @@ class FaceDetect:
|
||||
result.append(i["encoding"])
|
||||
|
||||
names = [
|
||||
#'no000001','no000002','no000003'# kepco 1
|
||||
# 'no000001','no000002','no000003',# test 1
|
||||
# ,
|
||||
'no000004' # jangys
|
||||
,'no000005' # whangsj
|
||||
@@ -364,6 +371,7 @@ class FaceDetect:
|
||||
# ,'no000010','no000011','no000012','no000015','no000018' #Helmet on kepco2
|
||||
,'no000019','no000020' #Helmet off kepco 2
|
||||
,'no000021' #,no000022
|
||||
# ,'no000100' #test
|
||||
]
|
||||
return result , names
|
||||
|
||||
@@ -411,70 +419,62 @@ class FaceDetect:
|
||||
# face_encodings = []
|
||||
|
||||
# while self.mqtt_status != self.thread_value.STATUS_COMPLETE and self.stop_sign != True:
|
||||
# while True:
|
||||
while True:
|
||||
|
||||
# # TODO(JWKIM):ageing test 23-02-28
|
||||
# # self._mqtt_publish(status="AGEING_TEST")
|
||||
# TODO(JWKIM):ageing test 23-02-28
|
||||
# self._mqtt_publish(status="AGEING_TEST")
|
||||
|
||||
# # loop stop
|
||||
# if self.stop_event.is_set():
|
||||
# if self.mqtt_status == self.thread_value.STATUS_COMPLETE:
|
||||
# pass
|
||||
# else:
|
||||
# self.thread_value.current_status = self.thread_value.STATUS_STOP
|
||||
# # TODO(JWKIM):ageing test 23-02-28
|
||||
# break
|
||||
# elif self.thread_value.timeout_status:
|
||||
# self.thread_value.current_status = self.thread_value.STATUS_TIMEOUT
|
||||
# # TODO(JWKIM):ageing test 23-02-28
|
||||
# break
|
||||
# loop stop
|
||||
if self.stop_event.is_set():
|
||||
if self.mqtt_status == self.thread_value.STATUS_COMPLETE:
|
||||
pass
|
||||
else:
|
||||
self.thread_value.current_status = self.thread_value.STATUS_STOP
|
||||
# TODO(JWKIM):ageing test 23-02-28
|
||||
break
|
||||
elif self.thread_value.timeout_status:
|
||||
self.thread_value.current_status = self.thread_value.STATUS_TIMEOUT
|
||||
# TODO(JWKIM):ageing test 23-02-28
|
||||
break
|
||||
|
||||
# Grab a single frame of video
|
||||
ret, frame = input_movie.read()
|
||||
|
||||
cv2.imwrite(AI_CONST.FTP_FR_RESULT,frame)
|
||||
self._sftp_upload()
|
||||
self.result = ["no000010"]
|
||||
ret, frame = input_movie.read()
|
||||
|
||||
self._mqtt_publish(status = self.thread_value.STATUS_COMPLETE)
|
||||
|
||||
# Quit when the input video file ends
|
||||
# 영상파일일 경우 다시 재생
|
||||
# if not ret and os.path.isfile(self.input_video):
|
||||
# input_movie = cv2.VideoCapture(self.input_video)
|
||||
# continue
|
||||
if not ret and os.path.isfile(self.input_video):
|
||||
input_movie = cv2.VideoCapture(self.input_video)
|
||||
continue
|
||||
|
||||
# frame_count = int(input_movie.get(cv2.CV_CAP_PROP_FPS))
|
||||
|
||||
# Convert the image from BGR color (which OpenCV uses) to RGB color (which face_recognition uses)
|
||||
# rgb_frame = frame[:, :, ::-1]
|
||||
rgb_frame = frame[:, :, ::-1]
|
||||
|
||||
# face_locations = face_recognition.face_locations(rgb_frame)
|
||||
# face_encodings = face_recognition.face_encodings(rgb_frame, face_locations)
|
||||
# for face_encoding in face_encodings:
|
||||
face_locations = face_recognition.face_locations(rgb_frame)
|
||||
face_encodings = face_recognition.face_encodings(rgb_frame, face_locations)
|
||||
for face_encoding in face_encodings:
|
||||
|
||||
# matched_name = [] # detect 완료된 명단
|
||||
matched_name = [] # detect 완료된 명단
|
||||
|
||||
# match = face_recognition.compare_faces(known_faces, face_encoding, tolerance=AI_CONST.FACE_EVOLUTION_DISTANCE)
|
||||
match = face_recognition.compare_faces(known_faces, face_encoding, tolerance=AI_CONST.FACE_EVOLUTION_DISTANCE)
|
||||
|
||||
# #TODO(jwkim): 입력 이미지 변경
|
||||
# if self.fr_manager.fr_id_info != self.id_info:
|
||||
# raise Exception(AI_CONST.IMG_CHANGED_MSG)
|
||||
#TODO(jwkim): 입력 이미지 변경
|
||||
if self.fr_manager.fr_id_info != self.id_info:
|
||||
raise Exception(AI_CONST.IMG_CHANGED_MSG)
|
||||
|
||||
# face_distances = face_recognition.face_distance(known_faces, face_encoding)
|
||||
# best_match_index = np.argmin(face_distances)
|
||||
face_distances = face_recognition.face_distance(known_faces, face_encoding)
|
||||
best_match_index = np.argmin(face_distances)
|
||||
|
||||
# if face_distances[best_match_index] < AI_CONST.FACE_EVOLUTION_DISTANCE :
|
||||
# #demo
|
||||
# print(match)
|
||||
# if match[best_match_index]:
|
||||
if face_distances[best_match_index] < AI_CONST.FACE_EVOLUTION_DISTANCE :
|
||||
#demo
|
||||
if match[best_match_index]:
|
||||
|
||||
# # self.result[0] = known_names[best_match_index]
|
||||
# self.result[0] = "no000010"
|
||||
# self.mqtt_status = self.thread_value.STATUS_COMPLETE
|
||||
# print(known_names[best_match_index])
|
||||
# self.stop_event.set()
|
||||
# break
|
||||
self.result[0] = "no000010"
|
||||
print(known_names[best_match_index])
|
||||
self.mqtt_status = self.thread_value.STATUS_COMPLETE
|
||||
self.stop_event.set()
|
||||
break
|
||||
|
||||
# if match[best_match_index]:
|
||||
# matched_name.append(self.worker_names[best_match_index])
|
||||
@@ -486,52 +486,47 @@ class FaceDetect:
|
||||
# ri
|
||||
# self._ai_rbi(matched_name)
|
||||
|
||||
# if self.mqtt_status == self.thread_value.STATUS_NEW:
|
||||
# self._mqtt_publish(self.thread_value.STATUS_NEW)
|
||||
if self.mqtt_status == self.thread_value.STATUS_NEW:
|
||||
self._mqtt_publish(self.thread_value.STATUS_NEW)
|
||||
|
||||
# # input source check
|
||||
# self._source_check()
|
||||
# input source check
|
||||
self._source_check()
|
||||
|
||||
# # loop stop
|
||||
# if self.stop_event.is_set():
|
||||
# if self.mqtt_status == self.thread_value.STATUS_COMPLETE:
|
||||
# self.result_frame = copy.deepcopy(frame)
|
||||
# else:
|
||||
# self.thread_value.current_status = self.thread_value.STATUS_STOP
|
||||
# # TODO(JWKIM):ageing test 23-02-28
|
||||
# break
|
||||
# elif self.thread_value.timeout_status:
|
||||
# self.thread_value.current_status = self.thread_value.STATUS_TIMEOUT
|
||||
# # TODO(JWKIM):ageing test 23-02-28
|
||||
# break
|
||||
# loop stop
|
||||
if self.stop_event.is_set():
|
||||
|
||||
# if self.thread_value.timeout_status:
|
||||
# self._mqtt_publish(self.thread_value.STATUS_TIMEOUT)
|
||||
# self.thread_value.timeout_status = False
|
||||
if self.mqtt_status == self.thread_value.STATUS_COMPLETE:
|
||||
self.result_frame = copy.deepcopy(frame)
|
||||
else:
|
||||
self.thread_value.current_status = self.thread_value.STATUS_STOP
|
||||
# TODO(JWKIM):ageing test 23-02-28
|
||||
break
|
||||
elif self.thread_value.timeout_status:
|
||||
self.thread_value.current_status = self.thread_value.STATUS_TIMEOUT
|
||||
# TODO(JWKIM):ageing test 23-02-28
|
||||
break
|
||||
|
||||
# elif self.stop_event.is_set():
|
||||
# if self.mqtt_status == self.thread_value.STATUS_COMPLETE:
|
||||
# #sftp
|
||||
|
||||
# cv2.imwrite(AI_CONST.FTP_FR_RESULT,self.result_frame)
|
||||
|
||||
# if project_config.SFTP_UPLOAD and project_config.FR_UPLOAD:
|
||||
# self.snapshot_path = self._sftp_upload()
|
||||
# else:
|
||||
# self.snapshot_path = None
|
||||
|
||||
# self._mqtt_publish(self.thread_value.STATUS_COMPLETE)
|
||||
# else:
|
||||
# self._mqtt_publish(self.thread_value.STATUS_STOP)
|
||||
if self.thread_value.timeout_status:
|
||||
self._mqtt_publish(self.thread_value.STATUS_TIMEOUT)
|
||||
self.thread_value.timeout_status = False
|
||||
|
||||
# if not self.timeout_event.is_set():
|
||||
# self.timeout_event.set()
|
||||
elif self.stop_event.is_set():
|
||||
if self.mqtt_status == self.thread_value.STATUS_COMPLETE:
|
||||
#sftp
|
||||
cv2.imwrite(AI_CONST.FTP_FR_RESULT,self.result_frame)
|
||||
self.snapshot_path = self._sftp_upload()
|
||||
self._mqtt_publish(self.thread_value.STATUS_COMPLETE)
|
||||
else:
|
||||
self._mqtt_publish(self.thread_value.STATUS_STOP)
|
||||
|
||||
# self.timeout_event.clear()
|
||||
if not self.timeout_event.is_set():
|
||||
self.timeout_event.set()
|
||||
|
||||
self.timeout_event.clear()
|
||||
|
||||
# if self.mqtt_status == self.thread_value.STATUS_COMPLETE:
|
||||
if self.mqtt_status == self.thread_value.STATUS_COMPLETE:
|
||||
|
||||
# pass
|
||||
pass
|
||||
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
Reference in New Issue
Block a user