Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Face detection wrapper using hybrid margin-based region of interest (MROI) approach."
You can install the hybrid MROI face detection wrapper using pip
:
pip install mroi-fd
This project is developed and tested on python version 3.7.4
. Please check
your python version using python --version
. If your system has a different
python version, you may want to consider using
pyenv (See Using pyenv)
First, clone and cd
into the repository:
git clone https://gitlab.com/ailabuser/bacha_hybrid_mroi_face_detection
cd bacha_hybrid_mroi_face_detection
Create a python virtual environment:
mkvirtualenv venv
Activate the virtual environment (deactivate
to deactivate the virtual
environment):
workon venv
Install all the required dependencies while still having the virtual environment active:
pip install -r requirements.txt
Create a python virtual environment:
virtualenv -p /usr/bin/python3 venv
Activate the virtual environment (deactivate
to deactivate the virtual
environment):
source venv/bin/activate
Install all the required dependencies while still having the virtual environment active:
pip install -r requirements.txt
If your python version is not 3.7.4, you may want to use
pyenv. After you have installed pyenv
,
install the specific python version. On Linux, this can be done by running the
following command:
env PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install 3.7.4
Then, create a virtual environment:
pyenv virtualenv 3.7.4 bacha_mroi_face_detection
You can activate the virtual environment using pyenv
like so:
pyenv activate bacha_mroi_face_detection
The face detection technique used hybrid margin-based region of interest (MROI) approach. It is hybrid in the sense that the implementation runs one main routine to detect a face, but switch to an escape routine when the main routine fails. Using MROI increase the face detection speed by having the selected face detection algorithm to only consider a sub-region (where a face was previously detected) instead of the full frame.
There are three pre-defined selection of main routines available for you to use:
When the main routine failed to detect a face, the implementation switch to the escape routine which runs template matching algorithm.
In order to use your face detection algorithm with the hybrid MROI face
detector, you need to create a subclass which inherit the FaceDetector
class,
and override its detect
method. The implementation requires thedetect
method to return either a face ROI or None
; otherwise, the hybrid MROI face
detector may fail.
Here's an example, in which we use a python implementation of MTCNN:
import cv2
from mtcnn.mtcnn import MTCNN
from mroi_fd import FaceDetector
class MROI_MTCNN(FaceDetector):
def __init__(self):
# The main routine face detector object used to detect faces.
fd_obj = MTCNN()
# Initialize using base class constructor. We pass the face detector
# object (fd_obj) and use the MROI with fixed-margin approach with
# a template matching escape routine.
super().__init__(fd_obj, mode=FaceDetector.FMTM)
@staticmethod
def detect(fd_obj, image):
rgb_src = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
result = fd_obj.detect_faces(rgb_src)
if len(result) > 0:
return result[0]['box']
else:
return None
Internally, this was basically how the pre-defined hyrbid MROI face detectors
(i.e., MROI_HaarCascade
and MROI_MTCNN
) was defined. Simply import them with
from mroi_fd import MROI_HaarCascade, MROI_MTCNN
To use the face detector, simply instantiate the hybrid MROI face detector and
run it by invoking its run
method. Below is a simple script that runs the
face detector and feed it images in a loop.
fd = MROI_MTCNN()
fd.run() # This runs the face detector in the background.
cap = cv2.VideoCapture("/path/to/video/file")
while True:
ret, frame = cap.read()
# No more images; exit.
if not ret:
break
# Feed the image into the face detector.
fd.input_image(frame)
# Get the ROI containing the face. This will be `None` if no face is
# detected.
ROI = fd.get_face_region()
if ROI is not None:
x, y, w, h = ROI
cv2.rectangle(frame, (x, y), (x+w, y+h), (0, 255, 0), 2)
cv2.imshow("MROI_MTCNN Face Detector", frame)
if cv2.waitKey(1) == ord('q'):
break
fd.clean()
cap.release()
cv2.destroyAllWindows()
FAQs
Face detection wrapper using hybrid margin-based region of interest (MROI) approach."
We found that mroi-fd demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.