aboutsummaryrefslogtreecommitdiff
path: root/svg-flatten/src/nopencv_test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'svg-flatten/src/nopencv_test.cpp')
-rw-r--r--svg-flatten/src/nopencv_test.cpp19
1 files changed, 7 insertions, 12 deletions
diff --git a/svg-flatten/src/nopencv_test.cpp b/svg-flatten/src/nopencv_test.cpp
index 77fbe30..5eedfe1 100644
--- a/svg-flatten/src/nopencv_test.cpp
+++ b/svg-flatten/src/nopencv_test.cpp
@@ -227,7 +227,7 @@ MU_TEST(test_round_trip_two_px) { testdata_roundtrip("testdata/two-p
MU_TEST(test_round_trip_two_px_inv) { testdata_roundtrip("testdata/two-px-inv.png"); }
static void test_polygon_area(const char *fn) {
- cerr << endl << "poly area test " << fn << endl;
+ //cerr << endl << "poly area test " << fn << endl;
Image32 ref_img;
mu_assert(ref_img.load(fn), "Input image failed to load");
ref_img.binarize();
@@ -245,23 +245,20 @@ static void test_polygon_area(const char *fn) {
}
double pos_sum = 0.0;
- double neg_sum = 0.0;
- gerbolyze::nopencv::find_blobs(ref_img, [fn, white_px_count, black_px_count, &pos_sum, &neg_sum](Polygon_i& poly, ContourPolarity pol) {
+ double neg_sum = black_px_count;
+ gerbolyze::nopencv::find_blobs(ref_img, [&pos_sum, &neg_sum](Polygon_i& poly, ContourPolarity pol) {
double area = polygon_area(poly);
- cerr << endl << fn << ": " << area << pos_sum << " / " << neg_sum << " -- " << white_px_count << " / " << black_px_count << endl;
+ //cerr << endl << fn << ": " << area << " " << pos_sum << " / " << neg_sum << " -- " << white_px_count << " / " << black_px_count << " GOT: " << poly.size() << " w/ " << pol << endl;
mu_assert(fabs(area) > 0.99, "Polygon smaller than a single pixel");
mu_assert((pol == CP_CONTOUR) == (area >= 0), "Polygon area has incorrect sign");
- if (area > 0) {
- pos_sum += area;
- } else {
- neg_sum -= area;
- }
+ pos_sum += area;
+ neg_sum -= area;
});
mu_assert(pos_sum - white_px_count < 0.01, "Calculated area outside tolerance");
mu_assert(neg_sum - black_px_count < 0.01, "Calculated area outside tolerance");
- cerr << endl << "poly area test " << fn << " done" << endl;
+ //cerr << endl << "poly area test " << fn << " done" << endl;
}
MU_TEST(test_polygon_area_blank) { test_polygon_area("testdata/blank.png"); }
@@ -346,7 +343,6 @@ MU_TEST(chain_approx_test_two_px_inv) { chain_approx_test("testdata/two-
MU_TEST_SUITE(nopencv_contours_suite) {
- /*
MU_RUN_TEST(test_complex_example_from_paper);
MU_RUN_TEST(test_round_trip_blank);
MU_RUN_TEST(test_round_trip_white);
@@ -379,7 +375,6 @@ MU_TEST_SUITE(nopencv_contours_suite) {
MU_RUN_TEST(chain_approx_test_two_blobs);
MU_RUN_TEST(chain_approx_test_two_px);
MU_RUN_TEST(chain_approx_test_two_px_inv);
- */
MU_RUN_TEST(test_polygon_area_blank);
MU_RUN_TEST(test_polygon_area_white);
MU_RUN_TEST(test_polygon_area_blob_border_w);