Exemple #1
0
func loop(path string, paint, crosshair bool) {

	pictureFiles = GetFileNames(path)

	//	images := make([][]byte, len(pictureFiles))
	faceDetector := gofaces.NewFaceDetector()

	//	for i := 0; i < len(pictureFiles); i++ {

	//	}

	fmt.Println("Pictures: ", len(pictureFiles))

	for i := 0; i < len(pictureFiles); i++ {

		fmt.Println("Processing picture: ", pictureFiles[i])
		img := gofaces.GetNormalizedByteVectorFromFile(pictureFiles[i])
		faces := faceDetector.Detect(img)
		if len(faces) > 0 {
			if paint {
				img = gofaces.PaintFace(img, faces[0])
			}

			if faces[0].Eyes() > 1 {
				img = gofaces.AlignFaceInImage(img, faces[0])
			}

			if crosshair {
				img = gofaces.Crosshair(img)
			}

			cropface := gofaces.CropOutFace(img, faces[0])

			win := opencv.NewWindow("Face Detected")

			win.ShowImage(opencv.DecodeImageMem(cropface))
			opencv.WaitKey(0)
			win.Destroy()
		} else {
			win := opencv.NewWindow("No face found")

			win.ShowImage(opencv.DecodeImageMem(img))
			opencv.WaitKey(0)
			win.Destroy()
		}

	}
}
Exemple #2
0
func one(path string, paint bool) {
	faceDetector := gofaces.NewFaceDetector()

	picture := gofaces.GetNormalizedByteVectorFromFile(path)
	faces := faceDetector.Detect(picture)
	if paint {
		picture = gofaces.PaintFace(picture, faces[0])
	}
	picture = gofaces.AlignFaceInImage(picture, faces[0])
	picture = gofaces.CropOutFace(picture, faces[0])

	win := opencv.NewWindow("Face Detection")
	defer win.Destroy()

	win.ShowImage(opencv.DecodeImageMem(picture))
	opencv.WaitKey(0)
}