1 Star 5 Fork 1

cubone/learnopencv

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
AgeGender
AlphaBlending
AugmentedRealityWithArucoMarkers
Autoencoder-in-TensorFlow
Background-Subtraction
Bag-Of-Tricks-For-Image-Classification
BatchNormalization
BlobDetector
CI
CameraCalibration
CenterofBlob
CharClassification
Classification-with-localization-convert-any-keras-classi...
ColorSpaces
Colorization
Colormap
Contour-Detection-using-OpenCV
ConvexHull
Creating-a-Virtual-Pen-and-Eraser
DNN-OpenCV-Classification-Android
DNN-OpenCV-Classification-with-Java
Deep-Learning-with-OpenCV-DNN-Module
Delaunay
DenoisingAutoencoder
Depth-Perception-Using-Stereo-Camera
Efficient-image-loading
EfficientNet
EigenFace
EpipolarGeometryAndStereoVision
ExposureFusion
FBAMatting
FPS
Face-Recognition-with-ArcFace
FaceAverage
FaceDetectionComparison
models
videos
CMakeLists.txt
README.md
dlib.zip
face_detection_dlib_hog.cpp
face_detection_dlib_hog.py
face_detection_dlib_mmod.cpp
face_detection_dlib_mmod.py
face_detection_opencv_dnn.cpp
face_detection_opencv_dnn.py
face_detection_opencv_haar.cpp
face_detection_opencv_haar.py
run-all.cpp
run-all.py
FaceMaskOverlay
FaceMorph
FaceSwap
FacialAttractiveness
FacialLandmarkDetection
Federated-Learning-Intro
FunnyMirrors
GOTURN
Getting-Started-OpenCV-CUDA-Module
Graph-Convolutional-Networks-Model-Relations-In-Data
HandPose
Hangman
HeadPose
Holes
Homography
Hough-Transform
HuMoments
Image-Classification-in-PyTorch
Image-Inpainting
Image-classification-pre-trained-models
ImageAlignment-FeatureBased
ImageAlignment
ImageMetrics
Improving-Illumination-in-Night-Time-Images
Inference-for-PyTorch-Models/ONNX-Caffe2
Install-OpenCV-Windows-exe
InstallScripts
Intro-to-Generative-Adversarial-Network
InvisibilityCloak
Keras-Fine-Tuning
Keras-ImageNet-Models
Keras-Transfer-Learning
KerasCNN-CIFAR
KerasMLP-MNIST
MRNet-Single-Model
MRnet-MultiTask-Approach
Mask-RCNN
MultiObjectTracker
Non-Maximum-Suppression
NonPhotorealisticRendering
OCR
ObjectDetection-YOLO
OpenCV-dnn-gpu-support-Linux
OpenCV-dnn-gpu-support-Windows
OpenPose-Multi-Person
OpenPose
OpenVINO-OpenCV
Optical-Flow-Estimation-using-Deep-Learning-RAFT
Optical-Flow-in-OpenCV
Photoshop-Filters-in-OpenCV
Playing-Chrome-TRex-Game-with-Facial-Gestures
Playing-rock-paper-scissors-with-AI
PyTorch-Fully-Convolutional-Image-Classification
PyTorch-Keypoint-RCNN
PyTorch-Mask-RCNN
PyTorch-Multi-Label-Image-Classification-Image-Tagging
PyTorch-Multi-Label-Image-Classification
PyTorch-ONNX-TensorRT-CPP
PyTorch-ONNX-TensorRT
PyTorch-Receptive-Field-With-Backprop
PyTorch-Segmentation-torchvision
PyTorch-Vision-Experiment-Logging
PyTorch-faster-RCNN
PyTorch-for-Beginners
PyTorch-to-CoreML-model-conversion
PyTorch-to-TensorFlow-Model-Conversion
Pytorch-Lightning
Pytorch-Net-Surgery
QRCode-OpenCV
Quora-Dataset-Duplicate-Search
ReconstructFaceUsingEigenFaces
RedEyeRemover
RotationMatrixToEulerAngles
SVM-using-Python
SeamlessCloning
SelectiveSearch
SnakeGame
Super-Resolution-in-OpenCV
TSNE
TensorBoard-With-Pytorch-Lightning
TensorFlow-Fully-Convolutional-Image-Classification
TensorFlow-Receptive-Field-With-Backprop
Tetris
TextDetectionEAST
Threshold
Training_a_custom_hand_detector_with_dlib
UI-cvui
UnderstandingLensDistortion
Universal-Sentence-Encoder
Variational-Autoencoder-TensorFlow
VideoBackgroundEstimation
VideoReadWriteDisplay
VideoStabilization
WarpTriangle
XeusCling
YOLOv3-Training-Snowman-Detector
app-seperation-semseg
barcode-QRcodeScanner
digits-classification
docs
downloadOpenImages
forEach
hdr
heatmap
imread
keras-linear-regression
ninjaEyeDetector
otsu-method
pymodule
qt-test
stereo-camera
tracking
video-classification-and-human-activity-recognition
.gitignore
README.md
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

There are 10 code files in this repo - 5 for C++ and 5 for Python:

  1. face_detection_opencv_haar.cpp and face_detection_opencv_haar.py - For Haar based face detection
  2. face_detection_opencv_dnn.cpp and face_detection_opencv_dnn.py - For OpenCV DNN based face detection
  3. face_detection_dlib_hog.cpp and face_detection_dlib_hog.py - for dlib hog based face detection
  4. face_detection_dlib_mmod.cpp and face_detection_dlib_mmod.py - for dlib mmod based face detection
  5. run-all.cpp and run-all.py - for running all the 4 together

First of all Unzip the dlib.zip file

For C++

Compile

Add path to the properly build OpenCV with DNN GPU Support and your CUDA:

cmake -D OpenCV_DIR=~/opencv -D CUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda/ .
make

For Python

Note: Our code is tested using Python 3.7.5, but it should also work with any other python3.x.

Install virtualenv:

pip install virtualenv

Create new virtual environment env and activate it:

python -m venv env
source  env/bin/activate

Install numpy:

pip install numpy

Install dlib:

pip install dlib

Create symlink to the properly build OpenCV with DNN GPU Support:

cd env/lib/python3.x/site-packages/
ln -s ~/opencv/build/cv2.so cv2.so

Run

If you don't pass any filename, it will use the web cam

For individual face detectors

C++

./face_detection_XXXX <filename>

Note: for face_detection_opencv_dnn.cpp you can pass up to 3 arguments:

  • video filename, if you'd like to run inference on a video instead of a camera:
./face_detection_opencv_dnn.out <filename>
  • device, if you want to use CPU instead of CPU:
./face_detection_opencv_dnn.out "" cpu
  • framework to specify Caffe (caffe) or TensorFlow (tf) network to use. Caffe network is set by default:
./face_detection_opencv_dnn.out "" gpu tf

Python

python face_detection_XXXX.py -video <filename>

Note: for face_detection_opencv_dnn.py you can pass up to 3 arguments:

  • filename, if you'd like to run inference on a video instead of a camera:
python face_detection_opencv_dnn.out --video <filename>
  • device, if you want to use CPU instead of GPU:
python face_detection_opencv_dnn.out --video <filename> --device cpu
  • framework to specify Caffe (caffe) or TensorFlow (tf) network to use. Caffe network is set by default:
python face_detection_opencv_dnn.out --video <filename> --device cpu --framework tf

For running all together

C++ ./run-all

Python python run-all.py --video

AI Courses by OpenCV

Want to become an expert in AI? AI Courses by OpenCV is a great place to start.

马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/cubone/learnopencv.git
git@gitee.com:cubone/learnopencv.git
cubone
learnopencv
learnopencv
master

搜索帮助