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.
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.
Also, shouldn't you be applying this to the whole image, and not just the first row?
There was a problem hiding this comment.
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.
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.
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.
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.