From: Jim G. <jgreen@RobotVision.com> - 2006-09-16 19:42:06
|
Hi, I'm new to vxl so this question may be basic, but... I'm running Win2000 on an Athlon64 dual processor chip with 2GB RAM. I successfully built vxl-1.6 (24Aug06) with CMake using Vis Studio V8 by following the directions. I am trying to add a RPC00B vil_nitf2_tagged_record (TRE) to vil_nitf2_tagged_record.cxx. This TRE has a series of individual values and then 4 groups of 20 polynomial coefficients. The individual values compile OK, but it looks like I have the wrong syntax for the groups of 20. The relevant code (patterned after the example in the file): -------------------------------------------------------------- /* An RPC (Rational Polynomial Coefficient) camera model is supplied by the image creator with many NITF images. The model is instanced using 80 polynomial coefficients plus some camera position parameters. Having a camera model is required for a 3D-to-2D projection back into the image plane so an RPC is very handy to have. Note that here we only instance RPC00B. RPC00A has the same order of coefficient values in the TRE, but the ordering of the 80 polynomial values is different in the 3D to 2D equation. We can read in both cases with the TRE code below, but if you want to use RPC00A, you must supply the equation ordering code (here the RPC00B equation is defined in <TBD>). */ bool error = false; vcl_string LNC[20]; // the arrays for the 80 polynomial coefficients vcl_string LDC[20]; vcl_string SNC[20]; vcl_string SDC[20]; // RPC00B Tagged Record Extension definition vil_nitf2_tagged_record_definition RPC00B = vil_nitf2_tagged_record_definition::define("RPC00B", "RPC00B camera parameters TRE" ) // These are the "offset and scale" fields that precede the polynomial coefficients .field("SUCCESS", "Success parameter", NITF_CHAR(), true) .field("ERR_BIAS", "ERR_BIAS", NITF_INT(7)) // read in as int where it's an int .field("ERR_RAND", "ERR_RAND", NITF_INT(7)) .field("LINE_OFF", "Line Offset", NITF_INT(6)) .field("SAMP_OFF", "Sample Offset", NITF_INT(5)) .field("LAT_OFF", "Latitude Offset", NITF_STR(8)) //I think this is the correct .field("LON_OFF", "Longitude offset", NITF_STR(9)) //type for a string input??? .field("HEIGHT_OFF", "Height Offset", NITF_INT(5)) .field("LINE_SCALE", "Line Scale", NITF_INT(6)) .field("SAMP_SCALE", "Sample Scale", NITF_INT(5)) .field("LAT_SCALE", "Latitude Scale", NITF_STR(8)) //Should we use double instead? .field("LON_SCALE", "Longitude Scale", NITF_STR(9)) .field("HEIGHT_SCALE", "Height Scale", NITF_INT(5)) // Now come the 4 sequential groups of 20 polynomial coefficients each for line number, // line density, sample number and sample density. // As these values are in <+/->n.nnnnnnE<+/->n (exponential) format, let's just read as // strings and convert into doubles later. for( int i=0, i < 20, i++) { .field("LNC[i]", "Line Number Coefficient", NITF_STR(12)) } for( int i=0, i < 20, i++) { .field("LDC[i]", "Line Density Coefficient", NITF_STR(12)) } for( int i=0, i < 20, i++) { .field("SNC[i]", "Sample Number Coefficient", NITF_STR(12)) } for( int i=0, i < 20, i++) { .field("SDC[i]", "Sample Density Coefficient", NITF_STR(12)) } .end(); //of RPC00B TRE ------------------------------------------------------------------- I get syntax errors from Vis Studio associated with the for loops and curley braces. 2>vil_nitf2_tagged_record.cxx 2>..\..\..\vxl-1.6\core\vil\file_formats\vil_nitf2_tagged_record.cxx(507) : error C2143: syntax error : missing ';' before 'for' 2>..\..\..\vxl-1.6\core\vil\file_formats\vil_nitf2_tagged_record.cxx(507) : error C2059: syntax error : 'for' 2>..\..\..\vxl-1.6\core\vil\file_formats\vil_nitf2_tagged_record.cxx(507) : error C2143: syntax error : missing ';' before '{' 2>..\..\..\vxl-1.6\core\vil\file_formats\vil_nitf2_tagged_record.cxx(507) : error C2447: '{' : missing function header (old-style formal list?) 2>..\..\..\vxl-1.6\core\vil\file_formats\vil_nitf2_tagged_record.cxx(510) : error C2059: syntax error : 'for' 2>..\..\..\vxl-1.6\core\vil\file_formats\vil_nitf2_tagged_record.cxx(510) : error C2143: syntax error : missing ';' before '{' 2>..\..\..\vxl-1.6\core\vil\file_formats\vil_nitf2_tagged_record.cxx(510) : error C2447: '{' : missing function header (old-style formal list?) 2>..\..\..\vxl-1.6\core\vil\file_formats\vil_nitf2_tagged_record.cxx(513) : error C2059: syntax error : 'for' 2>..\..\..\vxl-1.6\core\vil\file_formats\vil_nitf2_tagged_record.cxx(513) : error C2143: syntax error : missing ';' before '{' 2>..\..\..\vxl-1.6\core\vil\file_formats\vil_nitf2_tagged_record.cxx(513) : error C2447: '{' : missing function header (old-style formal list?) 2>..\..\..\vxl-1.6\core\vil\file_formats\vil_nitf2_tagged_record.cxx(516) : error C2059: syntax error : 'for' 2>..\..\..\vxl-1.6\core\vil\file_formats\vil_nitf2_tagged_record.cxx(516) : error C2143: syntax error : missing ';' before '{' 2>..\..\..\vxl-1.6\core\vil\file_formats\vil_nitf2_tagged_record.cxx(516) : error C2447: '{' : missing function header (old-style formal list?) 2>..\..\..\vxl-1.6\core\vil\file_formats\vil_nitf2_tagged_record.cxx(519) : error C2059: syntax error : '.' 2>Build log was saved at "file://d:\vxl\bin\core\vil\vil.dir\Debug\BuildLog.htm" 2>vil - 14 error(s), 0 warning(s) Apparently it doesn't like the for loops in this TRE definition? There is a "repeat" field defined in vil_nitf2_tagged_record_definition.h, but I have found no examples where it was used to read in a fixed number of values. Asn none of the documentation mention how this might be used in such a case. Any suggestions? Thanks, Jim Green ----------------------------------- |
From: Harry L. V. <hl...@st...> - 2006-09-18 00:18:21
|
Jim, field() is a method on class vil_nitf2_tagged_record_definition, so if you call field() in a 'for' loop, you'll need to call it on the instance of the class returned by vil_nitf2_tagged_record_definition::define(). An alternative is to use repeat(). As you noted there is not a version that takes a simple integer argument - only a version that takes a functor for evaluating a tag. Try defining a functor like this: template<typename T> class vil_nitf2_constant_functor : public vil_nitf2_field_functor<T> { public: vil_nitf2_constant_functor(T value) : value_(value) {} bool operator() (vil_nitf2_field_sequence* record, const vil_nitf2_index_vector& indexes, T& value) { value = value_; return true; } private: T value_; }; ...and using it an argument to repeat() within your definition like this: .repeat(vil_nitf2_constant_functor<int>(20), fields() .field("LNC", "Line Number Coefficient", NITF_STR(12)) .field("LDC", "Line Density Coefficient", NITF_STR(12)) .field("SNC", "Sample Number Coefficient", NITF_STR(12)) etc. If it works, let me know, and I'll fold it into the NITF code, and try to add a convenience version of repeat() that takes a simple integer argument. Harry Voorhees _________________________________________________________ Harry L. Voorhees, hl...@st..., 978-475-5279 Stellar Science Ltd. Co., www.stellarscience.com "Stellar Scientific Software Solutions" Jim Green wrote: > Hi, > > I'm new to vxl so this question may be basic, but... > > I'm running Win2000 on an Athlon64 dual processor chip with 2GB > RAM. I successfully built vxl-1.6 (24Aug06) with CMake using Vis > Studio V8 by following the directions. > > I am trying to add a RPC00B vil_nitf2_tagged_record (TRE) to > vil_nitf2_tagged_record.cxx. This TRE has a series of individual > values and then 4 groups of 20 polynomial coefficients. The > individual values compile OK, but it looks like I have the wrong > syntax for the groups of 20. The relevant code (patterned after the > example in the file): > -------------------------------------------------------------- > /* > An RPC (Rational Polynomial Coefficient) camera model is supplied by > the image creator > with many NITF images. The model is instanced using 80 polynomial > coefficients plus some > camera position parameters. Having a camera model is required for a > 3D-to-2D projection > back into the image plane so an RPC is very handy to have. > > Note that here we only instance RPC00B. RPC00A has the same order of > coefficient values in > the TRE, but the ordering of the 80 polynomial values is different in > the 3D to 2D equation. > We can read in both cases with the TRE code below, but if you want to > use RPC00A, you must > supply the equation ordering code (here the RPC00B equation is > defined in <TBD>). > */ > > > bool error = false; > vcl_string LNC[20]; // the arrays for the 80 polynomial coefficients > vcl_string LDC[20]; > vcl_string SNC[20]; > vcl_string SDC[20]; > > // RPC00B Tagged Record Extension definition > vil_nitf2_tagged_record_definition RPC00B = > vil_nitf2_tagged_record_definition::define("RPC00B", "RPC00B > camera parameters TRE" ) > > // These are the "offset and scale" fields that precede the > polynomial coefficients > .field("SUCCESS", "Success parameter", NITF_CHAR(), true) > .field("ERR_BIAS", "ERR_BIAS", > NITF_INT(7)) // read in as int where it's an int > .field("ERR_RAND", "ERR_RAND", NITF_INT(7)) > .field("LINE_OFF", "Line Offset", NITF_INT(6)) > .field("SAMP_OFF", "Sample Offset", NITF_INT(5)) > .field("LAT_OFF", "Latitude > Offset", NITF_STR(8)) //I think this is the correct > .field("LON_OFF", "Longitude > offset", NITF_STR(9)) //type for a string input??? > .field("HEIGHT_OFF", "Height Offset", NITF_INT(5)) > .field("LINE_SCALE", "Line Scale", NITF_INT(6)) > .field("SAMP_SCALE", "Sample Scale", NITF_INT(5)) > .field("LAT_SCALE", "Latitude > Scale", NITF_STR(8)) //Should we use double instead? > .field("LON_SCALE", "Longitude Scale", NITF_STR(9)) > .field("HEIGHT_SCALE", "Height Scale", NITF_INT(5)) > > // Now come the 4 sequential groups of 20 polynomial > coefficients each for line number, > // line density, sample number and sample density. > // As these values are in <+/->n.nnnnnnE<+/->n (exponential) > format, let's just read as > // strings and convert into doubles later. > > for( int i=0, i < 20, i++) { > .field("LNC[i]", "Line Number Coefficient", NITF_STR(12)) > } > for( int i=0, i < 20, i++) { > .field("LDC[i]", "Line Density Coefficient", NITF_STR(12)) > } > for( int i=0, i < 20, i++) { > .field("SNC[i]", "Sample Number Coefficient", NITF_STR(12)) > } > for( int i=0, i < 20, i++) { > .field("SDC[i]", "Sample Density Coefficient", NITF_STR(12)) > } > .end(); //of RPC00B TRE > > ------------------------------------------------------------------- > I get syntax errors from Vis Studio associated with the for loops and > curley braces. > > 2>vil_nitf2_tagged_record.cxx > 2>..\..\..\vxl-1.6\core\vil\file_formats\vil_nitf2_tagged_record.cxx(507) > : error C2143: syntax error : missing ';' before 'for' > 2>..\..\..\vxl-1.6\core\vil\file_formats\vil_nitf2_tagged_record.cxx(507) > : error C2059: syntax error : 'for' > 2>..\..\..\vxl-1.6\core\vil\file_formats\vil_nitf2_tagged_record.cxx(507) > : error C2143: syntax error : missing ';' before '{' > 2>..\..\..\vxl-1.6\core\vil\file_formats\vil_nitf2_tagged_record.cxx(507) > : error C2447: '{' : missing function header (old-style formal list?) > 2>..\..\..\vxl-1.6\core\vil\file_formats\vil_nitf2_tagged_record.cxx(510) > : error C2059: syntax error : 'for' > 2>..\..\..\vxl-1.6\core\vil\file_formats\vil_nitf2_tagged_record.cxx(510) > : error C2143: syntax error : missing ';' before '{' > 2>..\..\..\vxl-1.6\core\vil\file_formats\vil_nitf2_tagged_record.cxx(510) > : error C2447: '{' : missing function header (old-style formal list?) > 2>..\..\..\vxl-1.6\core\vil\file_formats\vil_nitf2_tagged_record.cxx(513) > : error C2059: syntax error : 'for' > 2>..\..\..\vxl-1.6\core\vil\file_formats\vil_nitf2_tagged_record.cxx(513) > : error C2143: syntax error : missing ';' before '{' > 2>..\..\..\vxl-1.6\core\vil\file_formats\vil_nitf2_tagged_record.cxx(513) > : error C2447: '{' : missing function header (old-style formal list?) > 2>..\..\..\vxl-1.6\core\vil\file_formats\vil_nitf2_tagged_record.cxx(516) > : error C2059: syntax error : 'for' > 2>..\..\..\vxl-1.6\core\vil\file_formats\vil_nitf2_tagged_record.cxx(516) > : error C2143: syntax error : missing ';' before '{' > 2>..\..\..\vxl-1.6\core\vil\file_formats\vil_nitf2_tagged_record.cxx(516) > : error C2447: '{' : missing function header (old-style formal list?) > 2>..\..\..\vxl-1.6\core\vil\file_formats\vil_nitf2_tagged_record.cxx(519) > : error C2059: syntax error : '.' > 2>Build log was saved at > "file://d:\vxl\bin\core\vil\vil.dir\Debug\BuildLog.htm" > 2>vil - 14 error(s), 0 warning(s) > > Apparently it doesn't like the for loops in this TRE > definition? There is a "repeat" field defined in > vil_nitf2_tagged_record_definition.h, but I have found no examples > where it was used to read in a fixed number of values. Asn none of > the documentation mention how this might be used in such a case. Any > suggestions? > > Thanks, Jim Green |
From: Jim G. <jgreen@RobotVision.com> - 2006-09-18 01:43:12
|
Harry, Thanks loads for your response and example. I'm leaving tomorrow night (Monday) for a 3 week trip. I'll try to test this tomorrow before I leave, but if I don't get a chance, I'll test it as soon as I return. But thanks for your help. I'll try to send an email to the group tomorrow with some results. My problem is I learned to program in C long before there was C++, so most of the code I write still looks like C, and I really never got familiar with templates and the other deep C++ stuff that vxl uses. Thanks, Jim Green -------------------------------------------- At 08:18 PM 9/17/2006, Harry L. Voorhees wrote: >Jim, > >field() is a method on class vil_nitf2_tagged_record_definition, so >if you call field() in a 'for' loop, you'll need to call it on the >instance of the class returned by vil_nitf2_tagged_record_definition::define(). > >An alternative is to use repeat(). As you noted there is not a >version that takes a simple integer argument - only a version that >takes a functor for evaluating a tag. Try defining a functor like this: > >template<typename T> >class vil_nitf2_constant_functor : public vil_nitf2_field_functor<T> >{ >public: > vil_nitf2_constant_functor(T value) : value_(value) {} > > bool operator() (vil_nitf2_field_sequence* record, > const vil_nitf2_index_vector& indexes, T& value) > { > value = value_; > return true; > } > >private: > T value_; >}; > >...and using it an argument to repeat() within your definition like this: > >.repeat(vil_nitf2_constant_functor<int>(20), fields() > .field("LNC", "Line Number Coefficient", NITF_STR(12)) > .field("LDC", "Line Density Coefficient", NITF_STR(12)) > .field("SNC", "Sample Number Coefficient", NITF_STR(12)) > etc. > >If it works, let me know, and I'll fold it into the NITF code, and >try to add a convenience version of repeat() that takes a simple >integer argument. > >Harry Voorhees > >_________________________________________________________ >Harry L. Voorhees, hl...@st..., 978-475-5279 > Stellar Science Ltd. Co., www.stellarscience.com > "Stellar Scientific Software Solutions" > >Jim Green wrote: >>Hi, >> >>I'm new to vxl so this question may be basic, but... >> >>I'm running Win2000 on an Athlon64 dual processor chip with 2GB >>RAM. I successfully built vxl-1.6 (24Aug06) with CMake using Vis >>Studio V8 by following the directions. >> >>I am trying to add a RPC00B vil_nitf2_tagged_record (TRE) to >>vil_nitf2_tagged_record.cxx. This TRE has a series of individual >>values and then 4 groups of 20 polynomial coefficients. The >>individual values compile OK, but it looks like I have the wrong >>syntax for the groups of 20. The relevant code (patterned after >>the example in the file): >>-------------------------------------------------------------- >>/* >>An RPC (Rational Polynomial Coefficient) camera model is supplied >>by the image creator >>with many NITF images. The model is instanced using 80 polynomial >>coefficients plus some >>camera position parameters. Having a camera model is required for >>a 3D-to-2D projection >>back into the image plane so an RPC is very handy to have. >> >>Note that here we only instance RPC00B. RPC00A has the same order >>of coefficient values in >>the TRE, but the ordering of the 80 polynomial values is different >>in the 3D to 2D equation. >>We can read in both cases with the TRE code below, but if you want >>to use RPC00A, you must >>supply the equation ordering code (here the RPC00B equation is >>defined in <TBD>). >>*/ >> >> >> bool error = false; >> vcl_string LNC[20]; // the arrays for the 80 polynomial coefficients >> vcl_string LDC[20]; >> vcl_string SNC[20]; >> vcl_string SDC[20]; >> >> // RPC00B Tagged Record Extension definition >> vil_nitf2_tagged_record_definition RPC00B = >> vil_nitf2_tagged_record_definition::define("RPC00B", "RPC00B >> camera parameters TRE" ) >> >> // These are the "offset and scale" fields that precede >> the polynomial coefficients >> .field("SUCCESS", "Success >> parameter", NITF_CHAR(), true) >> .field("ERR_BIAS", "ERR_BIAS", NITF_INT(7)) // read >> in as int where it's an int >> .field("ERR_RAND", "ERR_RAND", >> NITF_INT(7)) >> .field("LINE_OFF", "Line >> Offset", NITF_INT(6)) >> .field("SAMP_OFF", "Sample >> Offset", NITF_INT(5)) >> .field("LAT_OFF", "Latitude >> Offset", NITF_STR(8)) //I think this is the correct >> .field("LON_OFF", "Longitude >> offset", NITF_STR(9)) //type for a string input??? >> .field("HEIGHT_OFF", "Height >> Offset", NITF_INT(5)) >> .field("LINE_SCALE", "Line >> Scale", NITF_INT(6)) >> .field("SAMP_SCALE", "Sample >> Scale", NITF_INT(5)) >> .field("LAT_SCALE", "Latitude >> Scale", NITF_STR(8)) //Should we use double instead? >> .field("LON_SCALE", "Longitude >> Scale", NITF_STR(9)) >> .field("HEIGHT_SCALE", "Height >> Scale", NITF_INT(5)) >> >> // Now come the 4 sequential groups of 20 polynomial >> coefficients each for line number, >> // line density, sample number and sample density. >> // As these values are in <+/->n.nnnnnnE<+/->n >> (exponential) format, let's just read as >> // strings and convert into doubles later. >> >> for( int i=0, i < 20, i++) { >> .field("LNC[i]", "Line Number Coefficient", NITF_STR(12)) >> } >> for( int i=0, i < 20, i++) { >> .field("LDC[i]", "Line Density Coefficient", NITF_STR(12)) >> } >> for( int i=0, i < 20, i++) { >> .field("SNC[i]", "Sample Number Coefficient", NITF_STR(12)) >> } >> for( int i=0, i < 20, i++) { >> .field("SDC[i]", "Sample Density Coefficient", NITF_STR(12)) >> } >> .end(); //of RPC00B TRE >> >>------------------------------------------------------------------- >>I get syntax errors from Vis Studio associated with the for loops >>and curley braces. >> >>2>vil_nitf2_tagged_record.cxx >>2>..\..\..\vxl-1.6\core\vil\file_formats\vil_nitf2_tagged_record.cxx(507) >>: error C2143: syntax error : missing ';' before 'for' >>2>..\..\..\vxl-1.6\core\vil\file_formats\vil_nitf2_tagged_record.cxx(507) >>: error C2059: syntax error : 'for' >>2>..\..\..\vxl-1.6\core\vil\file_formats\vil_nitf2_tagged_record.cxx(507) >>: error C2143: syntax error : missing ';' before '{' >>2>..\..\..\vxl-1.6\core\vil\file_formats\vil_nitf2_tagged_record.cxx(507) >>: error C2447: '{' : missing function header (old-style formal list?) >>2>..\..\..\vxl-1.6\core\vil\file_formats\vil_nitf2_tagged_record.cxx(510) >>: error C2059: syntax error : 'for' >>2>..\..\..\vxl-1.6\core\vil\file_formats\vil_nitf2_tagged_record.cxx(510) >>: error C2143: syntax error : missing ';' before '{' >>2>..\..\..\vxl-1.6\core\vil\file_formats\vil_nitf2_tagged_record.cxx(510) >>: error C2447: '{' : missing function header (old-style formal list?) >>2>..\..\..\vxl-1.6\core\vil\file_formats\vil_nitf2_tagged_record.cxx(513) >>: error C2059: syntax error : 'for' >>2>..\..\..\vxl-1.6\core\vil\file_formats\vil_nitf2_tagged_record.cxx(513) >>: error C2143: syntax error : missing ';' before '{' >>2>..\..\..\vxl-1.6\core\vil\file_formats\vil_nitf2_tagged_record.cxx(513) >>: error C2447: '{' : missing function header (old-style formal list?) >>2>..\..\..\vxl-1.6\core\vil\file_formats\vil_nitf2_tagged_record.cxx(516) >>: error C2059: syntax error : 'for' >>2>..\..\..\vxl-1.6\core\vil\file_formats\vil_nitf2_tagged_record.cxx(516) >>: error C2143: syntax error : missing ';' before '{' >>2>..\..\..\vxl-1.6\core\vil\file_formats\vil_nitf2_tagged_record.cxx(516) >>: error C2447: '{' : missing function header (old-style formal list?) >>2>..\..\..\vxl-1.6\core\vil\file_formats\vil_nitf2_tagged_record.cxx(519) >>: error C2059: syntax error : '.' >>2>Build log was saved at >>"file://d:\vxl\bin\core\vil\vil.dir\Debug\BuildLog.htm" >>2>vil - 14 error(s), 0 warning(s) >> >>Apparently it doesn't like the for loops in this TRE >>definition? There is a "repeat" field defined in >>vil_nitf2_tagged_record_definition.h, but I have found no examples >>where it was used to read in a fixed number of values. Asn none of >>the documentation mention how this might be used in such a >>case. Any suggestions? >> >>Thanks, Jim Green |