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

face-detector img with no face error handling #60

Open
zurek11 opened this issue Mar 7, 2018 · 5 comments
Open

face-detector img with no face error handling #60

zurek11 opened this issue Mar 7, 2018 · 5 comments

Comments

@zurek11
Copy link

zurek11 commented Mar 7, 2018

Hi if i take a photo without any face is some way to handle this error with face detection? If so how can i handle this error? Because when i tried do that program returned this error:

fr.saveImage(path,faceImage[0]);
   ^

Error: Save_Image - Error: expected argument 1 to be of type ImageRGB
@zurek11
Copy link
Author

zurek11 commented Mar 7, 2018

And one more question. How can i save recogniser with added faces to database? Is there some way to save this variable there? (Because I want to use prediction more time and is non effective to train recognizer again and again with the same images).

@justadudewhohacks
Copy link
Owner

Hi, if no faces are detected then the returned faceImages array is empty. In you case faceImage[0] is simply undefined I guess.

How to serialize a model to json and load it again is described in the readme:

Save a trained model to json file:

const fs = require('fs')
const modelState = recognizer.serialize()
fs.writeFileSync('model.json', JSON.stringify(modelState))

Load a trained model from json file:

const modelState = require('model.json')
recognizer.load(modelState)

Simply serialize the model and store the json object or the stringified json in your db.

@zurek11
Copy link
Author

zurek11 commented Mar 7, 2018

const modelState = require('model.json') throws error: Cannot find module 'model.json' how can i install him? I was trying to install him as face-recognition so npm install model.json but console throw also error:

npm ERR! code E404
npm ERR! 404 Not Found: model.json@latest

@justadudewhohacks
Copy link
Owner

model.json is just a json file that you write the serialized state of the face recognizer to, as shown in the example above.

@odykyi
Copy link

odykyi commented Mar 29, 2018

@zurek11

// file1.js

const fs = require('fs')
// init recognizer
const modelState = recognizer.serialize()
fs.writeFileSync('model.json', JSON.stringify(modelState))

// file2.js

const modelState = require('./model.json');
//init recognizer
recognizer.load(modelState)

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

3 participants