go-face
go-face copied to clipboard
Update API
- Big update
- Add support opencv (cv::Mat)
- Add gender support
- Add age support
const cnn = "testdata/mmod_human_face_detector.dat"
const shape = "testdata/shape_predictor_68_face_landmarks.dat"
const descr = "testdata/dlib_face_recognition_resnet_model_v1.dat"
const gender = "testdata/dnn_gender_classifier_v1.dat"
const age = "testdata/dnn_age_predictor_v1.dat"
var green = color.RGBA{0, 255, 0, 0}
var thickness = 2
func main() {
deviceID := "0"
recognizer, err := face.NewRecognizer()
if err != nil {
fmt.Println(err)
return
}
webcam, err := gocv.OpenVideoCapture(deviceID)
if err != nil {
fmt.Printf("Error opening video capture device: %v\n", deviceID)
return
}
defer webcam.Close()
webcam.Set(gocv.VideoCaptureFrameWidth, 320)
webcam.Set(gocv.VideoCaptureFrameHeight, 240)
window := gocv.NewWindow("Capture Window")
defer window.Close()
img := gocv.NewMat()
defer img.Close()
recognizer.SetCNNModel(cnn)
recognizer.SetDescriptorModel(descr)
recognizer.SetShapeModel(shape)
recognizer.SetGenderModel(gender)
recognizer.SetAgeModel(age)
recognizer.SetSize(150)
recognizer.SetPadding(0.25)
recognizer.SetMinImageSize(200000)
recognizer.SetJittering(0)
fmt.Printf("Start reading device: %v\n", deviceID)
for {
if ok := webcam.Read(&img); !ok {
fmt.Printf("Device closed: %v\n", deviceID)
return
}
if img.Empty() {
continue
}
start := time.Now()
faces, err := recognizer.DetectFromMatCNN(img)
if err != nil {
fmt.Println(err)
continue
}
for _, f := range faces {
gocv.Rectangle(&img, f.Rectangle, green, thickness)
recognizer.Recognize(&f)
face.RenderFaceDetections(&img, f.Shapes, green, thickness)
recognizer.GetGender(&f)
recognizer.GetAge(&f)
fmt.Println(f.Gender, f.Age)
f.Close()
}
fmt.Println(time.Since(start))
window.IMShow(img)
if window.WaitKey(1) == 27 {
break
}
}
}
go build -tags gocv
screen)
Sounds great! Does anybody going to approve this merge request?
@tpoxa, Hi!) I am now checking changes and after I'll merge it. If you have some ideas, send it to [email protected]
Hi @Danile71 I decided to try your new API approach. I use the same docker environment to build library as for Kagami's Your branch fails to build with next error:
wrapper.cc: In function 'facesret* facerec_detect_from_buffer(facerec*, unsigned char*, int, int)':
wrapper.cc:103:39: error: no matching function for call to 'load_jpeg(image_t&, unsigned char*&, size_t)'
load_jpeg(img, img_data, size_t(len));
^
In file included from wrapper.cc:5:
/usr/include/dlib/image_loader/jpeg_loader.h:91:10: note: candidate: 'template<class image_type> void dlib::load_jpeg(image_type&, const string&)'
void load_jpeg (
^~~~~~~~~
/usr/include/dlib/image_loader/jpeg_loader.h:91:10: note: template argument deduction/substitution failed:
wrapper.cc:103:39: note: candidate expects 2 arguments, 3 provided
load_jpeg(img, img_data, size_t(len));
^
Are there any new dependencies/requirements?
Looks like Dlib version >=19.18 now is required...
This looks great. I was about to write some of this myself. Is there an ETA on it being merged?
@Danile71 Can u fix the github merge conflicts.
Please send me a msg; I might have a project for u.
This looks great, especially recognizer.DetectFromMatCNN which would be amazing! I'm looking forward to the merge.
any news about this one ?
any news about this one ?
This repo has been abandoned, just use C++ version of it.