示例#1
0
def generateReport(cself, filename="report.pdf", showOnScreen=True, graph=None, removedOutlierCorners=None):
    #plotter
    plotter = PlotCollection.PlotCollection("Calibration report")

    figs = list()    
    #plot graph
    if graph is not None:
        f=pl.figure(1001)
        title="Inter-camera observations graph (edge weight=#mutual obs.)";
        graph.plotGraphPylab(fno=f.number, noShow=True, title=title)
        plotter.add_figure("Obs. graph", f)
        figs.append(f)
        
    #rig geometry
    if len(cself.cameras)>1:
        f=pl.figure(1002)
        title="camera system"
        plotCameraRig(cself.baselines, fno=f.number, clearFigure=False, title=title)
        plotter.add_figure(title, f)
        figs.append(f)
        
    #plot for each camera
    for cidx, cam in enumerate(cself.cameras):
        if cself.numCamsReplaced > 0 and cidx < len(cself.cameras)-cself.numCamsReplaced:
            continue
        f = pl.figure(cidx*10+1)
        title="cam{0}: polar error".format(cidx)
        plotPolarError(cself, cidx, fno=f.number, noShow=True, title=title)
        plotter.add_figure(title, f)
        figs.append(f)
        f = pl.figure(cidx*10+2)
        title="cam{0}: azimutal error".format(cidx)
        plotAzumithalError(cself, cidx, fno=f.number, noShow=True, title=title)
        plotter.add_figure(title, f)
        figs.append(f)
        f = pl.figure(cidx*10+3)
        title="cam{0}: reprojection errors".format(cidx)
        plotAllReprojectionErrors(cself, cidx, fno=f.number, noShow=True, title=title)
        plotter.add_figure(title, f)
        figs.append(f)
    
    #plot all removed outlier corners
    if removedOutlierCorners is not None:
        if len(removedOutlierCorners) > 0:
            f=pl.figure(1003)
            title="Location of removed outlier corners"
            plotOutlierCorners(cself, removedOutlierCorners, fno=f.number, title=title)
            plotter.add_figure("Outlier corners", f)
            figs.append(f)
            
    #save to pdf
    pdf=PdfPages(filename)
    for fig in figs:
        pdf.savefig(fig)
    pdf.close()
    print "Report written to: {0}".format(filename)
    
    if showOnScreen:
        plotter.show()  
示例#2
0
def generateReport(cself, filename="report.pdf", showOnScreen=True):
    figs = list()
    plotter = PlotCollection.PlotCollection("Calibration report")

    #plot imu stuff (if we have imus)
    for iidx, imu in enumerate(cself.ImuList):
        f = pl.figure(3010 + iidx)
        plots.plotAngularVelocities(cself, iidx, fno=f.number, noShow=True)
        plotter.add_figure("imu{0}: angular velocities".format(iidx), f)
        figs.append(f)
        f = pl.figure(3020 + iidx)
        plots.plotAccelerations(cself, iidx, fno=f.number, noShow=True)
        plotter.add_figure("imu{0}: accelerations".format(iidx), f)
        figs.append(f)
        f = pl.figure(3030 + iidx)
        plots.plotAccelBias(cself, iidx, fno=f.number, noShow=True)
        plotter.add_figure("imu{0}: accelerometer bias".format(iidx), f)
        figs.append(f)
        f = pl.figure(3040 + iidx)
        plots.plotAngularVelocityBias(cself, iidx, fno=f.number, noShow=True)
        plotter.add_figure("imu{0}: gyro bias".format(iidx), f)
        figs.append(f)
        f = pl.figure(3050 + iidx)
        plots.plotGyroError(cself, iidx, fno=f.number, noShow=True)
        plotter.add_figure("imu{0}: angular velocity error".format(iidx), f)
        figs.append(f)
        f = pl.figure(3060 + iidx)
        plots.plotAccelError(cself, iidx, fno=f.number, noShow=True)
        plotter.add_figure("imu{0}: acceleration error".format(iidx), f)
        figs.append(f)

    #plot cam stuff
    if cself.CameraChain:
        for cidx, cam in enumerate(cself.CameraChain.camList):
            f = pl.figure(4000 + cidx)
            title = "cam{0}: reprojection errors".format(cidx)
            plots.plotReprojectionScatter(cself,
                                          cidx,
                                          fno=f.number,
                                          noShow=True,
                                          title=title)
            plotter.add_figure(title, f)
            figs.append(f)

    #write to pdf
    pdf = PdfPages(filename)
    for fig in figs:
        pdf.savefig(fig)
    pdf.close()

    if showOnScreen:
        plotter.show()
示例#3
0
def generateReport(cself, filename="report.pdf", showOnScreen=True):
    figs = list()
    plotter = PlotCollection.PlotCollection("Calibration report")
    offset = 3010

    #Output calibration results in text form.
    sstream = StringIO.StringIO()
    printResultTxt(cself, sstream)

    text = [line for line in StringIO.StringIO(sstream.getvalue())]
    linesPerPage = 40

    while True:
        fig = pl.figure(offset)
        offset += 1

        left, width = .05, 1.
        bottom, height = -.05, 1.
        right = left + width
        top = bottom + height

        ax = fig.add_axes([.0, .0, 1., 1.])
        # axes coordinates are 0,0 is bottom left and 1,1 is upper right
        p = patches.Rectangle((left, bottom), width, height, fill=False, transform=ax.transAxes, \
                                 clip_on=False, edgecolor="none")
        ax.add_patch(p)
        pl.axis('off')

        printText = lambda t: ax.text(left, top, t, fontsize=8, \
                                     horizontalalignment='left', verticalalignment='top',\
                                     transform=ax.transAxes)

        if len(text) > linesPerPage:
            printText("".join(text[0:linesPerPage]))
            figs.append(fig)
            text = text[linesPerPage:]
        else:
            printText("".join(text[0:]))
            figs.append(fig)
            break

    #plot imu stuff (if we have imus)
    for iidx, imu in enumerate(cself.ImuList):
        f = pl.figure(offset + iidx)
        plots.plotAccelerations(cself, iidx, fno=f.number, noShow=True)
        plotter.add_figure("imu{0}: accelerations".format(iidx), f)
        figs.append(f)
        offset += len(cself.ImuList)

        f = pl.figure(offset + iidx)
        plots.plotAccelErrorPerAxis(cself, iidx, fno=f.number, noShow=True)
        plotter.add_figure("imu{0}: acceleration error".format(iidx), f)
        figs.append(f)
        offset += len(cself.ImuList)

        f = pl.figure(offset + iidx)
        plots.plotAccelBias(cself, iidx, fno=f.number, noShow=True)
        plotter.add_figure("imu{0}: accelerometer bias".format(iidx), f)
        figs.append(f)
        offset += len(cself.ImuList)

        f = pl.figure(offset + iidx)
        plots.plotAngularVelocities(cself, iidx, fno=f.number, noShow=True)
        plotter.add_figure("imu{0}: angular velocities".format(iidx), f)
        figs.append(f)
        offset += len(cself.ImuList)

        f = pl.figure(offset + iidx)
        plots.plotGyroErrorPerAxis(cself, iidx, fno=f.number, noShow=True)
        plotter.add_figure("imu{0}: angular velocity error".format(iidx), f)
        figs.append(f)
        offset += len(cself.ImuList)

        f = pl.figure(offset + iidx)
        plots.plotAngularVelocityBias(cself, iidx, fno=f.number, noShow=True)
        plotter.add_figure("imu{0}: gyroscope bias".format(iidx), f)
        figs.append(f)
        offset += len(cself.ImuList)

    #plot cam stuff
    if cself.CameraChain:
        for cidx, cam in enumerate(cself.CameraChain.camList):
            f = pl.figure(offset + cidx)
            title = "cam{0}: reprojection errors".format(cidx)
            plots.plotReprojectionScatter(cself,
                                          cidx,
                                          fno=f.number,
                                          noShow=True,
                                          title=title)
            plotter.add_figure(title, f)
            figs.append(f)
            offset += len(cself.CameraChain.camList)

    #write to pdf
    pdf = PdfPages(filename)
    for fig in figs:
        pdf.savefig(fig)
    pdf.close()

    if showOnScreen:
        plotter.show()