Template class and any_image_view

Hello, I'm in trouble using dynamic images into a template class. I have an abstract class Filter of this form: template <typename TView1, typename TView2> class Filter { public: virtual ~Filter(); virtual void setParameter(uint8 id, float16 value); virtual void apply(const any_image_view<TView1>& source, const any_image_view<TView2>& destination) = 0; protected: Filter(); }; which is subclassed by other concrete classes like this one: template <typename TView1, typename TView2> class BlurGaussSelective : public Filter<TView1,TView2> { public: BlurGaussSelective(); virtual ~BlurGaussSelective(); void setParameter(uint8 id, float16 value); void apply(const any_image_view<TView1>& source, const any_image_view<TView2>& destination); }; As you can see I need to use a template class because the "apply" method (where concrete filters implements own logic) is virtual. But when I instantiate a BlurGaussSelective object I don't know which template types pass to it. I tried this: typedef vector<rgb8_image_t,gray8_image_t> ImageType; typedef vector<rgb8_view_t,gray8_view_t> ViewType; any_image<ImageType> source; any_image<ImageType> dest; jpeg_read_image("input.jpg", source); jpeg_read_image("input.jpg", dest); BlurGaussSelective<ViewType,ViewType> filter; filter.apply(const_view(source),const_view(dest)); But the compiler gives me this error: ../src/RotoscoperApplication.cpp: In member function ‘void Rotoscoper::Application::rotoscope()’: ../src/RotoscoperApplication.cpp:73: error: no matching function for call to ‘Rotoscoper::BlurGaussSelective<boost::mpl::vector<boost::gil::image_view<boost::gil::memory_based_2d_locator<boost::gil::memory_based_step_iterator<boost::gil::rgb8_pixel_t*> > >, boost::gil::image_view<boost::gil::memory_based_2d_locator<boost::gil::memory_based_step_iterator<boost::gil::gray8_pixel_t*> > >, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na>, boost::mpl::vector<boost::gil::image_view<boost::gil::memory_based_2d_locator<boost::gil::memory_based_step_iterator<boost::gil::rgb8_pixel_t*> > >, boost::gil::image_view<boost::gil::memory_based_2d_locator<boost::gil::memory_based_step_iterator<boost::gil::gray8_pixel_t*> > >, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na> >::apply(boost::gil::any_image_view<boost::mpl::v_item<boost::gil::image_view<boost::gil::memory_based_2d_locator<boost::gil::memory_based_step_iterator<const boost::gil::gray8c_pixel_t*> > >, boost::mpl::v_item<boost::gil::image_view<boost::gil::memory_based_2d_locator<boost::gil::memory_based_step_iterator<const boost::gil::rgb8c_pixel_t*> > >, boost::mpl::vector0<mpl_::na>, 0>, 0> >, boost::gil::any_image_view<boost::mpl::v_item<boost::gil::image_view<boost::gil::memory_based_2d_locator<boost::gil::memory_based_step_iterator<const boost::gil::gray8c_pixel_t*> > >, boost::mpl::v_item<boost::gil::image_view<boost::gil::memory_based_2d_locator<boost::gil::memory_based_step_iterator<const boost::gil::rgb8c_pixel_t*> > >, boost::mpl::vector0<mpl_::na>, 0>, 0> >)’ ../src/RotoscoperBlurGaussSelective.hpp:119: note: candidates are: void Rotoscoper::BlurGaussSelective<TImage1, TImage2>::apply(const boost::gil::any_image_view<IVTypes>&, const boost::gil::any_image_view<Types2>&) [with TImage1 = boost::mpl::vector<boost::gil::image_view<boost::gil::memory_based_2d_locator<boost::gil::memory_based_step_iterator<boost::gil::rgb8_pixel_t*> > >, boost::gil::image_view<boost::gil::memory_based_2d_locator<boost::gil::memory_based_step_iterator<boost::gil::gray8_pixel_t*> > >, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na>, TImage2 = boost::mpl::vector<boost::gil::image_view<boost::gil::memory_based_2d_locator<boost::gil::memory_based_step_iterator<boost::gil::rgb8_pixel_t*> > >, boost::gil::image_view<boost::gil::memory_based_2d_locator<boost::gil::memory_based_step_iterator<boost::gil::gray8_pixel_t*> > >, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na>] make: *** [src/RotoscoperApplication.o] Error 1 Which template type I should use when I instantiate the BlurGaussSelectiveClass? Thanks in advance. Greetings, Raffaele -- View this message in context: http://www.nabble.com/Template-class-and-any_image_view-tp25891719p25891719.... Sent from the Boost - Users mailing list archive at Nabble.com.

Hi Raffaele, I have made some changes and the code now compiles with VC++ 2005. I believe that your error was to define the template parameter for BlurGaussSelective class. You wrote this: BlurGaussSelective<ViewType,ViewType> filter; but this is correct: BlurGaussSelective< any_image<ImageType>::const_view_t, any_image<ImageType>::const_view_t > filter; Also, you don't need two template parameters. Please review the code below and let me know if you have questions or remarks. #include <boost\cstdint.hpp> #include <boost\gil\gil_all.hpp> #include <boost\gil\extension\io\jpeg_dynamic_io.hpp> #include <boost\gil\extension\dynamic_image\dynamic_image_all.hpp> using namespace std; using namespace boost; using namespace gil; template <typename TView> class Filter { public: virtual ~Filter(); virtual void setParameter(uint8_t id, float value); virtual void apply( TView& source, TView& destination) = 0; protected: Filter(); }; template <typename TView > class BlurGaussSelective : public Filter<TView> { public: BlurGaussSelective(); virtual ~BlurGaussSelective(); void setParameter(uint8_t id, float value); void apply( TView& source, TView& destination ); }; int main(int argc, char* argv[]) { typedef mpl::vector<rgb8_image_t,gray8_image_t> ImageType; typedef mpl::vector<rgb8_view_t,gray8_view_t> ViewType; any_image<ImageType> source; any_image<ImageType> dest; jpeg_read_image("input.jpg", source); jpeg_read_image("input.jpg", dest); BlurGaussSelective< any_image<ImageType>::const_view_t > filter; filter.apply(const_view(source),const_view(dest)); } Regards, Christian

Thanks a lot, it works perfectly. Christian Henning wrote:
Also, you don't need two template parameters.
I've however used two template types to be able to differentiate between view and constant view. So the filter instantiation becomes: BlurGaussSelective<any_image<ImageType>::const_view_t,any_image<ImageType>::view_t
filter; apply(const_view(source),view(dest));
Best regards, Raffaele -- View this message in context: http://www.nabble.com/Template-class-and-any_image_view-tp25891719p25900438.... Sent from the Boost - Users mailing list archive at Nabble.com.
participants (2)
-
Christian Henning
-
tatta