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 recognition confidence #42

Closed
45kb opened this issue Jan 9, 2015 · 4 comments
Closed

Face recognition confidence #42

45kb opened this issue Jan 9, 2015 · 4 comments

Comments

@45kb
Copy link

45kb commented Jan 9, 2015

Hi, sorry for the issue, i am not understanding how to detect a face in a photo.
This is the code i am using http://pastebin.com/WrphXW1N

Actually it returns the Object with all the infos (confidence, x, y etc..), but how do i check if the data matches a face? Is the confidence value telling me if it's a face or not?

I took this piece of code from the clmtrackr library, which seems to use jsfeat.

Any help appreciated, thank you!

@45kb 45kb changed the title Face recognition returned object Face recognition confidence Jan 9, 2015
@inspirit
Copy link
Owner

inspirit commented Jan 9, 2015

you are getting an array of rectangles with some properties that allow you to decide if face is good enough to further processing.
you can also look at the demo here:
https://github.com/inspirit/jsfeat/blob/gh-pages/sample_haar_face.html

@inspirit inspirit closed this as completed Jan 9, 2015
@45kb
Copy link
Author

45kb commented Jan 10, 2015

@inspirit Hi, thank you for the support, i am actually in trouble cause the code seems ok but rects.length is always 0 i debugged but it seems i am missing something, any clue please?

  var canvas = $window.document.getElementById('canvas')
  , canvasWidth = canvas.width
  , canvasHeight = canvas.height
  , ctx = canvas.getContext('2d')
  , work_canvas = $window.document.createElement('canvas')
  , work_ctx = work_canvas.getContext('2d')
  , ii_sum = new Int32Array((canvasWidth+1)*(canvasHeight+1))
  , ii_sqsum = new Int32Array((canvasWidth+1)*(canvasHeight+1))
  , ii_tilted = new Int32Array((canvasWidth+1)*(canvasHeight+1))
  , img_u8 = new jsfeat.matrix_t(canvasWidth, canvasHeight, jsfeat.U8_t | jsfeat.C1_t)
  , classifier = jsfeat.haar.frontalface
  , imageData
  , rects;

  work_canvas.width = canvasWidth;
  work_canvas.height = canvasHeight;
  jsfeat.haar.edges_density = 0.13;

  work_ctx.drawImage(canvas, 0, 0);
  imageData = work_ctx.getImageData(0, 0, work_canvas.width, work_canvas.height);


  var anim = function () {

    jsfeat.imgproc.grayscale(imageData.data, work_canvas.width, work_canvas.height, img_u8);
    jsfeat.imgproc.equalize_histogram(img_u8, img_u8);
    jsfeat.imgproc.compute_integral_image(img_u8, ii_sum, ii_sqsum, classifier.tilted ? ii_tilted : null);

    rects = jsfeat.haar.detect_multi_scale(ii_sum,
     ii_sqsum,
     ii_tilted,
     null,
     img_u8.cols,
     img_u8.rows,
     classifier,
     1.15,
     2);

    rects = jsfeat.haar.group_rectangles(rects, 1);

    if (rects && rects.length === 0) {

      $window.requestAnimationFrame(anim);
    } else {

      console.log(rects);
    }
  }

  anim();

@45kb
Copy link
Author

45kb commented Jan 10, 2015

Sorry, it's my mistake, it works, i was using a wrong version of jsfeat i guess, sorry again :)

@inspirit
Copy link
Owner

Congratulations! 👍

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

2 participants