ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder
ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 convert iekbox to polyline
 New Topic  Reply to Topic
 Printer Friendly
Next Page
Author Previous Topic Topic Next Topic
Page: of 2

pierrotsc

USA
296 Posts

Posted - Nov 29 2018 :  14:33:14  Show Profile  Reply
I have a rough time trying to convert the iekbox code (Looks like it's becoming obsolete) to a polyline.

This is the code i use.
ImageEnVect.AddNewObject(iekBOX,
Rect(Embeddeddm.nxTable_Tablet.FieldByName('Square00' + IntToStr(i) +
'_Left').AsInteger, Embeddeddm.nxTable_Tablet.FieldByName('Square00' +
IntToStr(i) + '_Top').AsInteger,
Embeddeddm.nxTable_Tablet.FieldByName('Square00' + IntToStr(i) +
'_Right').AsInteger, Embeddeddm.nxTable_Tablet.FieldByName('Square00'
+ IntToStr(i) + '_Bottom').AsInteger), Mainform.PenColor.colorvalue);

I tried that but I guess that is not it :)

SetLength(iShapePoints, 4);
iShapePoints[0] := Point(Embeddeddm.nxTable_Tablet.FieldByName('Square00' + IntToStr(1) + '_Left').AsInteger, Embeddeddm.nxTable_Tablet.FieldByName('Square00' + IntToStr(1) + '_Top').AsInteger);
iShapePoints[1] := Point(Embeddeddm.nxTable_Tablet.FieldByName('Square00' + IntToStr(1) + '_Top').AsInteger, Embeddeddm.nxTable_Tablet.FieldByName('Square00' + IntToStr(1) + '_Right').AsInteger);
iShapePoints[2] := Point(Embeddeddm.nxTable_Tablet.FieldByName('Square00' + IntToStr(1) + '_Right').AsInteger, Embeddeddm.nxTable_Tablet.FieldByName('Square00' + IntToStr(1) + '_Bottom').AsInteger);
iShapePoints[3] := Point(Embeddeddm.nxTable_Tablet.FieldByName('Square00' + IntToStr(1) + '_Bottom').AsInteger, Embeddeddm.nxTable_Tablet.FieldByName('Square00' + IntToStr(1) + '_Left').AsInteger);
ilayer := Mainform.ImageEnVect.LayersAdd(ielkPolyline);
TIEPolylineLayer(Mainform.ImageEnVect.Layers[ilayer]).LineWidth := 3;
TIEPolylineLayer(Mainform.ImageEnVect.Layers[ilayer]).LineColor := clred;
TIEPolylineLayer(Mainform.ImageEnVect.Layers[ilayer]).PolylineClosed := True;

TIEPolylineLayer(Mainform.ImageEnVect.Layers[ilayer]).SetPoints(iShapePoints, True);
Mainform.ImageEnVect.Update();

Any guru out there that can help me?
Thanks

xequte

4143 Posts

Posted - Nov 29 2018 :  14:49:15  Show Profile  Reply
Hi

What are the values you are passing as points? Are these screen positions?

You need to specify a relevant PointBase when caling SetPoints:

https://www.imageen.com/help/ImageEn/TIEPolylineLayer.SetPoints.html

(by default, the range is 0 - 1000)


Nigel
Xequte Software
www.imageen.com
Go to Top of Page

xequte

4143 Posts

Posted - Nov 29 2018 :  14:51:41  Show Profile  Reply

Also, have you seen this section for other tips:

https://www.imageen.com/help/ImageEn/TImageEnVect%20vs%20TIELayers.html

And you can copy all objects as layers to a TImageEnView using:

https://www.imageen.com/help/ImageEn/TImageEnVect.CopyAllObjectsTo.html


Nigel
Xequte Software
www.imageen.com
Go to Top of Page

pierrotsc

USA
296 Posts

Posted - Nov 29 2018 :  14:53:41  Show Profile  Reply
The values are in a nexusDB database. they are the coordinates of each square to create a template. So they are the corner coordinates of the box.
Go to Top of Page

pierrotsc

USA
296 Posts

Posted - Nov 29 2018 :  14:59:19  Show Profile  Reply
Yes, the copyallobjects should work but i am trying to convert all the code as it looks like imageenvect is becoming obsolete.
Go to Top of Page

xequte

4143 Posts

Posted - Nov 29 2018 :  15:02:36  Show Profile  Reply
> corner coordinates of the box

Relative to what? The bitmap, the screen or some range?

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

pierrotsc

USA
296 Posts

Posted - Nov 29 2018 :  15:05:29  Show Profile  Reply
Yes, i use bitmap coordinates of the background image. The boxes create a template. then i average the grayscale values inside each box.
Go to Top of Page

xequte

4143 Posts

Posted - Nov 29 2018 :  15:06:56  Show Profile  Reply
Hi

Then it should work if you use:

TIEPolylineLayer(Mainform.ImageEnVect.Layers[ilayer]).SetPoints(iShapePoints, True, iepbBitmap);

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

xequte

4143 Posts

Posted - Nov 29 2018 :  15:12:00  Show Profile  Reply
So your code would be something like:

SetLength(ShapePoints, 4);
ShapePoints[0] := Point(Embeddeddm.nxTable_Tablet.FieldByName('Square00' + IntToStr(1) + '_Left').AsInteger,
                        Embeddeddm.nxTable_Tablet.FieldByName('Square00' + IntToStr(1) + '_Top').AsInteger);
ShapePoints[1] := Point(Embeddeddm.nxTable_Tablet.FieldByName('Square00' + IntToStr(1) + '_Top').AsInteger,
                        Embeddeddm.nxTable_Tablet.FieldByName('Square00' + IntToStr(1) + '_Right').AsInteger);
ShapePoints[2] := Point(Embeddeddm.nxTable_Tablet.FieldByName('Square00' + IntToStr(1) + '_Right').AsInteger,
                        Embeddeddm.nxTable_Tablet.FieldByName('Square00' + IntToStr(1) + '_Bottom').AsInteger);
ShapePoints[3] := Point(Embeddeddm.nxTable_Tablet.FieldByName('Square00' + IntToStr(1) + '_Bottom').AsInteger,
                        Embeddeddm.nxTable_Tablet.FieldByName('Square00' + IntToStr(1) + '_Left').AsInteger);

Mainform.ImageEnVect.LayersAdd(ielkPolyline);

polyLayer := TIEPolylineLayer(Mainform.ImageEnVect.CurrentLayer);
polyLayer.LineWidth := 3;
polyLayer.LineColor := clRed;
polyLayer.SetPoints(ShapePoints, True);

Mainform.ImageEnVect.Update();


Nigel
Xequte Software
www.imageen.com
Go to Top of Page

pierrotsc

USA
296 Posts

Posted - Nov 29 2018 :  16:51:30  Show Profile  Reply
That does not work. it does not give me a square.I get a weird shape. I looked again at the rect function. the rect function gives me 2 points. the top left and the bottom right. these are the coordinates i have. so can i draw a square with only 2 Tpoints using polyline ?
Go to Top of Page

xequte

4143 Posts

Posted - Nov 29 2018 :  17:32:32  Show Profile  Reply
Hi

Naturally, a rectangle requires 4 points, which you can generate from the Top,Left and Bottom,Right coordinates.

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

pierrotsc

USA
296 Posts

Posted - Nov 29 2018 :  18:35:18  Show Profile  Reply
No, this is not what i meant :) rect function only give you 2 points. the top/left (X,Y) that is the first point and the bottom right (X,Y) that is the second point. i have 4 values, they are X,Y for the first point and X,Y for the second point. so you really need only 2 points to draw a rectangle. can polyline do that ?
Go to Top of Page

xequte

4143 Posts

Posted - Nov 29 2018 :  19:49:23  Show Profile  Reply
Hi

A Polyline layer, by nature, requires an array of points (i.e. the polyline layer doesn't know what the shape is). So for a rect (given you have leftX,topY and rightX,bottomY) the four points would be:

leftX,topY
rightX,topY
rightX,bottomY
leftX,bottomY

Otherwise you can use a TIEShapeLayer with a rectangle shape:

ImageEnView1.LayersAdd( iesRectangle, Rect(leftX, topY, rightX, bottomY), clRed, 3, clNone );

https://www.imageen.com/help/ImageEn/TImageEnView.LayersAdd.html

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

pierrotsc

USA
296 Posts

Posted - Nov 30 2018 :  09:32:27  Show Profile  Reply
Thank you Nigel, that works. But before I strat modifying all my code, i would like to know if the following code will still work. What i have is an image with some gray patches. i create boxes in these patches and i average the gray values.
Now that i use layers, i guess i can merge all layers or maybe not before i run the following command. if i merge all layers, do they rasterize ?
This is what i run right now.

Mainform.ImageEnVect.Select(Mainform.ImageEnVect.ObjLeft[i], Mainform.ImageEnVect.ObjTop[i], Mainform.ImageEnVect.ObjLeft[i] + Mainform.ImageEnVect.ObjWidth[i], Mainform.ImageEnVect.ObjTop[i] + Mainform.ImageEnVect.ObjHeight[i], iespReplace);
Mainform.Calibration.Select((i * 100), 0, (i * 100) + 100, 100, iespReplace);
Mainform.Calibration.Proc.Fill(Mainform.ImageEnVect.Proc.CalcAverageRGB());

Best
Pierre
Go to Top of Page

xequte

4143 Posts

Posted - Nov 30 2018 :  19:00:51  Show Profile  Reply
Hi Pierre

It should be something like:

// Select in background layer the area of layer 1
ImageEnView1.LayersCurrent := 0;
ImageEnView1.SelectionBase := iesbClientArea;
lyr1Rect := ImageEnView1.ClientAreaBox;
ImageEnView1.Select( lyr1Rect.Left, lyr1Rect.Top, lyr1Rect.Right, lyr1Rect.Bottom );


Nigel
Xequte Software
www.imageen.com
Go to Top of Page

pierrotsc

USA
296 Posts

Posted - Nov 30 2018 :  19:26:55  Show Profile  Reply
I see. so i would have to go through each layers. That should work. I will try to code something small and see what I get. Thank you Nigel.
Best
Pierre

I may have to look at clientareabox though. if i have 2 rectangular polyline in one layer, how do i differentiate one from another ?
Also, if i merge all, do they all rasterize or could i keep all the polylines in one layer ? that may not be posible though. just thinking as i am typing.
Go to Top of Page

xequte

4143 Posts

Posted - Nov 30 2018 :  19:47:26  Show Profile  Reply
> I may have to look at clientareabox though. if i have 2 rectangular polyline
> in one layer, how do i differentiate one from another ?

ClientAreaBox returns the area of the whole layer (rectangular area that fits all polylines within.

> Also, if i merge all, do they all rasterize or could i keep all the polylines
> in one layer ?

Two polyline layers cannot be merged into one polyline layer. As a polyline layer supports only one "line"

Merging converts the polyline layer into a bitmap.



Nigel
Xequte Software
www.imageen.com
Go to Top of Page

pierrotsc

USA
296 Posts

Posted - Nov 30 2018 :  19:51:31  Show Profile  Reply
ok..will play with it tomorrow. thanks for the code sample...
something i noticed when i created all the polyline layers is sometimes when i click on one layer in the thumbnail of imageenmview, i get 2 selected. for example layer 2 and 5 get selected when i click on layer 2. not sure what is happening.
will try a clean project from scratch in the morning.
Go to Top of Page

xequte

4143 Posts

Posted - Nov 30 2018 :  20:05:38  Show Profile  Reply
Try to create a sequence to reproduce the bug and let me know the steps.



Nigel
Xequte Software
www.imageen.com
Go to Top of Page

pierrotsc

USA
296 Posts

Posted - Nov 30 2018 :  21:00:03  Show Profile  Reply
i will. i think i need to start from scratch first to see if i can reproduce it. right now, i am mixing vectors and polylines.
Best
Go to Top of Page

pierrotsc

USA
296 Posts

Posted - Dec 01 2018 :  13:43:45  Show Profile  Reply
Ok, Nigel, i think i am getting there but it is not working. i modified the layers demo but in a nutshell, this is what i am doing. i am loading an image, then i press a button that adds 3 polyline layers. They are 100x100 squares. Then i am trying to select the layer 1 size, and average the points of the background within this selection. nothing is happening. here's the simple code
ImageEnView1.LayersAdd(iesRectangle, Rect(5, 5, 100, 100), clRed, 3, clNone);
ImageEnView1.Update();
ImageEnView1.LayersAdd(iesRectangle, Rect(105, 5, 205, 100), clRed, 3, clNone);
ImageEnView1.Update();
ImageEnView1.LayersAdd(iesRectangle, Rect(210, 5, 310, 100), clRed, 3, clNone);
ImageEnView1.Update();

ImageEnView1.Deselect;
ImageEnView1.LayersCurrent := 0;
ImageEnView1.SelectionBase := iesbClientArea;
lyr1Rect := ImageEnView1.Layers[1].ClientAreaBox;
ImageEnView1.Select(lyr1Rect.Left, lyr1Rect.Top, lyr1Rect.Right, lyr1Rect.Bottom);
ImageEnView1.Update();
ImageEnView1.Proc.Fill(ImageEnView1.Proc.CalcAverageRGB());
ImageEnView1.Update();

Do you see what the issue is ?
Thanks
Best
Pierre
Go to Top of Page
Page: of 2 Previous Topic Topic Next Topic  
Next Page
 New Topic  Reply to Topic
 Printer Friendly
Jump To: