IMAQ ROI rotated rectangle ANGLE calculation

I am using IMAQ Construct ROI to construct a rotated Rectangle ROI. The resulting contours give coordinated of the top and bottom points of the rectangle before rotation and a fifth number indicate the angle. But can anyone tell me how can i calculate the angle in degree from this value, so that i can calculate the exact points of the rotated rectangle?
Is there any other method to find the actual coordinates of the 4 edges of the rotated rectangle? My intention is to find some points in between these edge points, which i can calculated with simple trigonometry by knowing the angle of rotation. 
Thank you in advance,
Mathew

The angle of rotation is about the center of the rectangle.  I think the angle is already degrees.  If you calculate the center of the rectangle and subtract it from the corners, you have the coordinates to be rotated.  The easiest way I have found to rotate coordinates is to convert them to a complex number, multiply the complex number by the angle IN RADIANS, then convert back to x, y.  Add the center of the rectangle back to the rotated coordinates and you are done.
Bruce
Bruce Ammons
Ammons Engineering

Similar Messages

  • Why rotated rectangle tool can't draw rotated ROI on image?

    I want to use the tool window to draw a rotated rectangle on image, but each time, it seems only draw a rectangle, it can't rotate. Don't know why?
    In Vision Assitant, if I use rotated rectangle tool, it will show like this:
    Using the cross lines in rectangle, I can rotate my ROI, it is OK.
    Run the sample code: C:\Users\Public\Documents\National Instruments\CVI\samples\Vision\2. Functions\Geometric Matching, change     imaqShowToolWindow (FALSE);
    to  imaqShowToolWindow (TRUE); 
    on line 93#. Compile then run. Seems I also can't rotate my ROI, don't know why?
    Please show me? Thank you. 

    Hi,
    You cannot perform action on an overlay. In order to achieve what you want to do, I suggest you to use the ROI property in an image property node. Then just pass your ROI coordinates, the ROI will be updated automatically whenever your coordinates changes. You can drag a ROI this is impossible with an overlay.
    Regards

  • How to change IMAQ ROI color while adjusting handles

    I have an application where a user must draw a rotated rectangle box around an object.  I'm using an color overlay to highlight the box, but when the user is adjusting the roi handles, the box color becomes gray.  The images i'm working with are gray scale images and it makes it difficult to adjust the rotated rectangle box when they are virtually the same color.  Is there any way to change the color of the roi while it is being adjusted?
    Thanks,
    Pete

    Hi pbartko2,
    You can change the color of the ROI while it is in place, but there are no settings to change the color while the ROI is being moved. This will always be the default color of grey. You could post this as a suggestion on our Idea Exchange. Ideas voted up on the Idea Exchange are taken into consideration for previous releases. Unfortunately at the moment there isn't an easy way around this issue.
    Regards,
    Emily C
    Applications Engineer
    National Instruments

  • How to obtain corner points of rotated rectangle?

    Am drawing a rectangle, then using an Affine Transform to rotate the angle. After rotating and drawing the rectangle, I need to obtain the 4 corner points of the rectangle. This is (psuedocode) for what I've tried:
    Rectangle r = new Rectangle (x, y, width, height);
    AffineTransform at = new AffineTransform();
    at.rotate (angleInDegrees*Math.PI/180);
    Shape s = at.createTransformedShape (r);
    PathIterator pi = s.getPathIterator(at);
    while (pi.isDone() == false)
    fetchCornerPoint (pi);
    pi.next();
    g2.draw(s);
    The shape is being correctly drawn on the screen, so I know the transofmr is working. But the path appears to contain the 4 corner points of the rectangle prior to rotation, not the 4 corner points after the rotation.
    It's got to be a "doh moment", but I can't see it.

    I notice you call getPathIterator on 's', which is already transformed. I have not verified this, but maybe you should call getPathIterator(at) on the original shape ('r')?

  • Can a component be rotated an angle?

    can a component be rotated an angle?

    Generally, no. You'd have to extend the existing component to support rotation.

  • Coordinates of rotated rectangle

    I have a rectangle that is rotated by a script.
    When outputting the geometric bounds of the rectangle, I get the coordinates of the outside rectangle that is aligned horizontally.
    How can I get the actual coordinates of the rotated rectangle?

    Here's a basic example of using resolve()
    Note: This will only work if your object is (directly) on a page. Generalizing it to work whether it's on a page or a spread is very hard, and I don't have the time right now to break my head over this...
    var coord = getPointCoordinates(app.selection[0],AnchorPoint.TOP_LEFT_ANCHOR);
    alert(coord);
    function getPointCoordinates(obj,anchorPoint){
        var oC = obj.resolve(anchorPoint,CoordinateSpaces.SPREAD_COORDINATES);
        var page = obj.parentPage;
        var pC = page.resolve(anchorPoint,CoordinateSpaces.SPREAD_COORDINATES);
        return [oC[0][0]-pC[0][0],oC[0][1]-pC[0][1]];
    HTH
    Harbs

  • Problem rotating rectangle (selecting corners) after creating with rectangle tool in illustrator

    I'm using the latest CC version of Illustrator. When I draw a rectangle using the rectangle tool, I no longer seem to be able to select the corners to resize the rectangle nor does the cursor turn to a rotate icon when I put the mouse just outside the corner. I know that Ai CC treats rectangles differently now, with the live rectangles and the rounded corner options, and the transform box opening automatically. What I'm wondering, and hoping isn't the case, is whether this is this at the expense of being able to go right in and resize using the just the mouse? I know that there is the  "Object > Shape > Expand" option, but having to do that for every time I draw a rectangle is time-consuming and adds and extra step that was unnecessary before. I saw a tutorial on Lynda where the instructor drew a live rectangle in CC AND was still able to resize it by grabbing the corner "handle". Anyone know if this is just a setting I need to turn on or something similarly easy, or is it a case of Adobe inadvertently making the workflow longer when trying to make it easier? And yes, I have "show bounding box" selected under VIEW.

    MOD indi-go girl,
    I am afraid you have come across the Live Rectangle bug which is limited to the MAC versions starting with 10.7 and 10.8, but not 10.9 (Mavericks) or 10.10 (Yosemite). Hopefully, the bug will be fixed soon.
    So a switch to Mavericks or Yosemite with a reinstallation might be the way to solve it here and now.
    To get round it in each case, it is possible to Expand the Live Rectangles to get normal old fashioned rectangles, or to Pathfinder>Unite, or to use the Scale Tool or the Free Transform Tool.
    A more permanent way round that is to create normal old fashioned rectangles, after running the free script created by Pawel, see this thread with download link:
    https://forums.adobe.com/thread/1587587

  • Moving a rotated rectangle [AS CS5]

    I have a script that moves items from the top half of each page to a new page, essentially like this:
    set mybounds to visible bounds of myitem
    tell myitem to move to myPage1
    tell myitem to move to {item 2 of mybounds, item 1 of mybounds}
    Works great except when the item is a rectangle with rotation applied. In that case, getting the bounds of the rotated item returns the bounds of the item unrotated, but when moving the item, the move to coordinates correspond to the rotated item. (or something like that, I haven't worked out exactly what is going on — rotated items get moved to the wrong spot).
    Can anyone suggest and alternative method of moving to a new page that works for rotated items?

    Im having no problems with rotated objects… Moving to a new containing page will forget the visible bounds and the object will default to 0,0 but I can just re-apply the bounds back to position…
    tell application "Adobe InDesign CS2"
         tell the active document
              tell page 1
                   set ThisBox to the first rectangle
                   set BoxBounds to visible bounds of ThisBox
              end tell
              move ThisBox to page 2
              set visible bounds of ThisBox to BoxBounds
         end tell
    end tell

  • Imaq learn pattern 2 angle

    hello,
    i need advice about how the imaq learn pattern 2 computes the angle.
    the problem i got is following: we use the imaq learn pattern 2 to get compare the angle between 5 pictures form a video. the first one is the reference pic (=0° angle). everything seems to work fine, but the angle changes with the size of the template and where it is cut out from.
    i thought that this may be a problem with the pic. a lot of information in the picture stays the same only a little is different (just take a look at the attached pictures). can anyone please tell me how the imaq learn pattern calculates the angel, if it is the tool to go for to solve the problem, or should i try to get the angle from somewhere else?
    Same picture - different size= different angle. Same picture - cut out a couple of pixels away = different ange?!?
    thanx a lot
    martin

    Dear Sir,
    I tried a match pattern 2 after the IMAQ Learn pattern 2 and could match both images (Angle 0)
    Which version of LV and Vision do you use?
    Do you also compute the angle via the Match Pattern 2.vi?
    Regards
    Ken
    Attachments:
    Match Pattern.vi ‏29 KB
    Match.jpg ‏58 KB

  • CompareTo for two boxes(rotated rectangles)

    I basically have a bunch of cubes in two point perspective that need to be drawn to the screen. I have all of the points calculated in an array for each cube, but I only need the first four points(bottom of the box) to actually tell if its front or not. The bottom of the cubes never overlap thanks to collision detection. What I am trying to do is create a compareTo method in the class that will always put the box that is in front later in an array, so it will be drawn to the screen after the one behind it. All of the cubes are below the horizon line
    [Program full screen|http://img.photobucket.com/albums/v148/jakster4u/1-2.jpg]
    [Example overlapping|http://img.photobucket.com/albums/v148/jakster4u/3.jpg]
    This is what I have so far but it only works some of the time and I was hoping their was a more elegant way than adding more if statements.
    The point at 0 in the array would be the lower point of the bottom, 1 the right point of the bottom, 2 the left point of the bottom, 3 the upper point of the bottom.
    public int compareTo(Object that)
             if(that instanceof IsoBox)
                  //same point
                  if(this.points[0][0]==((IsoBox)that).points[0][0] && this.points[0][1]==((IsoBox)that).points[0][1])
                       return 0;
                  //left of point less than y
                  if(this.points[1][0]<((IsoBox)that).points[0][0] && this.points[1][1]>((IsoBox)that).points[2][1])
                       return 1;
                  //right of point and less than y
                  if(this.points[1][0]>((IsoBox)that).points[0][0] && this.points[2][1]>((IsoBox)that).points[1][1])
                       return 1;     
                  return -1;
             return -1;
        } [Base that needs comparing|http://mad.printf.net/Perspective/PerspectiveDiagrams/PerspectiveDiagram2.jpg]
    I'm doing this for fun so any help or suggestions would be welcome.
    Also all of the boxes are placed randomly, with random sizes using collision detection at the start. A player can move the clear box around the other cubes, and fire bullets off the of the other cubes.
    [Bullets!|http://img.photobucket.com/albums/v148/jakster4u/2.jpg]

    Looking at your examples it appears to me that your code doesn't implement the concept of depth--Z axis or sometimes referred to as "point of view". you will need to do so to reliably get overlap consistency.

  • IMAQ Overlay Rectangle problem

    Hello,
    I am trying to Overlay Roteted rectangle and fill it inside.
    I can't do it by IMAQ Overlay Rectangle - it doesn't accept rotations
    So I onvert Restangle to ROI and I use IMAQ Overlay ROI but now I dont have fill option
    Do You know  way around this??
    Solved!
    Go to Solution.

    Dear Pawhan!
    As far as i'm aware, you can have Rotated Rectangle overlays in Vision Assistant, so you can set one up in VA and create a LabVIEW VI from there. If you want to stick with LV Vision, try this code:
    Please tell me if this works for you.
    Best regards:
    Andrew Valko
    NI Hungary
    Andrew Valko
    National Instruments Hungary
    Attachments:
    Rotated Rectangle.vi ‏20 KB

  • Rotate object to match path or another object

    How do I rotate an object to either make one of its sides match another object, or become totally horizontal/vertical.
    Let's say I want to rotate rectangle A in the picture so that its red line has the same angle as the horizontal path B, or the same angle as the blue line in rectangle C. Is there an easy way to do this?

    (This is one of those ridiculously elementary things that mystified me too, for longer than I would've liked, but I finally figured it out.)
    Like Carlos depicts in his post above, the key is having Smart Guides on, and then setting the rotation point by single-clicking somewhere once you have the Rotate Tool seletected.
    Snap the two shapes in question together on the same point. Also, set the rotation point at that same point.
    NOW, referring to the shape who's rotation to you need to modify: click and drag (making sure to always snap) on one of the two segments, which is connected by the point where you snapped the rotation point to and rotate it until your cursor contacts the shape who's rotation is already correct. Instead of grabbing a segment, you can also grab another point of the same shape.
    I wish Wade would've included that in his video - it's hard to explain.
    Once you set the rotation point, you can click anywhere and cause the selected object to "pivot" that your designated rotation point. Using a point on the rotation-needing shape it especially effective. Illie's snaps aren't the best - using points is the surest way to snap correctly.

  • Vision:ROIの設定

    CCDの映像をIMAQで取得し、画像処理を行うプロセスをVisionAssistantで作成し、LabView8.0のブロックダイアグラムに変換しました。
    Assistantからの変換だと、snap(静止画処理)になってしまうようなので、そこからvi、ループなどを変更しgrab(連続画処理)に変えました。
    <添付ファイル vison.vi>
    3つ質問させてください。
    1.このようにして作ったVision関連のVIのうち、ROIを設定しているvi、ノードはどれにあたるのでしょうか?
    2.IMAQで取得している映像は、フロントパネル上に表示され、その横にツールパレットが配置されています。この四角で囲うツールでプログラム中でROIを設定しなおすことは可能でしょうか?さらに、パターンマッチングに用いるパターン画像(png)もフロントパネル上から設定できませんでしょうか?
    3.フロントパネル上のIMAQ映像にパターンマッチングの結果(マッチした赤色の四角)を表示させることはできないでしょうか?
    よろしくお願いします。
    名古屋大学 佐藤
    添付:
    vision.vi ‏74 KB

    平素より、弊社製品をお使いいただきありがとうございます。
    日本ナショナルインスツルメンツ株式会社 柿部と申します。
    1.ROIの設定端子に関して
    こちらのプログラムですと、テンプレート画像をサーチする範囲をROIとして設定しています。
    具体的には、「IMAQ Match Color Pattern.vi」関数の「Optical Rectangle」端子でROIを設定しております。
    2.テンプレート画像設定方法に関して
    こちらは、行うことは可能です。
    「IMAQ Setup Learn Color pattern.vi」関数と「「IMAQ Learn Color pattern.vi」」関数を使用することにより、フロントパネルで指定した画像をテンプレート画像にすることができます。
    こちらの具体的な使い方は、C:\Program Files\National Instruments\LabVIEW 8.0\examples\Vision\2. Functions\Color Pattern Matching\Color Pattern Matching Example.llb を参照ください。
    上記プログラムで、テンプレート画像を学習させている箇所のスクリーンショット「Learning Template.jpg」を添付しましたので、ご参考にしていただけますと幸いです。
    3.マッチした箇所の明示方法に関して
    こちらも可能でございます。
    「IMAQ Match Color Pattern.vi」でマッチした箇所の座標がわかるので、その座標部分に赤い四角を描くことで実装できます。
    具体的な方法は、上記プログラムの「Overlay Matches Position Color.vi」のサブVIにて行っています。
    実際の箇所をスクリーンショット「Pattern Match Location.jpg」にて添付しましたので、ご参考にしていただけますと幸いです。
    以上、ご検討いただけますようお願い申し上げます。
    今後とも、宜しくお願い致します。
    失礼致します。
    添付:
    Images.zip ‏138 KB

  • Probleme rotation coordinate

    Hi everybody,
    I`m going to try to be clear, but I have juste one problem with the coordinate about a rotate rectangle.
    So, first I have this data, and when I put in Excel I have a right rectangle.
    SO now I know that I have to modify the data with the rotation, It`s what I did.
    It worked very well, I tried with graph and to modify the degree of rotation it was perfect I had good rotated rectangle.
    My next step and final step was just to put the coordinate on excel and reproduce the same rectangle on one graph in Excel.
    And it`s there that I met the problem.
    I have no Idea why, and I don`t see what to change to fix that......
    I now that just one rotation of 90 degree it`s enough to correct the position but where can I change something?
    If somenody know something about that or have the solution, you`re welcome.
    Sorry about this big post but I think is more clear with picture than more text.
    Thank you again for your answers (in advance)
    Maxime
    Solved!
    Go to Solution.

    Direction of rotation?
    In Excel, it looks like a postive rotation causes it to rotate clockwise.
    I didn't dig into your math, but in a lot of programs (like Autocad), a positive rotation angle is counter clockwise following the right hand rule.  Where 0 is the + X axis and a line from there rotates towards the + Y axis with a + angle.

  • On Pie chart rotation - the labels disappear

    I am using followig to rotate a pie chart:
    <mx:Rotate id="rotate" angleFrom="{angle-90}"
    angleTo="{angle}"
    target="{myChart}"/>
    private function rotateImage():void {
    rotate.end();
    angle += 90;
    rotate.play();
    <mx:PieChart id="myChart" dragEnabled="true"
    dragComplete="rotateImage()">
    So, when a user tries to drag the pie chart, the chart
    rotates. The
    chart rotates fine but the labels disappear? why would this
    happen and
    any solution to this.
    Also, I would like to use some other event for rotation
    instead of
    dragComplet. I would like to do it when user clicks left
    mouse
    button+moves the mouse (both on the outside of the chart)
    Any suggetions?
    Thanks in advance.

    Are your fonts embedded? Rotating non-embedded fonts makes
    text disappear during rotation.

Maybe you are looking for