[ITK-users] cannot save transform to file: Can't Create IO object

Sebastian Ordas sebastian.ordas at gmail.com
Mon May 23 20:42:38 EDT 2016


Thanks Matt,

The retrieved transformIO is null

I looked into my ITK 4.9 build and I am trying something like this:

itk::TransformFileWriterTemplate<double>::Pointer writer =
     itk::TransformFileWriterTemplate<double>::New();

// are .tfm and .txt the right file extensions?

itk::TransformIOFactoryTemplate<double>::TransformIOBasePointer 
tranformIO = itk::TransformIOFactoryTemplate<double>::CreateTransformIO( 
"fiducials_transform.tfm", 
itk::TransformIOFactoryFileModeType::WriteMode );

   if (tranformIO.IsNull())
   {
     MITK_ERROR << "transform IO is null";
     return;
   }

writer->SetTransformIO(tranformIO);

writer->SetFileName("fiducials_transform.tfm");

writer->SetInput(transform);

try
   {
     writer->Update();
   }
   catch (itk::ExceptionObject& e)
   {
     MITK_ERROR << "Caught exception: " << e.GetDescription();
     QMessageBox::information( this, "Save transform", "Could not save 
transform. See error log for details." );
   }

thank you
sebastian


On 23/05/2016 05:35 p.m., Matt McCormick wrote:
> Hello Sebastian,
>
> By running against ITK with this patch checked out:
>
>    http://review.source.kitware.com/#/c/21115/
>
> the error message will state what transform IO classes are registered.
>
> HTH,
> Matt
>
> On Mon, May 23, 2016 at 4:29 PM, Sebastian Ordas
> <sebastian.ordas at gmail.com> wrote:
>> Hello, I am trying to run the code bellow from my application (using ITK
>> 4.9)  but I get the following error :
>>
>> ERROR: Caught exception: itk::ERROR:
>> TransformFileWriterTemplate(000000000CD770E0): Can't Create IO object
>> for file test.tfm
>>
>> I am sure that if I test it from a simple test application this should work,
>> but I am trying to understand what I am missing from within my project
>> (maybe some factory not yet registered or even some registration-related
>> module not yet enabled in cmake?)
>>
>> typedef itk::VersorRigid3DTransform< double > TransformType;
>> TransformType::Pointer trf = TransformType::New();
>> trf->SetIdentity();
>>
>> itk::TransformFileWriterTemplate<double>::Pointer writer =
>>      itk::TransformFileWriterTemplate<double>::New();
>>
>>    writer->SetFileName("test.tfm");
>>    writer->SetInput(trf);
>>
>>    try
>>    {
>>      writer->Update();
>>    }
>>    catch (itk::ExceptionObject& e)
>>    {
>>      std::cerr << "Caught exception: " << e.GetDescription() << std::endl;
>>    }
>>
>>
>> _____________________________________
>> 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://public.kitware.com/mailman/listinfo/insight-users
>>



More information about the Insight-users mailing list