Giter Club home page Giter Club logo

Comments (5)

esimov avatar esimov commented on June 9, 2024

What you can do is to increase the MinSize to 50 or above to achieve a better frame rate, because this value defines the lower threshold above the face detector should be performed. I assume that the chances are very low that you need to analyze videos where the face sizes are smaller than 50px. Also if you already know the video size in advance you can adapt the MinSize and MaxSize accordingly. Another tip is to increase the ScaleFactor with a few decimals, maybe around 1.3, 1.4. I've changed the MinSize to 80 while testing and I got pretty decent latencies. There is no need to decrease the video frame rate, just adapt the cascade values.

Here are my settings:

cParams := pigo.CascadeParams{
	MinSize:     80,
	MaxSize:     1000,
	ShiftFactor: 0.1,
	ScaleFactor: 1.4,
	ImageParams: pigo.ImageParams{
		Pixels: pixels,
		Rows:   rows,
		Cols:   cols,
		Dim:    cols,
	},
}

from pigo.

pjebs avatar pjebs commented on June 9, 2024

Direct him to your real time examples you did with web cam. They achieved good frame rate.

Secondly there is an optimisation you can make which I regularly do. You can assume the face in the next frame is approximately in same area.

So in frame 1, you detect the number of faces and area. Say 1 face was discovered in pos A.

In frame 2 you first crop the frame to pos A + 20%. You then look for faces in the sub frame.

If you find the face, move to frame 3. If not, search for faces in entire frame 2.

You can dramatically increase performance this way.

You also must use of all your CPU cores.

from pigo.

esimov avatar esimov commented on June 9, 2024

@pjebs that's sound like a really cool optimization approach, I haven't thought about it. Do you have some available examples about this approach?

from pigo.

Jefry-nolastname avatar Jefry-nolastname commented on June 9, 2024

@esimov thank you so much. After i set the min/max based on video res, the speed doubled/tripled. Thanks.

  cols, rows := frame.Bounds().Max.X, frame.Bounds().Max.Y
  cParams := pigo.CascadeParams{
	  MinSize:     rows / 18,
	  MaxSize:     rows,
	  ShiftFactor: 0.1,
	  ScaleFactor: 1.4,
	  ImageParams: pigo.ImageParams{
		  Pixels: pixels,
		  Rows:   rows,
		  Cols:   cols,
		  Dim:    cols,
	  },
  }

@pjebs That's so Giga Brain of you. But that optimisation to me at least, seems best used for 1 face detection in each frame and quite costly for the performance if the frame a bit crowded. But i'll try it anyway and see for myself. Thanks

from pigo.

esimov avatar esimov commented on June 9, 2024

This is exactly the same reason why I was curious about @pjebs suggestions, because cropping the image on each frame rate is quite costly, definitely more computation extensive than detecting the whole image, considering also that you have to deal with multiple faces. Maybe with one or two faces this approach is affordable giving a better performance boost.

from pigo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.