Skip to content

Commit

Permalink
python 2 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
vikasgupta-github committed Oct 19, 2018
1 parent 01498fa commit 943470b
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions FaceDetectionComparison/face_detection_dlib_hog.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

from __future__ import division
import cv2
import dlib
import time
Expand All @@ -25,7 +25,7 @@ def detectFaceDlibHog(detector, frame, inHeight=300, inWidth=0):
cvRect = [int(faceRect.left()*scaleWidth), int(faceRect.top()*scaleHeight),
int(faceRect.right()*scaleWidth), int(faceRect.bottom()*scaleHeight) ]
bboxes.append(cvRect)
cv2.rectangle(frameDlibHog, (cvRect[0], cvRect[1]), (cvRect[2], cvRect[3]), (0, 255, 0), round(frameHeight/150), 4)
cv2.rectangle(frameDlibHog, (cvRect[0], cvRect[1]), (cvRect[2], cvRect[3]), (0, 255, 0), int(round(frameHeight/150)), 4)
return frameDlibHog, bboxes

if __name__ == "__main__" :
Expand Down
4 changes: 2 additions & 2 deletions FaceDetectionComparison/face_detection_dlib_mmod.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

from __future__ import division
import cv2
import dlib
import time
Expand All @@ -25,7 +25,7 @@ def detectFaceDlibMMOD(detector, frame, inHeight=300, inWidth=0):
cvRect = [int(faceRect.rect.left()*scaleWidth), int(faceRect.rect.top()*scaleHeight),
int(faceRect.rect.right()*scaleWidth), int(faceRect.rect.bottom()*scaleHeight) ]
bboxes.append(cvRect)
cv2.rectangle(frameDlibMMOD, (cvRect[0], cvRect[1]), (cvRect[2], cvRect[3]), (0, 255, 0), round(frameHeight/150), 4)
cv2.rectangle(frameDlibMMOD, (cvRect[0], cvRect[1]), (cvRect[2], cvRect[3]), (0, 255, 0), int(round(frameHeight/150)), 4)
return frameDlibMMOD, bboxes

if __name__ == "__main__" :
Expand Down
4 changes: 2 additions & 2 deletions FaceDetectionComparison/face_detection_opencv_dnn.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

from __future__ import division
import cv2
import time
import sys
Expand All @@ -20,7 +20,7 @@ def detectFaceOpenCVDnn(net, frame):
x2 = int(detections[0, 0, i, 5] * frameWidth)
y2 = int(detections[0, 0, i, 6] * frameHeight)
bboxes.append([x1, y1, x2, y2])
cv2.rectangle(frameOpencvDnn, (x1, y1), (x2, y2), (0, 255, 0), round(frameHeight/150), 8)
cv2.rectangle(frameOpencvDnn, (x1, y1), (x2, y2), (0, 255, 0), int(round(frameHeight/150)), 8)
return frameOpencvDnn, bboxes

if __name__ == "__main__" :
Expand Down
4 changes: 2 additions & 2 deletions FaceDetectionComparison/face_detection_opencv_haar.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

from __future__ import division
import cv2
import time
import sys
Expand Down Expand Up @@ -27,7 +27,7 @@ def detectFaceOpenCVHaar(faceCascade, frame, inHeight=300, inWidth=0):
int(x2 * scaleWidth), int(y2 * scaleHeight)]
bboxes.append(cvRect)
cv2.rectangle(frameOpenCVHaar, (cvRect[0], cvRect[1]), (cvRect[2], cvRect[3]), (0, 255, 0),
round(frameHeight / 150), 4)
int(round(frameHeight / 150)), 4)
return frameOpenCVHaar, bboxes

if __name__ == "__main__" :
Expand Down
10 changes: 5 additions & 5 deletions FaceDetectionComparison/run-all.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

from __future__ import division
import cv2
import dlib
import time
Expand Down Expand Up @@ -55,7 +55,7 @@ def detectFaceOpenCVHaar(faceCascade, frame, inHeight=300, inWidth=0):
int(x2 * scaleWidth), int(y2 * scaleHeight)]
bboxes.append(cvRect)
cv2.rectangle(frameOpenCVHaar, (cvRect[0], cvRect[1]), (cvRect[2], cvRect[3]), (0, 255, 0),
round(frameHeight / 150), 4)
int(round(frameHeight / 150)), 4)
return frameOpenCVHaar, bboxes


Expand All @@ -77,7 +77,7 @@ def detectFaceOpenCVDnn(net, frame):
x2 = int(detections[0, 0, i, 5] * frameWidth)
y2 = int(detections[0, 0, i, 6] * frameHeight)
bboxes.append([x1, y1, x2, y2])
cv2.rectangle(frameOpencvDnn, (x1, y1), (x2, y2), (0, 255, 0), round(frameHeight/150), 8)
cv2.rectangle(frameOpencvDnn, (x1, y1), (x2, y2), (0, 255, 0), int(round(frameHeight/150)), 8)
return frameOpencvDnn, bboxes


Expand All @@ -102,7 +102,7 @@ def detectFaceDlibHog(detector, frame, inHeight=300, inWidth=0):
cvRect = [int(faceRect.left()*scaleWidth), int(faceRect.top()*scaleHeight),
int(faceRect.right()*scaleWidth), int(faceRect.bottom()*scaleHeight) ]
bboxes.append(cvRect)
cv2.rectangle(frameDlibHog, (cvRect[0], cvRect[1]), (cvRect[2], cvRect[3]), (0, 255, 0), round(frameHeight/150), 4)
cv2.rectangle(frameDlibHog, (cvRect[0], cvRect[1]), (cvRect[2], cvRect[3]), (0, 255, 0), int(round(frameHeight/150)), 4)
return frameDlibHog, bboxes


Expand All @@ -127,7 +127,7 @@ def detectFaceDlibMMOD(detector, frame, inHeight=300, inWidth=0):
cvRect = [int(faceRect.rect.left()*scaleWidth), int(faceRect.rect.top()*scaleHeight),
int(faceRect.rect.right()*scaleWidth), int(faceRect.rect.bottom()*scaleHeight) ]
bboxes.append(cvRect)
cv2.rectangle(frameDlibMMOD, (cvRect[0], cvRect[1]), (cvRect[2], cvRect[3]), (0, 255, 0), round(frameHeight/150), 4)
cv2.rectangle(frameDlibMMOD, (cvRect[0], cvRect[1]), (cvRect[2], cvRect[3]), (0, 255, 0), int(round(frameHeight/150)), 4)
return frameDlibMMOD, bboxes


Expand Down

0 comments on commit 943470b

Please sign in to comment.