Skip to content

Optional face detection with gocv - #35

Open
svkoskin wants to merge 29 commits into
muesli:masterfrom
svkoskin:face-detection
Open

Optional face detection with gocv#35
svkoskin wants to merge 29 commits into
muesli:masterfrom
svkoskin:face-detection

Conversation

@svkoskin

Copy link
Copy Markdown

I restored face detection features using another set of bindings for OpenCV, called gocv. It should still be possible to build smartcrop without having OpenCV installed. I have no particular interest in maintaining or supporting a fork, so if there is any chance for this to get merged, I'd appreciate it 😸

@muesli

muesli commented Apr 18, 2018

Copy link
Copy Markdown
Owner

This looks fairly promising, thanks! Will try it out, see how it goes and provide feedback here.

Comment thread smartcrop.go Outdated
const (
detailWeight = 0.2
skinBias = 0.01
skinBias = 0.9

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This probably isn't the best idea, as it changes the current behavior (without face detection). We should introduce a separate bias here, maybe.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's a valid concern. I ended up with this since now the score function does not know whether skin or face was detected. Would it be useful to be able to override these values, or are the same values useful for all use cases? If it is useful some kind of API for providing overrides could solve this problem.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe each Detector should contain & provide its own bias, which the user could then manipulate, e.g. by manually initializing a Detector.

Comment thread gocv/face.go Outdated
height := face.Dy()

if d.DebugMode == true {
log.Printf("Face: x: %d y: %d w: %d h: %d\n", x, y, width, height)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should think about injecting the Logger here.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes that seems smart

Comment thread smartcrop.go
return &smartcropAnalyzer{Resizer: resizer, logger: logger}

// Set default detectors here
detectors := []Detector{

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a nice idea, but requires a bit more restructuring, I think. For example, if you initialize smartcrop with only the FaceDetector, the debug output looks a bit funky.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, when this goes public the interface needs to be a bit stricter. I witnessed that by unintentionally changing the order of detectors, and got my detected face overwritten by the artist formerly known as edgeDetect. I'll try to figure something out.

@svkoskin

Copy link
Copy Markdown
Author

Thanks for your feedback, I'll try to resolve the issues.

@muesli

muesli commented May 9, 2018

Copy link
Copy Markdown
Owner

@svkoskin If there's anything I can do to help, let me know!

svkoskin added 13 commits June 5, 2018 13:32
This reverts commit a3a40ff.
smartcropAnalyzer will soon have the configuraed detectors as its members, and a method can use them without having to pass them as parameters
EdgeDetector's results are handled a bit differently in the scoring phase, so introduce a new interface and a field for it
Revert skin bias to the value in master branch that users are depending on. This reverts commit e15f810.
@svkoskin

svkoskin commented Jun 8, 2018

Copy link
Copy Markdown
Author

@muesli As usual, I have had a bit limited time for actually implementing the fixes. Detaching bias seemed to require quite a big refactoring, but I added providing bias and weights to Detector's responsibilities. Making detections [][]uint8-based made it a bit easier to detach things from each other. Nevertheless, without attaching the face detector this should now return same crops as the version in master.

@muesli

muesli commented Sep 9, 2018

Copy link
Copy Markdown
Owner

I have not forgotten about this! Just need to find some time to fix up the CI and integrate all your changes - sorry it's been taking so long!

@ybouhachem

Copy link
Copy Markdown

Any update on this?

@muesli

muesli commented Apr 1, 2020

Copy link
Copy Markdown
Owner

@Nazdroth I'm currently attempting to migrate the CI stuff over to GitHub actions for a bunch of my projects - this among them. This should hopefully make it easier to fix up the CI with the required dependencies. As @svkoskin mentioned themselves, this probably still requires a bit of work inside smartcrop to decouple the bias and weighting process.

Other than that still a fantastic PR, I just need to find the time to tie up the loose ends. Actually looking forward to that, though!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants