I am trying to build the Neural Networks ITK example, but the compile fails because of a missing localMetaConfiguration.h. This requires the MetaIO package, but I do not see where this is an option to turn on in CMake, so maybe it is a default module (?)
The file is present in my build directory as ./Modules/ThirdParty/MetaIO/src/MetaIO/src/localMetaConfiguration.h
The class documentation shows ITKZLIB as a dependency, but this may be a default module as well.
Can anyone tell me how to enable these modules and get localMegaConfiguration.h so that I can complete the compile?
The ITK Neural Networks have not had any attention in many years. It would be great if you wanted to work on using them, but I will let you know that the last time I used them they were very sub-optimal performance. I think that everyone has abandoned using this implementation many years ago in favor of other more performant tools.
I was able to reproduce a problem with the code from IJ article. I get a slightly different error message:
2>itkNNetIOTest.cxx
2>c:\users\dzenan\desktop\nn\itknnetfilereader.h(21): fatal error C1083: Cannot open include file: 'metaTypes.h': No such file or directory
You are building quite outdated code. Can you start off from this source file instead? Enable NeuralNetworks remote module when building ITK in order to use it.
You were missing include(${ITK_USE_FILE}) in your CMakeLists.txt. I also needed to rename itkNeuralNetworkIOTest into main so it reads int main(int argc,char* argv[]). Here is the modified CMakeLists.txt which worked for me:
project(NeuralNetworkExamples)
cmake_minimum_required(VERSION 3.11)
find_package(ITK REQUIRED) # includes all ITK modules
#find_package(ITK REQUIRED COMPONENTS NeuralNetworks) # only includes listed modules and their dependencies
include(${ITK_USE_FILE})
add_executable(NNTest itkNeuralNetworkIOTest.cxx)
target_link_libraries(NNTest ${ITK_LIBRARIES})
I still get more or less the same error:
Scanning dependencies of target NNTest
[ 50%] Building CXX object CMakeFiles/NNTest.dir/itkNeuralNetworkIOTest.cxx.o
In file included from /usr/include/ITK-5.0/itkNeuralNetworkFileReader.h:21:0,
from /home/melrobin/projects/NN/itkNeuralNetworkIOTest.cxx:19:
/usr/include/ITK-5.0/itkMetaImageIO.h:25:10: fatal error: metaObject.h: No such file or directory #include “metaObject.h”
^~~~~~~~~~~~~~
compilation terminated.
Where should metaObject.h be located? It appears that the MetaIO module is installed on my filesystem.
Since it is in the src directory, probably nowhere. But on Windows, I don’t usually “install” ITK. Or on Linux. I have many ITK builds and I use them from build directories.
But we have probably discovered the source of your problems. Bug: NeuralNetworks don’t work correctly when installed. Workaround: don’t install it, use it from build directory.
Can you try the workaround? When configuring the example, point to the build directory, not the install directory.