Commit 9b577891 authored by Guillaume Pasero's avatar Guillaume Pasero

DOC: use environments cmakecode, cppcode, ...

parent 7c7e5fec
......@@ -112,17 +112,17 @@ section~\ref{chapter:WriteAFilter}, page~\pageref{chapter:WriteAFilter}.
The first step is to write a persistent mean image filter. We need to
include the appropriate header :
\begin{minted}{cpp}
\begin{cppcode}
#include "otbPersistentImageFilter.h"
\end{minted}
\end{cppcode}
Then, we declare the class prototype as follows:
\begin{minted}{cpp}
\begin{cppcode}
template<class TInputImage >
class ITK_EXPORT PersistentMeanImageFilter :
public PersistentImageFilter<TInputImage, TInputImage>
\end{minted}
\end{cppcode}
Since the output image will only be used for streaming purpose, we do
not need to declare different input and output template types.
......@@ -131,14 +131,14 @@ In the \emph{private} section of the class, we will declare a member which
will be used to store temporary results, and a member which will be
used to store the final result.
\begin{minted}{cpp}
\begin{cppcode}
private:
// Temporary results container
std::vector<PixelType> m_TemporarySums;
// Final result member
double m_Mean;
\end{minted}
\end{cppcode}
Next, we will write the \verb?Reset()? method implementation in the
\emph{protected} section of the class. Proper allocation of the
......@@ -146,7 +146,7 @@ temporary results container with respect to the number of threads is
handled here.
\begin{minted}{cpp}
\begin{cppcode}
protected:
virtual void Reset()
{
......@@ -160,13 +160,13 @@ protected:
// Reset the final result
m_Mean = 0.;
}
\end{minted}
\end{cppcode}
Now, we need to write the \verb?ThreadedGenerateData()? methods (also
in the \emph{protected} section), were
temporary results will be computed for each piece of stream.
\begin{minted}{cpp}
\begin{cppcode}
virtual void ThreadedGenerateData(const RegionType&
outputRegionForThread, itk::ThreadIdType threadId)
{
......@@ -190,12 +190,12 @@ for (it.GoToBegin(); !it.IsAtEnd(); ++it, progress.CompletedPixel())
m_TemporarySums[threadId]+= value;
}
\end{minted}
\end{cppcode}
Last, we need to define the \verb?Synthetize()? method (still in the
\emph{protected} section), which will yield the final results:
\begin{minted}{cpp}
\begin{cppcode}
virtual void Synthetize()
{
// For each thread
......@@ -214,7 +214,7 @@ if(nbPixels!=0)
m_Mean/=nbPixels;
}
}
\end{minted}
\end{cppcode}
\subsection{Second step: Decorating the filter and using it}
......@@ -222,41 +222,41 @@ Now, to use the filter, one only has to decorate it with the
\doxygen{otb}{PersistentFilterStreamingDecorator}. First step is
to include the appropriate header:
\begin{minted}{cpp}
\begin{cppcode}
#include "otbPersistentMeanImageFilter.h"
#include "otbPersistentFilterStreamingDecorator.h"
\end{minted}
\end{cppcode}
Then, we decorate the filter with some typedefs:
\begin{minted}{cpp}
\begin{cppcode}
typedef otb::PersistentMeanImageFilter<ImageType>
PersitentMeanFilterType;
typedef otb::PersistentFilterStreamingDecorator
< PersitentMeanFilterType> StreamingMeanFilterType;
\end{minted}
\end{cppcode}
Now, the decorated filter can be used like any standard filter:
\begin{minted}{cpp}
\begin{cppcode}
StreamingMeanFilterType::Pointer filter =
StreamingMeanFilterType::New();
filter->SetInput(reader->GetOutput());
filter->Update();
\end{minted}
\end{cppcode}
\subsection{Third step: one class to rule them all}
It is often convenient to avoid the few typedefs of the previous
section by deriving a new class from the decorated filter:
\begin{minted}{cpp}
\begin{cppcode}
template<class TInputImage >
class ITK_EXPORT StreamingMeanImageFilter :
public PersistentFilterStreamingDecorator<
PersistentImageFilter<TInputImage, TInputImage> >
\end{minted}
\end{cppcode}
This also allows to redefine setters and getters for parameters,
avoiding to call the \verb?GetFilter()? method to set them.
......@@ -36,9 +36,7 @@ directory. The \code{CMakeLists.txt} will be very similar between your projects.
Open the \code{CMakeLists.txt} file and write in the few lines:
\begin{small}
\begin{verbatim}
\begin{cmakecode}
PROJECT(Tutorials)
cmake_minimum_required(VERSION 2.6)
......@@ -53,8 +51,7 @@ ENDIF(OTB_FOUND)
ADD_EXECUTABLE(HelloWorldOTB HelloWorldOTB.cxx )
TARGET_LINK_LIBRARIES(HelloWorldOTB ${OTB_LIBRARIES})
\end{verbatim}
\end{small}
\end{cmakecode}
The first line defines the name of your project as it appears in Visual Studio
......@@ -102,8 +99,7 @@ Follow the following steps:
\item Create a CMakeLists.txt into the src repository with the following lines:
\begin{verbatim}
\begin{cmakecode}
project(MyFirstProcessing)
cmake_minimum_required(VERSION 2.8)
......@@ -114,10 +110,11 @@ include(${OTB_USE_FILE})
add_executable(MyFirstProcessing MyFirstProcessing.cxx )
target_link_libraries(MyFirstProcessing ${OTB_LIBRARIES} )
\end{verbatim}
\end{cmakecode}
\item Create a MyFirstProcessing.cxx into the src repository with the following lines:
\begin{verbatim}
\begin{cppcode}
#include "otbImage.h"
#include "otbVectorImage.h"
#include "otbImageFileReader.h"
......@@ -151,9 +148,9 @@ int main(int argc, char* argv[])
return EXIT_SUCCESS;
}
\end{verbatim}
\end{cppcode}
\item create a file named BuildMyFirstProcessing.bat into the MyFirstCode directory with the following lines:
\begin{verbatim}
\begin{batcode}
@echo off
set /A ARGS_COUNT=0
......@@ -193,7 +190,7 @@ echo You need to run this script from an OSGeo4W shell
GOTO :END
:END
\end{verbatim}
\end{batcode}
\item into a OSGEo4W shell, run the configure.bat with the right arguments: full path to your src directory, full path to your build directory, full path to the place where find OTBConfig.cmake file (should be C:\textbackslash path\textbackslash to\textbackslash MyOTBDir\textbackslash install\textbackslash lib\textbackslash otb).
\item into the OSGeo4W shell, open the MyFirstProcessing.sln
\item build the solution
......@@ -212,12 +209,10 @@ write images and the basics of the pipeline system.
First, let's add the following lines at the end of the \code{CMakeLists.txt}
file:
\begin{small}
\begin{verbatim}
\begin{cmakecode}
ADD_EXECUTABLE(Pipeline Pipeline.cxx )
TARGET_LINK_LIBRARIES(Pipeline ${OTB_LIBRARIES})
\end{verbatim}
\end{small}
\end{cmakecode}
Now, create a \code{Pipeline.cxx} file.
......@@ -264,12 +259,10 @@ reader and the writer.
Let's first add the 2 following lines to the \code{CMakeLists.txt} file:
\begin{small}
\begin{verbatim}
\begin{cmakecode}
ADD_EXECUTABLE(FilteringPipeline FilteringPipeline.cxx )
TARGET_LINK_LIBRARIES(FilteringPipeline ${OTB_LIBRARIES})
\end{verbatim}
\end{small}
\end{cmakecode}
\input{FilteringPipeline.tex}
......@@ -303,12 +296,10 @@ To realize this conversion, we will use the
Add the two lines to the \code{CMakeLists.txt} file:
\begin{small}
\begin{verbatim}
\begin{cmakecode}
ADD_EXECUTABLE(ScalingPipeline ScalingPipeline.cxx )
TARGET_LINK_LIBRARIES(ScalingPipeline ${OTB_LIBRARIES})
\end{verbatim}
\end{small}
\end{cmakecode}
\input{ScalingPipeline}
......@@ -331,12 +322,10 @@ process multispectral images.
Add the following lines in the \code{CMakeLists.txt} file:
\begin{small}
\begin{verbatim}
\begin{cmakecode}
ADD_EXECUTABLE(Multispectral Multispectral.cxx )
TARGET_LINK_LIBRARIES(Multispectral ${OTB_LIBRARIES})
\end{verbatim}
\end{small}
\end{cmakecode}
\input{Multispectral}
......@@ -355,12 +344,10 @@ try it!
Add the following lines in the \code{CMakeLists.txt} file:
\begin{small}
\begin{verbatim}
\begin{cmakecode}
ADD_EXECUTABLE(SmarterFilteringPipeline SmarterFilteringPipeline.cxx )
TARGET_LINK_LIBRARIES(SmarterFilteringPipeline ${OTB_LIBRARIES})
\end{verbatim}
\end{small}
\end{cmakecode}
\input{SmarterFilteringPipeline}
......@@ -410,12 +397,10 @@ To get the best of the image processing algorithms, you want to combine these da
First you need to add the following lines in the \code{CMakeLists.txt} file:
\begin{small}
\begin{verbatim}
\begin{cmakecode}
ADD_EXECUTABLE(OrthoFusion OrthoFusion.cxx)
TARGET_LINK_LIBRARIES(OrthoFusion ${OTB_LIBRARIES})
\end{verbatim}
\end{small}
\end{cmakecode}
\input{OrthoFusion}
......
......@@ -248,12 +248,12 @@ in order to launch each internal application. The order should be compatible wit
image parameter connexions. If you want to do "in-memory" connexions, you can do it between
two calls to \code{ExecuteInternal()}, for instance :
\begin{minted}{cpp}
\begin{cppcode}
ExecuteInternal("a");
GetInternalApplication("b")->SetParameterInputImage("in",
GetInternalApplication("a")->GetParameterOutputImage("out"));
ExecuteInternal("b");
\end{minted}
\end{cppcode}
The application BundleToPerfectSensor is a simple example of composite applications.
For a more complex example, you can check the application TrainImagesClassifier.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment