ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Semi-transparent Layers with non-transparent border?

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
PeterPanino Posted - Nov 05 2022 : 14:15:55
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.
5   L A T E S T    R E P L I E S    (Newest First)
PeterPanino Posted - Nov 07 2022 : 04:58:47
Hi Nigel,

Thank you, that works perfectly. ImageEn has a solution for everything.
xequte Posted - Nov 06 2022 : 18:18:02
Hi

You can use FillOpacity to specify a different transparency for the fill than the the border. See the example at:

http://www.imageen.com/help/TIELayer.FillOpacity.html

Nigel
Xequte Software
www.imageen.com
PeterPanino Posted - Nov 05 2022 : 18:03:11
When using $0093FFFF instead of clYellow, it is even better:

PeterPanino Posted - Nov 05 2022 : 17:51:06
Another approach is this one:

for var i := 0 to rects.size() - 1 do
begin
  r := rects.getRect(i);
  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].Operation := ielAverage;
  ImageEnViewPixelEditor.Layers[ThisLayer].Tag := FFaceLayer;
  ImageEnViewPixelEditor.Layers[ThisLayer].BorderColor := clRed;
  ImageEnViewPixelEditor.Layers[ThisLayer].BorderWidth := 2;
end;




It is not optimal, but it is still better than the first one.
PeterPanino Posted - Nov 05 2022 : 17:13:34
I tried this approach:

for var i := 0 to rects.size() - 1 do
begin
  r := rects.getRect(i);
  var bm := TIEBitmap.Create;
  cxImageListLarge.GetImage(11, bm.VclBitmap); // semi-transparent mono-color PNG image
  var ThisLayer := ImageEnViewPixelEditor.LayersAdd(bm);
  ImageEnViewPixelEditor.Layers[ThisLayer].LayerRect := Rect(r.x, r.y, r.x + r.width, r.y + r.height);
  ImageEnViewPixelEditor.Layers[ThisLayer].Visible := True;
  ImageEnViewPixelEditor.Layers[ThisLayer].VisibleBox := True;;
  ImageEnViewPixelEditor.Layers[ThisLayer].Tag := FFaceLayer;
  ImageEnViewPixelEditor.Layers[ThisLayer].BorderColor := clRed;
  ImageEnViewPixelEditor.Layers[ThisLayer].BorderWidth := 2;
  bm.Free;
end;


The Layers are created correctly, but they have no visible image and no visible border.