Generalities
test and benchmark programs are built if the build process is configured to create the "test"
build target. Two ways to do this :
- add the option
"--test"
when configuring Smil with the script config-smil
;
- use
ccmake
to enable the option "BUILD_TEST"
.
- Note
- test and benchmark programs follow the naming convention :
test_XXXX.cpp
and bench_XXXX.cpp
.
test programs
See below an example of test program (this example is in the dev-tools
directory in the source tree : dev-tools/test_template.cpp
).
Note the call to the function pathTestImage()
. This function is defined in the header Smil-build.h
. When you call this function, it will search for an image in the images
directory of the source tree. If it doesn't find it there, it will try to get it in the images
directory of Smil web server.
#include "DMorphoMeasures.hpp"
#include "Smil-build.h"
using namespace smil;
class TestErode : public TestCase
{
virtual void run()
{
char *path;
path = pathTestImage("gray/lena.png");
Image<UINT8> imIn(path);
Image<UINT8> ImOut(imIn);
path = pathTestImage("gray/lena-erode.png");
Image<UINT8> imTruth(path);
TEST_ASSERT(imOut == imTruth);
if (retVal != RES_OK)
imOut.printSelf();
}
};
class TestDilate : public TestCase
{
virtual void run()
{
char *path;
path = pathTestImage("gray/lena.png");
Image<UINT8> imIn(path);
Image<UINT8> ImOut(imIn);
path = pathTestImage("gray/lena-dilate.png");
Image<UINT8> imTruth(path);
TEST_ASSERT(imOut == imTruth);
if (retVal != RES_OK)
imOut.printSelf();
}
};
int main()
{
TestSuite ts;
ADD_TEST(ts, TestErode);
ADD_TEST(ts, TestDilate);
return ts.run();
}
RES_T erode(const Image< T > &imIn, Image< T > &imOut, const StrElt &se=DEFAULT_SE, const T borderVal=ImDtTypes< T >::max())
erode() - Morphological grayscale erosion
Definition: DMorphoBase.hpp:112
RES_T dilate(const Image< T > &imIn, Image< T > &imOut, const StrElt &se=DEFAULT_SE, const T borderVal=ImDtTypes< T >::min())
dilate() - Morphological grayscale dilation
Definition: DMorphoBase.hpp:65
There are two ways to launch the built test programs (in the build tree).
- launch all tests :
- launch a single test (as an example) :
bench programs
See below an example of benchmark program (this example is in the dev-tools
directory in the source tree : dev-tools/bench_template.cpp
).
#include "Core/include/DCore.h"
#include "DMorpho.h"
using namespace smil;
int main()
{
Image<UINT8> im1(5562, 7949);
Image<UINT8> im2(im1);
UINT BENCH_NRUNS = 1E2;
BENCH_IMG_STR(
dilate,
"hSE", im1, im2, hSE());
BENCH_IMG_STR(
dilate,
"sSE", im1, im2, sSE());
BENCH_IMG_STR(
dilate,
"CrossSE", im1, im2, CrossSE());
BENCH_IMG_STR(
open,
"hSE", im1, im2, hSE());
BENCH_IMG_STR(
open,
"sSE", im1, im2, sSE());
BENCH_IMG_STR(
open,
"CrossSE", im1, im2, CrossSE());
}
RES_T open(const Image< T > &imIn, Image< T > &imOut, const StrElt &se=DEFAULT_SE)
open() - Morphological grayscale opening
Definition: DMorphoFilter.hpp:123
There are two ways to launch the built benchmark programs (in the build tree).
- launch all benchmarks :
for b in bin/bench*
do
printf "====== %-24s ======\n" $(basename $b)
$b
done
- launch a single benchmark (as an example) :