Then I think the function vidl2_convert_wrap_in_view is more suitable for me. I'll give it a try.


On Tue, Jul 1, 2008 at 11:42 AM, Matt Leotta <> wrote:

vidl2_convert_to_view always performs a deep copy of the image data
(it may also perform some conversion if the frame encoding is not
supported by vil).  This means it is safe and should always work.  The
resulting vil_image_view will "own" its image data.

vidl2_convert_wrap_in_view tries to perform a shallow copy.  That is,
it tries to construct a vil_image_view that is a wrapper around the
same memory used by the vidl2_frame.  This will always be faster than
vidl2_convert_to_view, but may not always work.  If the frame encoding
is not supported by vil it will return a null smart pointer.  Also, it
is generally not safe to use the resulting vil image after the
original vidl2_frame is destroyed.  In some cases, like when the
vidl2_frame is created from a vil_image_view and then the frame is
converted back to a vil_image_view, the memory is shared (with a smart
pointer) and it is safe to delete the original structures.

In short, you should use vidl2_convert_to_view unless you are looking
for speed and know what you are doing.


On Tue, Jul 1, 2008 at 10:20 AM, Crístian Viana
<> wrote:
> Thank you guys, now I can use the convert functions! And now I understand
> more about smart pointers :)
> But there's one last doubt: what's the difference between the functions
> vidl2_convert_to_view and vidl2_convert_wrap_in_view? I want to get a
> vil_image_view out of a vidl2_frame to convert it to another format (in
> Java), so which of those functions is better for me?
> On Mon, Jun 30, 2008 at 7:12 PM, Peter Vanroose <>
> wrote:
>> > > void* data = istream->current_frame()->data();
>> > >
>> >
>> > I would avoid this last one.
>> > ... data will be deleted as soon as you make that assignment
>> > (since the smart pointer goes out of scope).  You end up with
>> > "data" pointing to deallocating memory.
>> Agreed. Thanks for pointing out.
>> That's actually the difference between "normal" pointers and smart
>> pointers!
>> By assigning istream->current_frame() to a variable of datatype
>> vidl2_frame_sptr, the counter will be incremented; when that variable goes
>> out of scope, the count is decremented (and the data deleted if this was the
>> last smart pointer referencing it).
>> --      Peter.
>>      ___________________________________________________
>> Sök efter kärleken!
>> Hitta din tvillingsjäl på Yahoo! Dejting:
> --
> Crístian Deives dos Santos Viana [aka CD1]
> Google Talk:

Crístian Deives dos Santos Viana [aka CD1]
Google Talk: