Kagami/go-face

Error detected in function dlib::chip_details dlib::get_face_chip_details(const dlib::full_object_detection&, long unsigned int, double)

Closed this issue · 2 comments

Im trying to run go-face package in docker container. I have managed to setup dlib in my container. but, when I run the docker container i get these error messages

Can't recognize: 
Error detected at line 1958.
Error detected in file /usr/local/include/dlib/image_transforms/interpolation.h.
Error detected in function dlib::chip_details dlib::get_face_chip_details(const dlib::full_object_detection&, long unsigned int, double).

Failing expression was det.num_parts() == 68.
	 chip_details get_face_chip_details()
	 You must give a detection with exactly 68 parts in it.
	 det.num_parts(): 5

Here is the Dockerfile and the golang code im using

FROM golang:1.11.1 as builder
ENV GOPATH /go
ADD . /project
WORKDIR /project
RUN \
  bashfiles/setup.sh
WORKDIR /root/
COPY dlib-1.pc /usr/local/lib/pkgconfig/dlib-1.pc
RUN go get github.com/Kagami/go-face
WORKDIR /project
RUN go build -o app main.go
CMD ["./app"]

here is my setup.sh bash file

#!/bin/bash
set -v
export ROOT=$(cd $(dirname $0)/.. && pwd)

# 1. Install Python, pip
apt-get update
apt-get install -y python-pip python-dev swig python-numpy

# installing dlib
apt-get install -y build-essential cmake pkg-config
apt-get install -y libx11-dev libatlas-base-dev
apt-get install -y libjpeg62-turbo-dev
apt-get install -y libgtk-3-dev libboost-python-dev
apt-get install -y python-dev python-pip python3-dev python3-pip
pip2 install -y -U pip numpy
pip3 install -y -U pip numpy

wget http://dlib.net/files/dlib-19.6.tar.bz2
tar xvf dlib-19.6.tar.bz2
cd dlib-19.6/
mkdir build
cd build
cmake ..
cmake --build . --config Release
make install
ldconfig

Here is a sample golang code im using

package main

import (

	"encoding/json"
	"fmt"
	"github.com/Kagami/go-face"
	"log"
	"strings"

)


func GetFaceEncodings(name string) (encodings_float []float64 , encodings_string string, err error)  {

	const dataDir = "models"

	rec, err := face.NewRecognizer(dataDir)

	if err != nil {
		fmt.Println("Cannot initialize recognizer")
	}
	defer rec.Close()


	facesdlib, err := rec.RecognizeFile(name)

	if err != nil {
		log.Fatalf("Can't recognize: %v", err)
	}
	//fmt.Println("Number of Faces in Image: ", len(facesdlib))

	var face_encodings []face.Descriptor

	for _, f := range facesdlib {

		face_encodings = append(face_encodings, f.Descriptor)

		encodings_string = fmt.Sprintf("%f", face_encodings)
		encodings_string = strings.Replace(encodings_string, " ", ", ", -1)
		encodings_string = strings.Replace(encodings_string, "[[", "[", -1)
		encodings_string = strings.Replace(encodings_string, "]]", "]", -1)

		//fmt.Printf("encodings string is %v \n", encodings_string)

		if err := json.Unmarshal([]byte(encodings_string), &encodings_float); err != nil {
			fmt.Println("unable to parse signature")
		}
		//fmt.Printf("encodings float64 is %v \n", encodings_float)

	}
	return encodings_float, encodings_string, err
}

func main() {

	encodings_float1, encodings_string, err := GetFaceEncodings("data/kohli1.jpg")

	if err != nil {
		fmt.Println("error processing image 1")
	}

	fmt.Printf("encodings float is %v \n \n \n", encodings_float1)
	fmt.Printf("encodings string is %v \n", encodings_string)

}

What am I doing wrong ?

I think dlib 19.6 is too old, try 19.10 or 19.15.

Yeah, I tried 19.16 it worked fine.
Thanks