03-12-2013 09:15 AM
Hi,
I have a rectangle (which is a search zone in my area of tracking a fly) for which I know the ROI/Coordinates, which is 4 points (4 Integers) and a rotation value (1 Integer too). You can see it on the following screenshot :
I'm drawing in a XY graph, the way the fly walked. However, I would like to add that rectangle to be able to know when the fly was in that area or not.
My problem is that I can't plot a Rotated Rectangle in a XY graph from these Rectangle Values as I only have 5 values, which is enough to plot a rectangle, but not interperted but the XY graph, for which I need like 1000 points (X and Y).
How to create those XY for a rotated rectangle? Or any other ideas?
Thank you,
Sébastien.
Solved! Go to Solution.
03-12-2013 11:09 AM
Here's one way (8.0). I'll leave it to you to adapt it to different center points, etc.
03-12-2013 12:05 PM
Thank you very much, this is really close from what I need.
The problem is that, here are the values extracted by LabView when it draws a rectangle. It's the upper right corner and downer left corner and the rotation, respectivly like this :
------------*1
| |
*2------------
X2
Y1
X1
Y2
And the rotation angle.
I don't exactly see how to enter it in your subVI.
As it's end of the day for me, I prefer to post now, but I may investigate tomorrow morning, maybe it's easy to do it.
Thank you, Kudos for you 😉
Sébastien.
03-12-2013 12:50 PM
The VI I posted shows the basic concept, but it will certainly need adaptations. In the VIs, the points of the rectangle are a constant in the BD. Like I said before, you will need to adapt it to have a different center point and possibly other things as well.
03-13-2013 05:24 AM
Well, I'm working since 1h30 on it, and I still don't get it.
Any other help welcomed.
Thank you,
Sébastien.
03-13-2013 07:12 AM
Post what you have so that there's a common base.
03-13-2013 07:25 AM
Hi,
Here is a VI I did as the main one is not my property.
1st you select a video, you define a rotated rectangle area which will be saved in a XML.
Then I would like that area to be drawned keeping the good coordinates, because I add other information, like the way a fly walked which is an array of X&Y.
Here is the VI.
Thank you !
Regards,
Sébastien
PS : First run may got an error, missing XML file, just do it once then run again and it should be ok.
03-13-2013 07:42 AM
I don't have the vision module installed, so I can't run the code. In any case, that doesn't show the rotation code at all, so I'm not sure where you would expect it to come in.
03-13-2013 08:14 AM
Sorry.
Here is a new VI with more informations and without any LabView Vision part.
Here is how the rectangle setted in default value looks like in my Vision pictures :
I joined the new VI.
Thank you,
Sébastien
03-13-2013 09:35 AM
No more time for this. Here's information about converting cartesian to polar coordinates - http://en.wikipedia.org/wiki/Polar_coordinate_system#Converting_between_polar_and_Cartesian_coordina...
You can use the center of the rectangle as the center, get the four corners relative to that, convert them to polar, use the rotation to change the polar values and then convert back to cartesian to draw them on the graph.
If you're asking how the drawing was done, I did it by having the four corners of the rectangle as a plot and then adding the first point to them as well to close the curve.