[Insight-users] Help with Video Stream
Franck P. Vidal
franck.p.vidal at gmail.com
Fri May 17 03:28:26 EDT 2013
Hi Xiaoxiao,
examples run well as there is some filtering on the input stream.
If I do some filtering on the input stream, it kinda works as I get 3 frames that keep looping.
What I just did is as follows:
------------------------------------------------------------------------------------------------------------------------
…. ….
// Cache some data
m_total_frame_number = m_p_file_reader->GetNumberOfFrames();
m_frames_per_second = m_p_file_reader->GetFramesPerSecond();
m_duration = double(m_total_frame_number) / double(m_frames_per_second);
// Save the data
m_p_stream_data = m_p_file_reader->GetOutput();
if (m_p_stream_data->GetFrameBuffer())
{
m_p_stream_data->GetFrameBuffer()->SetNumberOfBuffers(m_total_frame_number);
}
m_p_current_frame = m_p_stream_data->GetFrame(m_current_frame);
------------------------------------------------------------------------------------------------------------------------
now m_p_current_frame is not null.
So it works, but is it the right approach for ITK?
Cheers,
Franck
On 17 May 2013, at 03:29, Xiaoxiao Liu <xiaoxiao.liu at kitware.com> wrote:
> Hi Franck,
> Are u able to run all the video related tests in ITK? I would first make sure the ITK tests can pass on your system to rule out potential third party lib compatibility problems.
>
>
>
>
> -
>
> Sent from my iPad
>
> On May 16, 2013, at 5:07 PM, "Franck P. Vidal" <franck.p.vidal at gmail.com> wrote:
>
>> Hello,
>>
>> I have some code to read an AVI file.
>> Get the method GetFrame of the VideoStream returns NULL.
>>
>>
>> -------------------------------------------------------------------------------------
>> typedef unsigned char PixelType;
>> typedef itk::Image<PixelType, 2> FrameType;
>> typedef itk::VideoStream<FrameType> VideoType;
>>
>> typename itk::VideoFileReader<VideoType>::Pointer m_p_file_reader;
>> typename VideoType::Pointer m_p_stream_data;
>> typename FrameType::Pointer m_p_current_frame;
>>
>> … … …
>>
>> try
>> {
>> // Set the current frame to be the first frame
>> m_current_frame = 0;
>>
>> // Load the IO factory for video files
>> itk::ObjectFactoryBase::RegisterFactory(itk::OpenCVVideoIOFactory::New());
>>
>> // Create the file reader
>> m_p_file_reader = itk::VideoFileReader<VideoType>::New();
>>
>> // Set the file name
>> m_p_file_reader->SetFileName(aFileName);
>>
>> // Load the file
>> m_p_file_reader->Update();
>> m_p_file_reader->UpdateOutputInformation();
>> m_p_stream_data = m_p_file_reader->GetOutput();
>>
>> m_p_current_frame = m_p_stream_data->GetFrame(m_current_frame);
>>
>> … … …
>>
>>
>> }
>> catch (std::exception& e)
>> {
>> std::cerr << "WARNING: " << e.what() << std::endl;
>> return (false);
>> }
>> -------------------------------------------------------------------------------------
>>
>> Any idea why 'm_p_current_frame' is always NULL???
>>
>> Cheers,
>>
>> _____________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Kitware offers ITK Training Courses, for more information visit:
>> http://www.kitware.com/products/protraining.php
>>
>> Please keep messages on-topic and check the ITK FAQ at:
>> http://www.itk.org/Wiki/ITK_FAQ
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.itk.org/mailman/listinfo/insight-users
More information about the Insight-users
mailing list