Beispiel #1
0
func (detector *FaceDetector) DetectGlasses(image *opencv.IplImage, roi pixelArea) (leftEyes, rightEyes pixelCoords) {

	var topFace opencv.Rect
	var eyes pixelCoords

	topFace.Init(roi.X(), roi.Y()+int(float64(roi.Height())*0.20), roi.Width(), int(float64(roi.Height())/2))

	image.SetROI(topFace)
	for _, eye := range detector.glassesCascade.DetectObjects(image) {
		leftEyes = append(leftEyes, pixelCoord{
			x:      eye.X() + topFaceLeft.X(),
			y:      eye.Y() + topFaceLeft.Y(),
			width:  eye.Width(),
			height: eye.Height(),
		})
	}

	fmt.Println(len(leftEyes), " left eyes found")

	image.SetROI(topFaceRight)
	for _, eye := range detector.glassesCascade.DetectObjects(image) {
		rightEyes = append(rightEyes, pixelCoord{
			x:      eye.X() + topFaceRight.X(),
			y:      eye.Y() + topFaceRight.Y(),
			width:  eye.Width(),
			height: eye.Height(),
		})
	}
	fmt.Println(len(rightEyes), " right eyes found")

	image.ResetROI()
	return
}