-
Notifications
You must be signed in to change notification settings - Fork 11
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
add opencv #3
base: master
Are you sure you want to change the base?
add opencv #3
Conversation
int[] od = o.data; | ||
for (int i = 0; i < o.width; i++) { | ||
// od[i] = (0 << 24) | (od[i] & 0xffffff); | ||
od[i] &= 0xffffff00; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this going to zero the saturation score? Surely you want to zero the alpha channel (used for boost)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, shouldn't you be applying this to the whole image, and not just the first row?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, shouldn't you be applying this to the whole image, and not just the first row?
yes, you are right. I fixed that.
this.height = height; | ||
this.data = new int[width * height]; | ||
for (int i = 0; i < this.data.length; i++) | ||
data[i] = 0xff000000; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI, this is going to set the alpha channel/boost score to 255 for the whole image by default, so you might want to change this to zero.
|
||
CropResult result = CropResult.newInstance(topCrop, crops, output, createCrop(input, topCrop)); | ||
if (options.isDebug()) { | ||
Graphics graphics = output.getGraphics(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As you are updating the alpha channel due to the boost calculation, you might want to drop the alpha channel from debug output (otherwise all pixels where the alpha channel is 0 won't be visible). I use the following to create a new BufferedImage without the alpha channel.
BufferedImage debugOutput = new BufferedImage(output.getWidth(), output.getHeight(), BufferedImage.TYPE_INT_RGB);
// Drop alpha channel from debug output
BandCombineOp filterAlpha = new BandCombineOp(
// RGBA -> RGB
new float[][] {
{1.0f, 0.0f, 0.0f, 0.0f},
{0.0f, 1.0f, 0.0f, 0.0f},
{0.0f, 0.0f, 1.0f, 0.0f}
}, null
);
filterAlpha.filter(output.getRaster(), debugOutput.getRaster());
public Crop[] detectFace(String imagePath) { | ||
Mat image = Imgcodecs.imread(imagePath); | ||
MatOfRect faceDetections = new MatOfRect(); | ||
cascadeClassifier.detectMultiScale(image, faceDetections); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't this classifier use a grey scale image?
Coincidentally I have also been working on this code recently to incorporate face detection using different OpenCV algorithms (Haar Cascade and DNN). I've also updated the code to closer match the current smartcrop.js algorithm. I will submit this as a PR when I get the chance. |
No description provided.