19 SECTION(
"a config file with no [dm] section, loading defaults" )
22 mx::app::writeConfigFile(
"/tmp/dm_test.conf", {
"none" }, {
"nada" }, {
"0" } );
24 mx::app::appConfigurator config;
32 config.readConfig(
"/tmp/dm_test.conf" );
37 REQUIRE( pdt.calibPath() ==
"/tmp/dmtest_calibs/dmtest" );
40 REQUIRE( pdt.shmimName() ==
"" );
44 SECTION(
"a config file with a [dm] section changing everything" )
47 std::vector<std::string> s, k, v;
50 k.push_back(
"calibPath" );
51 v.push_back(
"/tmp/dmtest_calibs2/dmtest2" );
53 mx::app::writeConfigFile(
"/tmp/dm_test.conf", s, k, v );
55 mx::app::appConfigurator config;
63 config.readConfig(
"/tmp/dm_test.conf" );
68 REQUIRE( pdt.calibPath() ==
"/tmp/dmtest_calibs2/dmtest2" );
82TEST_CASE(
"Test dmcomb detection, configuration, and manipulation",
"[dev::dm]" )
84 mx::ioutils::createDirectories(
"/tmp/dmtest/shm" );
87 snprintf( ppath,
sizeof( ppath ),
"%s=/tmp/dmtest/shm",
"MILK_SHM_DIR" );
90 mx::improc::milkImage<float> ch0, ch1, ch2, ch3, ch4, chT;
94 ch0.create(
"dmtest00", 50, 50 );
97 ch1.create(
"dmtest01", 50, 50 );
100 ch2.create(
"dmtest02", 50, 50 );
101 ch2().setConstant(3);
103 ch3.create(
"dmtest03", 50, 50 );
104 ch3().setConstant(4);
106 ch4.create(
"dmtest04", 50, 50 );
107 ch4().setConstant(5);
109 chT.create(
"dmtest", 50, 50 );
110 chT() = ch0() + ch1() + ch2() + ch3() + ch4();
113 catch(
const std::exception &e )
115 std::cerr <<
"dm_test: Exception creating dm channels: " << e.what() <<
'\n';
118 std::vector<std::string> s, k, v;
121 k.push_back(
"shmimName" );
122 v.push_back(
"dmtest" );
125 k.push_back(
"width" );
129 k.push_back(
"height" );
133 k.push_back(
"deltaChannels" );
134 v.push_back(
"dmtest02,dmtest03" );
136 mx::app::writeConfigFile(
"/tmp/dm_test.conf", s, k, v );
138 mx::app::appConfigurator config;
146 config.readConfig(
"/tmp/dm_test.conf" );
151 REQUIRE( pdt.shmimName() ==
"dmtest" );
159 int rows = pdt.instSatMap().rows();
160 REQUIRE( rows == 50 );
162 int cols = pdt.instSatMap().cols();
163 REQUIRE( cols == 50 );
165 rows = pdt.accumSatMap().rows();
166 REQUIRE( rows == 50 );
168 cols = pdt.accumSatMap().cols();
169 REQUIRE( cols == 50 );
171 rows = pdt.satPercMap().rows();
172 REQUIRE( rows == 50 );
174 cols = pdt.satPercMap().cols();
175 REQUIRE( cols == 50 );
177 int nc = pdt.numChannels();
180 size_t nd = pdt.deltaChannels().size();
183 const std::vector<size_t> ¬Deltas = pdt.notDeltas();
184 REQUIRE(notDeltas.size() == 3);
185 REQUIRE(notDeltas[0] == 0);
186 REQUIRE(notDeltas[1] == 1);
187 REQUIRE(notDeltas[2] == 4);
189 mx::improc::milkImage<float> outputShape;
193 outputShape.open(
"dmtest_shape");
199 REQUIRE(pass ==
true);
200 REQUIRE(outputShape.rows() == 50);
201 REQUIRE(outputShape.cols() == 50);
202 REQUIRE(outputShape().sum() == 0);
205 float sum = outputShape().sum();
206 REQUIRE(sum == (50*50)*(1+2+3+4+5));
208 mx::improc::milkImage<float> outputDelta;
212 outputDelta.open(
"dmtest_delta");
218 REQUIRE(pass ==
true);
219 REQUIRE(outputDelta.rows() == 50);
220 REQUIRE(outputDelta.cols() == 50);
221 REQUIRE(outputDelta().sum() == 0);
223 rows = pdt.totalFlat().rows();
224 REQUIRE( rows == 50 );
226 cols = pdt.totalFlat().cols();
227 REQUIRE( cols == 50 );
229 sum = pdt.totalFlat().sum();
234 sum = pdt.totalFlat().sum();
235 REQUIRE(sum == (50*50)*(1+2+5));
238 sum = outputShape().sum();
239 REQUIRE(sum == (50*50)*(1+2+3+4+5));
241 sum = outputDelta().sum();
242 REQUIRE(sum == (50*50)*(3+4));