Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
githubzhaoqian opened this issue Jul 29, 2020 · 1 comment

Comments

@githubzhaoqian
Copy link

githubzhaoqian commented Jul 29, 2020

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!

@githubzhaoqian
Copy link
Author

        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())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant