Kagami/go-face

How to get imgData []byte? func (rec *Recognizer) RecognizeSingle(imgData []byte) (face *Face, err error)

githubzhaoqian opened this issue · 1 comments

How to get imgData []byte?

         testDrStrange := filepath.Join(dataDir, "dr-strange.jpg")
	//drStrange, err := rec.RecognizeSingleFile(testDrStrange)
	file, err := os.Open(testDrStrange)
	if err != nil {
		log.Fatalf("open %s err: %v", testDrStrange, err)
	}
	rd := bufio.NewReader(file)
	sz := rd.Size()
	b := make([]byte, sz)
	rd.Read(b)
	drStrange, err := rec.RecognizeSingle(b)
	if err != nil {
		log.Fatalf("Can't recognize: %v", err)
	}

Can't recognize: jpeg_mem_loader: decode error: Premature end of JPEG file

dr-strange.jpg Is the right jpg.
use func RecognizeSingleFile is ok!

        file, err := os.Open(testDrStrange)
	if err != nil {
		log.Fatalf("open %s err: %v", testDrStrange, err)
	}
	nb := new(bytes.Buffer)
	io.Copy(nb, file)
	drStrange, err := rec.RecognizeSingle(nb.Bytes())