scaleFactor=1.2, minNeighbors=3, minSize=(10, 10)) #facerect = cascade.detectMultiScale(frame_gray, scaleFactor=1.01, minNeighbors=3, minSize=(3, 3)) if len(facerect) > 0: print('face detected') color = (255, 255, 255) # 白 for rect in facerect: # 検出した顔を囲む矩形の作成 #cv2.rectangle(frame, tuple(rect[0:2]), tuple(rect[0:2] + rect[2:4]), color, thickness=2) x, y = rect[0:2] width, height = rect[2:4] image = frame[y - 10:y + height, x:x + width] result = model.predict(image) if result == 0: # boss print('Boss is approaching') show_image() else: print('Not boss') #10msecキー入力待ち k = cv2.waitKey(100) #Escキーを押されたら終了 if k == 27: break #キャプチャを終了 cap.release() cv2.destroyAllWindows()
# 物体認識(顔認識)の実行 facerect = cascade.detectMultiScale(frame_gray, scaleFactor=1.2, minNeighbors=3, minSize=(10, 10)) #facerect = cascade.detectMultiScale(frame_gray, scaleFactor=1.01, minNeighbors=3, minSize=(3, 3)) if len(facerect) > 0: print('face detected') color = (255, 255, 255) # 白 for rect in facerect: # 検出した顔を囲む矩形の作成 #cv2.rectangle(frame, tuple(rect[0:2]), tuple(rect[0:2] + rect[2:4]), color, thickness=2) x, y = rect[0:2] width, height = rect[2:4] image = frame[y - 10: y + height, x: x + width] result = model.predict(image) if result == 0: # boss print('Boss is approaching') show_image() else: print('Not boss') #10msecキー入力待ち k = cv2.waitKey(100) #Escキーを押されたら終了 if k == 27: break #キャプチャを終了 cap.release() cv2.destroyAllWindows()