[Insight-users] Java wrappers runtime errors
Jarek Sacha
jarek at ieee.org
Sat, 03 Apr 2004 11:13:32 -0500
I am getting ITK internal runtime errors while attempting to use Java
wrappers. Even the the example provided in the distribution does not
work. I tried to rebuild ITK from scratch with todays CVS, the error
persists (tested on Fedora Linux + Sun's Java 1.5). Any hints how to
resolve this are very appreciated.
For instance while running "cannyEdgeDetectionImageFilter.java" I am
getting runtime error:
Exception in thread "main" java.lang.RuntimeException:
/home/local/src/Insight/Code/Common/itkImageBase.txx:167:
itk::ERROR: Image(0x81a0af0): itk::ImageBase::CopyInformation() cannot
cast PKN3itk10DataObjectE to PKN3itk9ImageBaseILj2EEE
at
InsightToolkit.itkImageFileWriterJNI.itkImageFileWriterUS2_Pointer_Update(Native
Method)
at
InsightToolkit.itkImageFileWriterUS2_Pointer.Update(itkImageFileWriterUS2_Pointer.java:119)
at
cannyEdgeDetectionImageFilter.main(cannyEdgeDetectionImageFilter.java:22)
I modified the example code the explicitly call each filter to have a
better idea where the error is happening. The error is generated when
"canny" filter itself is getting updated. Similar happens with other
filters, for instance BinaryDilateImageFilter and MedianImageFilter.
However, the readers and writers seems to work fine. A sample program:
itkImageFileReaderF2_Pointer reader =
itkImageFileReaderF2.itkImageFileReaderF2_New();
reader.SetFileName(inFile);
reader.Update();
itkBinaryDilateImageFilterF2F2_Pointer filter =
itkBinaryDilateImageFilterF2F2.itkBinaryDilateImageFilterF2F2_New();
filter.SetInput(reader.GetOutput());
filter.Update();
itkImageFileWriterF2_Pointer writer =
itkImageFileWriterF2.itkImageFileWriterF2_New();
writer.SetFileName(outFile);
writer.SetInput(filter.GetOutput());
writer.Update();
correctly copies from input to output. Also corresponding examples in
Python seems to work fine and all ITK tests are passed fine. So the
problem seems to be somewhere in the Java wrapping code.
Hints how to resolve this are appreciated,
Jarek