Skip to content

Commit

Permalink
dlib needs rgb pixel
Browse files Browse the repository at this point in the history
  • Loading branch information
vikasgupta-github committed Oct 20, 2018
1 parent 943470b commit daaa99d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 18 deletions.
8 changes: 4 additions & 4 deletions FaceDetectionComparison/face_detection_dlib_hog.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down Expand Up @@ -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()

8 changes: 4 additions & 4 deletions FaceDetectionComparison/face_detection_dlib_mmod.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -68,4 +69,3 @@ def detectFaceDlibMMOD(detector, frame, inHeight=300, inWidth=0):
break
cv2.destroyAllWindows()
vid_writer.release()

13 changes: 7 additions & 6 deletions FaceDetectionComparison/run-all.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand All @@ -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:
Expand Down Expand Up @@ -200,4 +202,3 @@ def detectFaceDlibMMOD(detector, frame, inHeight=300, inWidth=0):
break
cv2.destroyAllWindows()
vid_writer.release()

6 changes: 2 additions & 4 deletions HandPose/handPoseImage.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,15 @@
frameCopy = np.copy(frame)
frameWidth = frame.shape[1]
frameHeight = frame.shape[0]
aspect_ratio = frameWidth/frameHeight
aspect_ratio = float(frameWidth)/frameHeight

threshold = 0.1

t = time.time()
# 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)

Expand Down

0 comments on commit daaa99d

Please sign in to comment.