Adding to a list of points to create an AOI
(Originally posted by ytsejamr on 9/23/2005)
I'm trying to create an AOI based on a horizontal measurement line trace. I have the user create the trace, then I want to create an AOI that has that trace as the top of the "box", then the other 3 sides of the AOI are straight lines. I'm having a tough time explaining this, but basically the resulting AOI is a box with the top of the box being the line trace.
I'm having a problem adding the box corners to the list of points generated from the line trace.
I'm not sure if I need to add the box corners before the line trace points or after, or both. The problem is that the AOI is not being generated correctly. It seems like it's going far off of the image.
Here's the code:
Dim numPts As Integer, NumMeas As Integer, profPts() As PointAPI, aoiPts() As POINTAPI
Dim workingDoc As Integer, i As Integer, aoiString As String
ret = IpMeasShow(MEAS_SHOWADVANCED)
ret = IpMeasTool(MEAS_TRACE)
ret = IpMacroStop("Please trace the profile" & Chr(13) & "Select Continue when finished" , 0)
'Get number of lines
ret = IpMeasGet(GETNUMMEAS, 0, NumMeas)
'Exit if there is more than one measurement
If NumMeas > 1 Then
ret = IpMacroStop("Please only create one measurement", MS_MODAL + MS_STOP)
'Get the points that represent the line
ret = IpMeasGet(GETNUMPTS,0, numPts)
ReDim profPts(numPts -1)
ret = IpMeasGet(GETPOINTS, 0, profPts(0))
'Get the width/height information of the image
Dim dInfo As IPDOCINFO
ret = IpDocGet(GETDOCINFO, DOCSEL_ACTIVE, dInfo)
'Create a copy of the image to work with
workingDoc = IpWsDuplicate()
'Fill the new image in black
ret = IpWsFill(0, 3, 0)
'Create an AOI using the line trace as the top and extending all the way to the bottom of the image
For i = 0 To numPts -1
aoiString = aoiString & profPts(i).x & " " & profPts(i).y & " "
aoiString = aoiString & profPts(0).x & " " & dInfo.Height-1 & " "
aoiString = aoiString & profPts(numPts-1).x & " " & dInfo.Height-1 & " "
aoiString = aoiString & profPts(0).x & " " & profPts(0).y
Dim newPts As Integer
newPts = numPts + 3
ret = IpListPts(Pts(0), aoiString)
ret = IpAoiCreateIrregular(Pts(0), newPts)
Thanks for any help,