5
5
#include " ImageSave.h"
6
6
#include " CaptureFailException.h"
7
7
#include " Specs.h"
8
+ #include < array>
8
9
9
10
int ThicknessGauge::getBaseLine () const {
10
11
return baseLine_;
@@ -147,7 +148,6 @@ bool ThicknessGauge::generatePlanarImage() {
147
148
if (!cap.isOpened ()) // check if we succeeded
148
149
throw CaptureFailException (" Error while attempting to open capture device." );
149
150
150
- Point textPoint (100 , 100 );
151
151
Size blurSize (3 , 3 );
152
152
153
153
const auto alpha = 0.5 ;
@@ -172,11 +172,17 @@ bool ThicknessGauge::generatePlanarImage() {
172
172
173
173
ImageSave is (" pic_x" , SaveType::Image_Png, Information::Basic);
174
174
175
- const int arrayLimit = 512 ; // shit c++11 ->
175
+ const auto arrayLimit = 512 ; // shit c++11 ->
176
176
177
177
Mat frame;
178
- Mat outputs[arrayLimit];
179
- vi pix_planarMap[arrayLimit];
178
+ vector<Mat> outputs (frameCount_);
179
+ vector<vi> pix_Planarmap (frameCount_ * 2 ); // using double of these for testing
180
+ vector<v2<double >> gabs (frameCount_);
181
+
182
+ // array<Mat, arrayLimit> outputs;
183
+ // array<vi, arrayLimit> pix_planarMap;
184
+ // array<v2<int>, arrayLimit> gabs;
185
+
180
186
vi nonZero;
181
187
182
188
// capture first frame
@@ -221,7 +227,6 @@ bool ThicknessGauge::generatePlanarImage() {
221
227
// createTrackbar("Kernel size: 2n +1", dilationWindowName, &dilation_size, max_ed_kernel_size);
222
228
}
223
229
224
-
225
230
// test for video recording
226
231
if (saveVideo_) {
227
232
is.SetInformation (Information::Full);
@@ -237,10 +242,14 @@ bool ThicknessGauge::generatePlanarImage() {
237
242
vector<Point2d> test_subPix;
238
243
239
244
// configure output stuff
240
- for (auto i = 0 ; i < frameCount_; ++i ) {
241
- pix_planarMap[i] .reserve (imageSize_.width );
245
+ for (auto & p : pix_Planarmap ) {
246
+ p .reserve (imageSize_.width );
242
247
}
243
248
249
+ // for (auto i = 0; i < frameCount_; ++i) {
250
+ // pix_planarMap[i].reserve(imageSize_.width);
251
+ // }
252
+
244
253
// start the process of gathering information for set frame count
245
254
246
255
while (true ) {
@@ -250,7 +259,7 @@ bool ThicknessGauge::generatePlanarImage() {
250
259
for (auto i = 0 ; i < frameCount_; ++i) {
251
260
252
261
outputs[i] = Mat::zeros (imageSize_, CV_8UC1);
253
- pix_planarMap[i] .clear ();
262
+ pix_Planarmap. at (i) .clear ();
254
263
255
264
cap >> frame;
256
265
@@ -272,15 +281,18 @@ bool ThicknessGauge::generatePlanarImage() {
272
281
if (showWindows_) imshow (outputWindowName, frame);
273
282
274
283
// extract information from the image, and make new output based on pixel intensity mean in Y-axis for each X point
275
- auto generateOk = miniCalc.generatePlanarPixels (frame, outputs[i], pix_planarMap[i] , test_subPix);
284
+ auto generateOk = miniCalc.generatePlanarPixels (frame, outputs[i], pix_Planarmap. at (i) , test_subPix);
276
285
277
286
if (!generateOk) {
278
287
cout << " Failed to map pixels to 2D plane for frame #" << to_string (i + 1 ) << " of " << to_string (frameCount_) << endl;
279
288
break ;
280
289
}
281
290
282
- findNonZero (outputs[i], pix_planarMap[arrayLimit - (1 + i)]);
283
- if (miniCalc.fillElementGabs (pix_planarMap[arrayLimit - (1 + i)], outputs[i], baseLine_)) {
291
+ findNonZero (outputs[i], pix_Planarmap[arrayLimit - (1 + i)]);
292
+ gabs.push_back (miniCalc.fillElementGabs (pix_Planarmap[arrayLimit - (1 + i)], outputs[i], baseLine_));
293
+ if (gabs.back ().hasValue ()) {
294
+ // at least one gab was filled..
295
+
284
296
// Mat temp(pix_planarMap[arrayLimit - (1 + i)]);
285
297
// cout << "TEMP cols " << temp.cols << endl;
286
298
// imshow("temp", temp);
0 commit comments