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
 IEVision - Unspecified Error

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
yogiyang Posted - May 07 2019 : 03:23:47
Hello,

I am trying to integrate WaterShed to select pixels based on red color and green color markers.

I am using following code (most of the code is taken from the sample provided):

  wsq: TIEVisionWatershed;

  wsq := IEVisionLib().createWatershed();

  // Code to Create Selection
  wsq.setMarkers(0);
  wsq.setMarkers(ImageEnViewMain.Layers[1]
    .Bitmap.GetIEVisionImage());
  ImageEnViewMain.Layers[1].Bitmap.origin := ieboBOTTOMLEFT;
  wsq.run();

  ImageEnViewMain.LayersCurrent := 0;
  ImageEnViewMain.Deselect();
  wsq.getSelectionMask(ImageEnViewMain.SelectionMask, Integer(REGION2COLOR[1]));
  ImageEnViewMain.SelectCustom();
  ImageEnViewMain.Layers[1].Visible := False;
  ImageEnViewMain.Update;



Code in OnMouseMove Event:

if RadioGroupDefineRegion.ItemIndex > 1 then
      exit;

    if rgModes.ItemIndex > 0 then
      exit;

    bmpX := ImageEnViewMain.XScr2Bmp(X);
    bmpY := ImageEnViewMain.YScr2Bmp(Y);
    if (ImageEnViewMain.LayersCount > 1) and (ssLeft in Shift) and (bmpX >= 0) and
      (bmpY >= 0) and (bmpX < ImageEnViewMain.IEBitmap.Width) and
      (bmpY < ImageEnViewMain.IEBitmap.Height) then
    begin
      ellipsRect := Rect(bmpX - ELLIPSRAY, bmpY - ELLIPSRAY, bmpX + ELLIPSRAY,
        bmpY + ELLIPSRAY);

      // draw on layer1 bitmap canvas
      with ImageEnViewMain.Layers[1].Bitmap.Canvas do
      begin
        Pen.Color := REGION2COLOR[RadioGroupDefineRegion.ItemIndex];
        Brush.Color := Pen.Color;
        Ellipse(ellipsRect);
      end;

      // draw on layer1 bitmap alpha (to make painted ellipse visible)
      ImageEnViewMain.Layers[1]
        .Bitmap.AlphaChannel.CanvasCurrentAlpha := 255;
      with ImageEnViewMain.Layers[1].Bitmap.AlphaChannel.Canvas do
      begin
        Ellipse(ellipsRect);
      end;

      ImageEnViewMain.UpdateRect(Rect(X - ELLIPSRAY, Y - ELLIPSRAY, X + ELLIPSRAY,
        Y + ELLIPSRAY), true);

    end;


Code in Button Click Event:

  wsq.setMarkers(0);
  wsq.setMarkers(ImageEnViewMain.Layers[1]
    .Bitmap.GetIEVisionImage());
  ImageEnViewMain.Layers[1].Bitmap.origin := ieboBOTTOMLEFT;
  wsq.run();

  ImageEnViewMain.LayersCurrent := 0;
  ImageEnViewMain.Deselect();
  wsq.getSelectionMask(ImageEnViewMain.SelectionMask, Integer(REGION2COLOR[1]));
  ImageEnViewMain.SelectCustom();
  ImageEnViewMain.Layers[1].Visible := False;
  ImageEnViewMain.Update;


I am getting error when wsq.run(); is executed.

What must be the problem?

TIA


Yogi Yang
1   L A T E S T    R E P L I E S    (Newest First)
yogiyang Posted - May 07 2019 : 07:12:37
Hello,

Problem is solved.

I had forgotten to initialize wsq.setInputImage.

I did that and now things are working fine.




Yogi Yang