ChartDetect - a Calibration Chart Detector library

NAME

AppendChartCtrGF, AppendChartGF, AppendEdges2DGF, Chart, DestChart, DestLLSetsGF, WriteChart2Tsai

SYNOPSIS

#include ''chart.h''

t_detect Chart(int chart_dim,BARY *in)
void AppendEdges2DGF(t_LL Sets,t_LL edgeMap);
void AppendChartGF(t_LL sets,t_LL segmentedChart,int chart_dim)
void AppendChartCtrGF(t_LL sets,t_LL segmentedChart,int chart_dim)
void WriteChart2Tsai(t_LL segmentedChart,char *tsai_inp,int chart_dim)
void DestLLSetsGF(t_LL sets)
void DestChart(t_detect chart,int chart_dim)


DESCRIPTION

Introduction

ChartDetect is a library used for calibration chart(s) detection. The type t_detect is represented by a link list of the segmented calibration chart and a link list of all the edge strings detected.

typedef struct {t_LL segmentedChart; t_LL edgeMap;} t_detect

Within t_detect, segmentedChart gives a list of t_chart and edgemap gives a list of edgepoints of the whole image.

typedef struct {PARY *chartSqr;t_V2 chartCG;t_V2iPair vectPair; int chartWeight;int numLoop;int chartArea;void *att;} t_chart

In t_chart, chartSqr outputs a PARY of size chart_dim pointing to t_sqr, chartCG gives the center of the chart, vectpair shows the vector of the two axis of the chart, chartweight defines the structure quality of the chart (range: 0-432), chartArea indicates the area of the chart (not implemented) and att lets the user have an optional attributes for input.

typedef struct {t_LL oneLoop;t_V2 ctr;int area;void *att;} t_sqr;

In t_sqr, oneLoop contains a list of edge string that forms the square loop, ctr gives the center of the square loop, next is the area fo the square loop and att lets the user have an optional attributes for input.

Charts detection and destruction

Chart(chart_dim,in) detects calibration charts from the BARY *in. chart_dim defines the dimension of the calibration chart (default: 4x4). The output is given in the t_detect format. DestChart(t_detect chart,int chart_dim) destroys the list of detected charts, ie. deletes all elements and frees all memory allocated for the list.

Output function

AppendEdges2DGF(sets,edgeMap) outputs the edge map, extracted from the whole image, to a gf format output file /tmp/g. The edge map will exclude the borders (i.e. rim of 4 pixel by default) of the image.
AppendChartGF(sets,segmentedChart,chart_dim) writes the charts with indication of orientation into a gf format output file /tmp/g.
AppendChartCtrGF(sets,segmentedChart,chart_dim) produce the charts center into a gf format output file /tmp/g.
WriteChart2Tsai(segmentedChart,tsai_inp,chart_dim) gives an output file(s) tsai_inp for Tsai's camera calibration input.

Example exChartDetect.c


/*----------------- chart library example: basic functions ---------------- */
#include <stdlib.h>
#include <string.h>
#include <optionGM.h>
#include "chart.h"


/*-----------------------------------------------------------------------*/ 
/*  
  This example shows HOW TO:  
    - detect calibration charts from a BARY image (Chart)
    - output to Tsai's camera calibration (WriteChart2Tsai) 
    - output to gf format (AppendChartGF,AppendChartCtrGF,DestLLSetsGF)
    - destroy charts element (DestChart)
*/ 
/*-----------------------------------------------------------------------*/ 
int main (int argc, char ** argv)
{
  ExitOnAryError();
  OptionInit(argv,&argc);                       /* analyse the command line */
  {
    char *in_file  = OptionStr("i",NULL,"input image/grabber output (P5 pgm)");
    char *out_file = OptionStr("o",NULL,"output .gf file");
    char *tsai_inp = OptionStr("f",NULL,"output for Tsai's calibration");
    int chart_dim  = OptionInt("dim",4,"size of calibration chart");


    OptionCompulsory("i");
    OptionCheck();
    ExitOnAryError();
    {
      t_detect detect;
      BARY *im = P5pgm2Bary(in_file);
      
      detect = Chart(chart_dim,im);
      if (NULL != out_file) {                       /* write into gf format */
	t_LL sets = ConsLL();
      
	AppendEdges2DGF(sets,detect.edgeMap);
	AppendChartGF(sets,detect.segmentedChart,chart_dim);
	AppendChartCtrGF(sets,detect.segmentedChart,chart_dim);
	WriteLLSets(out_file,sets);
	DestLLSetsGF(sets);
      }
      if (NULL != tsai_inp)  /* write into Tsai's camera calibration format */
	WriteChart2Tsai(detect.segmentedChart,tsai_inp,chart_dim);


      destAry(im);
      DestChart(detect,chart_dim); 
    }
  }                                             /* end of scope for options */
  /*----- exit -------------------------------------------------------------*/
  return 1;
}

POSTSCRIPT FILES OF CALIBRATION CHARTS

The location of the input calibration charts in postscript format can be found in /vol/vssp/vap/soft/chart directory. The square charts are chart44.ps (one 14x14cm) and chart44_small.ps (one 7x7cm). The circle charts are circle44.ps (one 14x14cm), circle444_small.ps (four 7x7cm charts) and circle44_small.ps (one 7x7cm).

BUGS

Please inform me if it's not working well.

SEE ALSO

LL(3)

AUTHOR

Alan Soh L.M., University of Surrey, 1st July 1997. Thanks to George (Jiri) Matas (g.matas@ee.surrey.ac.uk) who contributed the source codes for low level image processing.
23-Nov-97. Automatically converted by man2html, written by G.Matas (g.matas@ee.surrey.ac.uk)