Example #1
0
def data(dataFile, nPts):
    ptAnal = file(dataFile)
    ptLine = ptAnal.readline()
    ##print "ptLine: "+ptLine

    iPt = -1
    loc = [None for i in range(nPts)]  # Fiducial center coordinates in pixels.
    target = [None for i in range(nPts)]  # Target world coordinates in meters.
    offset = [None for i in range(nPts)]  # World coordinate error in meters.

    while ptLine != "" and ptLine[:5] != "total":
        # Chop the newline.
        ptLine = ptLine.strip('\n')
        ##print "ptLine = "+ptLine

        m1 = reAnalysisSection.match(ptLine)
        m2 = reAnalysisData.match(ptLine)
        if m1 != None:

            # Section headers.
            iPt = iPt + 1
            if iPt > nPts - 1:
                print "\nExtra points?\n"
                break
            target[iPt] = (float(m1.group(1)), float(m1.group(2)))
            blobCtrs = [[None, None], [None, None]]
            offset[iPt] = [None, None]

        elif m2 != None:
            ##print "m2.groups() "+str(m2.groups())

            # Coordinates.
            if m2.group(1) != "w" and m2.group(3) == '':

                # Stash mean_[ab][xy] blob center coordinates.
                blobCtrs[m2.group(1) == 'b'][m2.group(2) == 'y'] = float(
                    m2.group(4))
                ##print "blobCtrs "+str(blobCtrs)

            elif m2.group(3) == '_offset':

                if m2.group(2) == 'x':
                    # mean_wx_offset - We have [ab][xy] coords, record the center.
                    ##print "iPt "+str(iPt)+", blobCtrs "+str(blobCtrs)
                    loc[iPt] = geom.ptBlend(*blobCtrs)
                    pass

                # Stash mean_w[xy]_offset error coords.
                offset[iPt][m2.group(2) == 'y'] = float(m2.group(4))

                pass
            pass

        ptLine = ptAnal.readline()
        pass
    return (loc, target, offset)
Example #2
0
def data(dataFile, nPts):
    ptAnal = file(dataFile)
    ptLine = ptAnal.readline()
    ##print "ptLine: "+ptLine

    iPt = -1
    loc = [None for i in range(nPts)]    # Fiducial center coordinates in pixels.
    target = [None for i in range(nPts)] # Target world coordinates in meters.
    offset = [None for i in range(nPts)] # World coordinate error in meters.

    while ptLine != "" and ptLine[:5] != "total":
        # Chop the newline.
        ptLine = ptLine.strip('\n')
        ##print "ptLine = "+ptLine

        m1 = reAnalysisSection.match(ptLine)
        m2 = reAnalysisData.match(ptLine)
        if m1 != None:

            # Section headers.
            iPt = iPt + 1
            if iPt > nPts-1:
                print "\nExtra points?\n"
                break
            target[iPt] = (float(m1.group(1)), float(m1.group(2)))
            blobCtrs = [[None, None], [None, None]]
            offset[iPt] = [None, None]

        elif m2 != None:
            ##print "m2.groups() "+str(m2.groups())

            # Coordinates.
            if m2.group(1) != "w" and m2.group(3) == '':

                # Stash mean_[ab][xy] blob center coordinates.
                blobCtrs[m2.group(1) == 'b'][m2.group(2) == 'y'] = float(m2.group(4))
                ##print "blobCtrs "+str(blobCtrs)

            elif m2.group(3) == '_offset':

                if m2.group(2) == 'x':
                    # mean_wx_offset - We have [ab][xy] coords, record the center.
                    ##print "iPt "+str(iPt)+", blobCtrs "+str(blobCtrs)
                    loc[iPt] = geom.ptBlend(*blobCtrs)
                    pass

                # Stash mean_w[xy]_offset error coords.
                offset[iPt][m2.group(2) == 'y'] = float(m2.group(4))

                pass
            pass

        ptLine = ptAnal.readline()
        pass
    return (loc, target, offset)
Example #3
0
    gridLine = gridLine.strip('\n')
    ##print "gridLine = "+gridLine

    m1 = reFrameData_line.match(gridLine)
    if m1 == None:
        # Everything else streams straight through.
        print gridLine
    else:
        # Frame data.
        lineHead = m1.group(1)
        data = [float(f) for f in m1.groups()[1:]]

        # XXX Horrid Hack Warning - We need right-handed coordinates,
        # but the image Y coordinate goes down from 0 at the top.
        # Negate it internally.
        pixLoc = geom.ptBlend((data[0], -data[1]), (data[2], -data[3]))
        wcLoc = (data[4], data[5])
        wAng = data[6]

        # Find the quadrant by looking at the center edges of the triangles.
        # We can actually blend linearly past the outer edges...
        for iTri in range(nPts-1):

            # Get the barycentric coords of the image point.
            bcs = triangles[iTri].baryCoords(pixLoc)
            if bcs[1] >= 0.0 and bcs[2]  >= 0.0:

                # This is the triangle containing this image point.
                newLoc = geom.ptOffset(wcLoc, triangles[iTri].errorBlend(bcs))
                ##print "pixLoc %s, iTri %d, bcs %s"%(pixLoc, iTri, bcs)
                ##print "triangles[%d] %s"%(iTri, triangles[iTri])