From: Ian S. <sc...@im...> - 2011-03-15 17:35:45
|
Hi Joe, Peter has been trying to add code to fix a few of BRL's unresolved symbols, but I'm concerned that his implementation of vsl_b_read(bfs, vil_image_view_base_sptr&) won't behave as users might expect. See emails below for the details. I'd be grateful if you or someone else at Brown can explain to me where, why and how they are doing IO on a vil_image_view_base_sptr. I'd be happy to write a proper polymorphic IO capability for vil_image_view_base_sptr once I understand how BRL is trying to use it. I've never delved into the depths of brl before. It seems that are a few references to vil_io, but I can't find a decent example of a use case. vil_image_view_base_sptr isn't really intended for use outside vil's internals, so I'm not sure exactly what BRL intends by doing IO. Are you using a vil_image_view_base_sptr as a polymorphic image? Does the IO need to completely reconstruct the image contents, and layout? BTW There is a fully polymorphic wrapper for vil_image_view<> in mul/vimt that supports the full polymorphic IO. But if you don't need the world_to_image transform, I can see it might not be ideal. Thanks, Ian. -------- Original Message -------- Subject: Re: [Vxl-commit] SF.net SVN: vxl:[31421] trunk/core/vil/io Date: Tue, 15 Mar 2011 17:32:47 +0100 From: pe...@va... To: Ian Scott <sc...@im...> CC: Peter Vanroose <p.v...@ie...> Ian, Completely agree with you. I just tried to avoid "unresolved symbols" in contrib/brl/bseg, see e.g. contrib/brl/bseg/boxm/algo/sp/pro/Templates/brdb_value_t+vil_image_view_base_sptr-.cxx where an implicit use is made of vsl_b_read(vsl_b_istream&, vil_smart_ptr<vil_image_view_base>&) and vsl_b_write(vsl_b_ostream&, vil_smart_ptr<vil_image_view_base> const&) The new instantiation in vil/io seems to avoid that problem. I've no idea whether the use cases in contrib/brl/bseg (there are other similar ones) make sense or not in terms of I/O. -- Peter. > I've haven't had time to look at this properly but two issues jump out > at me. > > 1. vil_image_view_base is an abstract base class. Indeed the > documentation explicitly discourages people from using > vil_image_view_base_sptr. Why would you want to do IO on it? > > 2. Your changes allow you to do IO on a vil_image_view_base_sptr, but > there is no support for figuring out which concrete type lies behind the > pointer, and loading in the rest of the image. Again I don't understand > what use case you have in mind. > > Ian. > > On 15/03/2011 15:31, pet...@us... wrote: >> Revision: 31421 >> http://vxl.svn.sourceforge.net/vxl/?rev=31421&view=rev >> Author: peter_vanroose >> Date: 2011-03-15 15:31:30 +0000 (Tue, 15 Mar 2011) >> >> Log Message: >> ----------- >> added I/O for vil_image_view_base >> >> Modified Paths: >> -------------- >> trunk/core/vil/io/vil_io_image_view.h >> >> Added Paths: >> ----------- >> trunk/core/vil/io/Templates/vil_io_smart_ptr+vil_image_view_base-.cxx >> >> Added: trunk/core/vil/io/Templates/vil_io_smart_ptr+vil_image_view_base-.cxx >> =================================================================== >> --- trunk/core/vil/io/Templates/vil_io_smart_ptr+vil_image_view_base-.cxx >> (rev 0) >> +++ >> trunk/core/vil/io/Templates/vil_io_smart_ptr+vil_image_view_base-.cxx 2011-03-15 >> 15:31:30 UTC (rev 31421) >> @@ -0,0 +1,3 @@ >> +#include<vil/io/vil_io_smart_ptr.txx> >> +#include<vil/io/vil_io_image_view.h> >> +VIL_IO_SMART_PTR_INSTANTIATE(vil_image_view_base); >> >> >> Property changes on: >> trunk/core/vil/io/Templates/vil_io_smart_ptr+vil_image_view_base-.cxx >> ___________________________________________________________________ >> Added: svn:mime-type >> + text/plain >> Added: svn:eol-style >> + native >> >> Modified: trunk/core/vil/io/vil_io_image_view.h >> =================================================================== >> --- trunk/core/vil/io/vil_io_image_view.h 2011-03-15 14:58:35 UTC (rev >> 31420) >> +++ trunk/core/vil/io/vil_io_image_view.h 2011-03-15 15:31:30 UTC (rev >> 31421) >> @@ -7,6 +7,7 @@ >> >> #include<vcl_cstddef.h> >> #include<vcl_iostream.h> >> +#include<vxl_config.h> >> #include<vil/vil_image_view.h> >> #include<vil/io/vil_io_memory_chunk.h> >> >> @@ -90,7 +91,7 @@ >> vcl_cerr<< "I/O ERROR: vsl_b_read(vsl_b_istream&, >> vil_image_view<T>&)\n" >> << " Unknown version number"<< w<< '\n'; >> is.is().clear(vcl_ios::badbit); // Set an unrecoverable IO error on >> stream >> - return; >> + break; >> } >> } >> >> @@ -119,4 +120,74 @@ >> image.print(os); >> } >> >> +//: Binary save vil_image_view_base to stream. >> +// \relatesalso vil_image_view_base >> +inline void vsl_b_write(vsl_b_ostream&os, const vil_image_view_base& >> image) >> +{ >> + const short io_version_no = 1; >> + vsl_b_write(os, io_version_no); >> + vsl_b_write(os, image.ni()); >> + vsl_b_write(os, image.nj()); >> + vsl_b_write(os, image.nplanes()); >> +} >> + >> +//: Binary load vil_image_view_base from stream. >> +// \relatesalso vil_image_view_base >> +inline void vsl_b_read(vsl_b_istream&is, vil_image_view_base& image) >> +{ >> + if (!is) return; >> + >> + unsigned ni,nj,np; >> + short w; >> + vsl_b_read(is, w); >> + switch (w) >> + { >> + case 1: >> + vsl_b_read(is, ni); >> + vsl_b_read(is, nj); >> + vsl_b_read(is, np); >> + image.set_size(ni, nj, np); >> + break; >> + >> + default: >> + vcl_cerr<< "I/O ERROR: vsl_b_read(vsl_b_istream&, >> vil_image_view_base&)\n" >> +<< " Unknown version number"<< w<< '\n'; >> + is.is().clear(vcl_ios::badbit); // Set an unrecoverable IO error on >> stream >> + break; >> + } >> +} >> + >> +//: Binary load vil_image_view_base from stream onto the heap >> +// \relatesalso vil_image_view_base >> +inline void vsl_b_read(vsl_b_istream&is, vil_image_view_base*& p) >> +{ >> + if (!is) return; >> + >> + bool not_null_ptr; >> + vsl_b_read(is, not_null_ptr); >> + if (not_null_ptr) >> + { >> + unsigned ni,nj,np; >> + short w; >> + vsl_b_read(is, w); >> + switch (w) >> + { >> + case 1: >> + vsl_b_read(is, ni); >> + vsl_b_read(is, nj); >> + vsl_b_read(is, np); >> + p->set_size(ni, nj, np); >> + break; >> + >> + default: >> + vcl_cerr<< "I/O ERROR: vsl_b_read(vsl_b_istream&, >> vil_image_view_base&)\n" >> +<< " Unknown version number"<< w<< '\n'; >> + is.is().clear(vcl_ios::badbit); // Set an unrecoverable IO error on >> stream >> + break; >> + } >> + } >> + else >> + p = 0; >> +} >> + >> #endif // vil_io_image_view_h_ >> >> >> This was sent by the SourceForge.net collaborative development platform, the >> world's largest Open Source development site. >> >> ------------------------------------------------------------------------------ >> Colocation vs. Managed Hosting >> A question and answer guide to determining the best fit >> for your organization - today and in the future. >> http://p.sf.net/sfu/internap-sfd2d >> _______________________________________________ >> Vxl-commit mailing list >> Vxl...@li... >> https://lists.sourceforge.net/lists/listinfo/vxl-commit >> >> > |