diff --git a/FaceDetectionComparison/face_detection_dlib_hog.py b/FaceDetectionComparison/face_detection_dlib_hog.py index f26559be3..71639ecb0 100644 --- a/FaceDetectionComparison/face_detection_dlib_hog.py +++ b/FaceDetectionComparison/face_detection_dlib_hog.py @@ -11,12 +11,13 @@ def detectFaceDlibHog(detector, frame, inHeight=300, inWidth=0): frameWidth = frameDlibHog.shape[1] if not inWidth: inWidth = int((frameWidth / frameHeight)*inHeight) - + scaleHeight = frameHeight / inHeight scaleWidth = frameWidth / inWidth - + frameDlibHogSmall = cv2.resize(frameDlibHog, (inWidth, inHeight)) + frameDlibHogSmall = cv2.cvtColor(frameDlibHogSmall, cv2.COLOR_BGR2RGB) faceRects = detector(frameDlibHogSmall, 0) print(frameWidth, frameHeight, inWidth, inHeight) bboxes = [] @@ -61,10 +62,9 @@ def detectFaceDlibHog(detector, frame, inHeight=300, inWidth=0): vid_writer.write(outDlibHog) if frame_count == 1: tt_dlibHog = 0 - + k = cv2.waitKey(10) if k == 27: break cv2.destroyAllWindows() vid_writer.release() - diff --git a/FaceDetectionComparison/face_detection_dlib_mmod.py b/FaceDetectionComparison/face_detection_dlib_mmod.py index 916940600..f652cb074 100644 --- a/FaceDetectionComparison/face_detection_dlib_mmod.py +++ b/FaceDetectionComparison/face_detection_dlib_mmod.py @@ -11,14 +11,15 @@ def detectFaceDlibMMOD(detector, frame, inHeight=300, inWidth=0): frameWidth = frameDlibMMOD.shape[1] if not inWidth: inWidth = int((frameWidth / frameHeight)*inHeight) - + scaleHeight = frameHeight / inHeight scaleWidth = frameWidth / inWidth - + frameDlibMMODSmall = cv2.resize(frameDlibMMOD, (inWidth, inHeight)) + frameDlibMMODSmall = cv2.cvtColor(frameDlibMMODSmall, cv2.COLOR_BGR2RGB) faceRects = detector(frameDlibMMODSmall, 0) - + print(frameWidth, frameHeight, inWidth, inHeight) bboxes = [] for faceRect in faceRects: @@ -68,4 +69,3 @@ def detectFaceDlibMMOD(detector, frame, inHeight=300, inWidth=0): break cv2.destroyAllWindows() vid_writer.release() - diff --git a/FaceDetectionComparison/run-all.py b/FaceDetectionComparison/run-all.py index a4a36d96f..08fd61d66 100644 --- a/FaceDetectionComparison/run-all.py +++ b/FaceDetectionComparison/run-all.py @@ -88,12 +88,13 @@ def detectFaceDlibHog(detector, frame, inHeight=300, inWidth=0): frameWidth = frameDlibHog.shape[1] if not inWidth: inWidth = int((frameWidth / frameHeight)*inHeight) - + scaleHeight = frameHeight / inHeight scaleWidth = frameWidth / inWidth - + frameDlibHogSmall = cv2.resize(frameDlibHog, (inWidth, inHeight)) + frameDlibHogSmall = cv2.cvtColor(frameDlibHogSmall, cv2.COLOR_BGR2RGB) faceRects = detector(frameDlibHogSmall, 0) print(frameWidth, frameHeight, inWidth, inHeight) bboxes = [] @@ -113,14 +114,15 @@ def detectFaceDlibMMOD(detector, frame, inHeight=300, inWidth=0): frameWidth = frameDlibMMOD.shape[1] if not inWidth: inWidth = int((frameWidth / frameHeight)*inHeight) - + scaleHeight = frameHeight / inHeight scaleWidth = frameWidth / inWidth - + frameDlibMMODSmall = cv2.resize(frameDlibMMOD, (inWidth, inHeight)) + frameDlibMMODSmall = cv2.cvtColor(frameDlibMMODSmall, cv2.COLOR_BGR2RGB) faceRects = detector(frameDlibMMODSmall, 0) - + print(frameWidth, frameHeight, inWidth, inHeight) bboxes = [] for faceRect in faceRects: @@ -200,4 +202,3 @@ def detectFaceDlibMMOD(detector, frame, inHeight=300, inWidth=0): break cv2.destroyAllWindows() vid_writer.release() - diff --git a/HandPose/handPoseImage.py b/HandPose/handPoseImage.py index 5e09b8fe8..d9bf2f29b 100644 --- a/HandPose/handPoseImage.py +++ b/HandPose/handPoseImage.py @@ -12,7 +12,7 @@ frameCopy = np.copy(frame) frameWidth = frame.shape[1] frameHeight = frame.shape[0] -aspect_ratio = frameWidth/frameHeight +aspect_ratio = float(frameWidth)/frameHeight threshold = 0.1 @@ -20,9 +20,7 @@ # input image dimensions for the network inHeight = 368 inWidth = int(((aspect_ratio*inHeight)*8)//8) - -inpBlob = cv2.dnn.blobFromImage(frame, 1.0 / 255, (inWidth, inHeight), - (0, 0, 0), swapRB=False, crop=False) +inpBlob = cv2.dnn.blobFromImage(frame, 1.0 / 255, (inHeight, inWidth), (0, 0, 0), swapRB=False, crop=False) net.setInput(inpBlob)