예제 #1
0
파일: main.go 프로젝트: postfix/gofaces
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()
		}

	}
}
예제 #2
0
파일: main.go 프로젝트: postfix/gofaces
func debug(path string) {
	faceDetector := gofaces.NewFaceDetector()

	picture := gofaces.GetNormalizedByteVectorFromFile(path)

	image := opencv.DecodeImageMem(picture)
	faceAreas := faceDetector.DetectFaces(image)
	faces := faceDetector.DetectFacialFeatures(image, faceAreas)

	picture = gofaces.PaintFaces(picture, faces)

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

	win.ShowImage(opencv.DecodeImageMem(picture))
	opencv.WaitKey(0)
}
예제 #3
0
파일: main.go 프로젝트: postfix/gofaces
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)
}