|
Boost Users : |
Subject: Re: [Boost-users] [boost::gil] Type conversion in Generic Image Library
From: Nestor Morales Hernández (nestor_at_[hidden])
Date: 2013-08-01 04:50:04
Ok, I tried to change typedefs to make things more clear, but I guess I
have had a mess. I will try to explain it again:
I am trying to use the class CpuPreprocessor publicly available here:
https://bitbucket.org/rodrigob/doppia/src/8b784ff23eeab329d02ebe2eb1bc4775e277444e/src/video_input/preprocessing/CpuPreprocessor.hpp?at=default
To do so, I create a shared pointer pointing to an object of the class:
shared_ptr<CpuPreprocessor> homography_rectifier_p;
homography_rectifier_p.reset(new
CpuPreprocessor(video_input_p->get_left_image().dimensions(),
video_input_p->get_stereo_calibration(),
options));
Then, I try to execute the `run` method of the class CpuPreprocessor, which
has the prototype:
void run(const AbstractPreprocessor::input_image_view_t& input, const int
camera_index,
const AbstractPreprocessor::output_image_view_t &output);
// I get the input images
AbstractStereoMatcher::input_image_view_t
input_left_view(video_input_p->get_left_image()),
input_right_view(video_input_p->get_right_image());
// And then I try to put them as input of the run function, doing the same
process followed in
https://bitbucket.org/rodrigob/doppia/src/8b784ff23eeab329d02ebe2eb1bc4775e277444e/src/video_input/VideoFromFiles.cpp?at=default#cl-293
AbstractVideoInput::input_image_t
rectified_left_view(input_left_view._dynamic_cast<AbstractVideoInput::input_image_t>()),
rectified_right_view(input_right_view._dynamic_cast<AbstractVideoInput::input_image_t>());
homography_rectifier_p->run(input_left_view, 0,
boost::gil::view(rectified_left_view));
// The ouput of the compiler is the following:
/home/nestor/Dropbox/KULeuven/projects/doppia/src/applications/stixel_world_improved/StixelWorldApplication.cpp:296:102:
required from here
/home/nestor/Dropbox/KULeuven/projects/doppia/libs/boost/gil/image_view.hpp:101:143:
error: const class
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::pixel<unsigned char,
boost::gil::layout<boost::mpl::vector3<boost::gil::red_t,
boost::gil::green_t, boost::gil::blue_t> > >*> > >,
boost::mpl::v_item<boost::gil::image_view<boost::gil::memory_based_2d_locator<boost::gil::memory_based_step_iterator<const
boost::gil::pixel<unsigned char,
boost::gil::layout<boost::mpl::vector1<boost::gil::gray_color_t> > >*> > >,
boost::mpl::vector0<mpl_::na>, 0>, 0> > has no member named pixels
make[2]: *** [CMakeFiles/stixel_world.dir/StixelWorldApplication.cpp.o]
Error 1
// Finally, the typedefs for the types of the variables used in this post
are the following:
//From
https://bitbucket.org/rodrigob/doppia/src/8b784ff23eeab329d02ebe2eb1bc4775e277444e/src/video_input/preprocessing/AbstractPreprocessor.hpp?at=default#cl-26
typedef AbstractVideoInput::input_image_view_t input_image_view_t;
typedef AbstractVideoInput::input_image_t::view_t output_image_view_t;
typedef AbstractVideoInput::input_image_view_t::point_t dimensions_t;
//From
https://bitbucket.org/rodrigob/doppia/src/8b784ff23eeab329d02ebe2eb1bc4775e277444e/src/stereo_matching/AbstractStereoMatcher.hpp?at=default#cl-25
/// input image are either rgb8 or gray8
typedef boost::mpl::vector<boost::gil::gray8_image_t,
boost::gil::rgb8_image_t> input_images_t;
// FIXME some applications may need float instead of bits8
typedef boost::gil::gray8_image_t disparity_map_t;
typedef boost::gil::rgb8_image_t input_image_t;
typedef boost::gil::rgb8c_view_t input_image_view_t;
typedef input_image_view_t::point_t dimensions_t;
I hope somebody can help me with that. As I said, I'm new on using Boost
Generic Image Library and it is driving me crazy.
Thank you in advance, best regards.
Néstor
2013/8/1 Nathan Crookston <nathan.crookston_at_[hidden]>
> Hi Néstor,
>
> Nestor Morales Hernández wrote:
>
>>
>> I currently have an image of the type ` boost::gil::rgb8c_view_t`. I need
>> to pass it to a function (from a code I don't mantain) with this prototype:
>>
>> void function(const boost::gil::rgb8c_view_t& input, const int index,
>> const boost::gil::rgb8c_view_t::view_t &output)
>>
>> I have created an output image by using the following syntax:
>>
>> boost::gil::rgb8c_view_t::view_t
>> output(input._dynamic_cast<boost::gil::rgb8c_view_t::view_t>());
>>
>> At this point, the compiler accepts the image output as input for the
>> function. However, I need the image back to the `boost::gil::rgb8c_view_t`
>> type. The question is:
>>
>> - Is it a correct way to allocate the image output?
>> - How do I transform it back to the type boost::gil::rgb8c_view_t?
>>
>>
> I'm having trouble parsing your syntax here. It looks like input is not
> really an rgb8c_view_t, rather its an any_image type. If it were the
> gil-specified typedef, there wouldn't be a _dynamic_cast member. Likewise
> output appears to be the same, with a nested view_t typedef.
>
> Are you saying that function is the prototype over which you have no
> control? It seems odd that it would have an output view which has
> immutable pixels (due to the 'c' in rgb8c) and which could not itself be
> swapped out for a different view (due to the fact that it's a view passed
> by const reference).
>
> I'm hoping there's been some mistake in copying pieces of your code into
> this email, otherwise there's only bad solutions to what you describe.
>
> HTH,
> Nate
>
>
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>
-- Néstor Morales Hernández Departamento ISAATC, Universidad de La Laguna e-mail: nestor_at_[hidden] Phone: (+34) 922 318 287
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net