-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
33,425 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
remotecv/detectors/face_grayscale_equalized_detector/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
# thumbor imaging service | ||
# https://github.com/globocom/thumbor/wiki | ||
|
||
# Licensed under the MIT license: | ||
# http://www.opensource.org/licenses/mit-license | ||
# Copyright (c) 2022 globo.com <thumbor@g.globo> | ||
|
||
from remotecv.detectors import CascadeLoaderDetector | ||
|
||
HAIR_OFFSET = 0.12 | ||
|
||
|
||
class FaceGrayscaleEqualizedDetector(CascadeLoaderDetector): | ||
def __init__(self): | ||
self.load_cascade_file(__file__, "haarcascade_frontalface_default.xml") | ||
|
||
def __add_hair_offset(self, top, height): | ||
return max(0, top - height * HAIR_OFFSET) | ||
|
||
def detect(self, image): | ||
features = self.get_grayscale_equalized_features(image) | ||
points = [] | ||
if features: | ||
for (left, top, width, height), _neighbors in features: | ||
top = self.__add_hair_offset(top, height) | ||
points.append([left, top, width, height]) | ||
|
||
return points |
Oops, something went wrong.