#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)
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.
/*----------------- 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;
}