OriginX, OriginY, RotationX, RotationY

Hello Chris,
How are you doing?
I need to set the Origin X, Y and Rotation X, Y on one image
With my old AX Tools use this code, e.g.:

axCVimage.OriginX = 0;
axCVimage.OriginY = 0;
axCVimage3.RotationX = 0;
axCVimage3.RotationY = 0;

How can I do the same thing with the new tools?
We are using Forms, not Wpf (I know we have a reference for that on Wpf)
Thank you very much

Hi @George,

what you are looking for ist the CoordinateSystem property of the Stemmer.Cvb.Image object. You can reset rotation and origin by just settings an identity matrix (AffineMatrix2D.Identity). If you want to set a rotation, you’ll need to do this by creating the coordinate system’s matrix accordingly, e.g.

img.CoordinateSystem = new AffineMatrix2D(
                             new Matrix2D(Angle.FromDegrees(45.0)), 
                             Point2Dd.Empty); 

As this is on the image object, not on the display, this is completely independent of whether you are working with Forms or WPF.

2 Likes

Thank you illusive!
This is something that I will have never discover without help!
Thank you very much

Illusive, so I have now my Image Origin and rotation ready, I need now adding a Label on my Display, a label coming from the Image. I am using this to add labels:

Display.Overlays.Add(new DisplayLabel("Label1", true, Color.Red, Point2D));

But Stemmer.cvb.Image do not have the reference to add labels and I can not convert my Image Origin point (Stemmer.Cvb.Point2Dd) to System.Drawing.Point (Point2D needed to Add a Display Label).
So my question is How can I add a Label from my Image?
Thank you very much guys!

Hi @George,

you transform a point coordinate (Point2D in your case) with a matrix (in your case the affine matrix you are using for the coordinate system, let’s call it cs) the way you usually would in mathematics: By multiplying them:

var pt = cs * Point2D;

Please note that it’s pointless to search for a possibility to add labels on the image object: Labels are entirely living on a display, not on an image.

The conversion from Point2Dd to System.Drawing.Point is done through an extension method (ToPoint) found in the namespace Stemmer.Cvb.Extensions.