I mark detected faces with semi-transparent filled Layers:
However, it seems that the semi-transparent Layers also make semi-transparent borders, so the visibility of the red borders is reduced:
procedure TformMain.mExtractFacesClick(Sender: TObject);
begin
ImageEnViewPixelEditor.MouseInteractLayers := [mlMoveLayers, mlResizeLayers];
// Layers cannot be dragged beyond the background layer:
ImageEnViewPixelEditor.LayerOptions := ImageEnViewPixelEditor.LayerOptions + [loPreventOutOfBounds];
// create objectsFinder:
var objectsFinder := IEVisionLib.createObjectsFinder();
// following haar parameters may vary by image content:
objectsFinder.setDivisor(1);
objectsFinder.setHaarMinNeighbors(4);
//objectsFinder.setHaarScaleFactor(1.2);
// Add classifiers:
objectsFinder.addClassifier('face detector 1', IEVisionLib.createCascadeClassifier(IEVC_FRONTAL_FACE_DEFAULT));
objectsFinder.addClassifier('face detector 2', IEVisionLib.createCascadeClassifier(IEVC_FRONTAL_FACE_ALT_TREE));
objectsFinder.addClassifier('face detector 3', IEVisionLib.createCascadeClassifier(IEVC_FRONTAL_FACE_ALT));
objectsFinder.addClassifier('face detector 4', IEVisionLib.createCascadeClassifier(IEVC_FRONTAL_FACE_ALT_2));
objectsFinder.addClassifier('face detector 5', IEVisionLib.createCascadeClassifier(IEVC_PROFILE_FACE));
CodeSite.Send('TformMain.mExtractFacesClick: 1');
// Find Faces in image:
objectsFinder.findIn(ImageEnViewPixelEditor.IEBitmap.GetIEVisionImage());
var rects := objectsFinder.mergeAllRects(); // merge intersecting rectangles
CodeSite.Send('TformMain.mExtractFacesClick: 2');
// Draw rects to image:
ImageEnViewPixelEditor.LayersClear(False);
var r: TIEVisionRect;
for var i := 0 to rects.size() - 1 do
begin
r := rects.getRect(i);
//with ImageEnViewPixelEditor.IEBitmap.Canvas do
begin
{Pen.Width := 2;
Pen.Color := clRed;
Brush.Style := bsClear;
Rectangle(r.x, r.y, r.x + r.width, r.y + r.width);}
var ThisLayer := ImageEnViewPixelEditor.LayersAdd(iesRectangle, Rect(r.x, r.y, r.x + r.width, r.y + r.height),
clRed, 2, clYellow);
ImageEnViewPixelEditor.Layers[ThisLayer].Visible := True;
ImageEnViewPixelEditor.Layers[ThisLayer].VisibleBox := True;
ImageEnViewPixelEditor.Layers[ThisLayer].Transparency := 64;
ImageEnViewPixelEditor.Layers[ThisLayer].Tag := FFaceLayer;
ImageEnViewPixelEditor.Layers[ThisLayer].BorderColor := clRed;
ImageEnViewPixelEditor.Layers[ThisLayer].BorderWidth := 2;
end;
end;
ImageEnViewPixelEditor.Update;
CodeSite.Send('TformMain.mExtractFacesClick: 3');
end;
So is there a way to make the borders of the layers NON-TRANSPARENT (to increase their visibility) while leaving the Layers still semi-transparent?
BTW, I don't want to paint rectangles directly on the image - that's why I use only Layers to mark the faces. A possible workaround could be to duplicate the background layer and paint the rectangles on that duplicate layer. But that would complicate things enormously when having to move or resize the layers, so I would prefer to have layers with non-transparent borders - if that is possible.
BTW2, anyone will have noticed that the two rectangles on Mr. B.G. completely intersect and should be merged. So this seems to be an issue that should also be resolved.