test suite does not deal with goldfeather vs SCS opencsg algorithm #269

Open
donbright opened this Issue Feb 2, 2013 · 14 comments

Projects

None yet

3 participants

Member

in some systems, one algorithm might work while the other might not.

how would it be possible to incorporate this into the test suite?

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Owner
kintel commented Feb 2, 2013

As a start, we could add a parameter to opencsgtest - I can look at it.

Member

i wish we could somehow auto-detect which algorithm should be 'preferred' on a particular machine....

Owner
kintel commented Feb 2, 2013

We could keep a database over known to be bad configurations, but this feels wrong - and is a never-ending effort as we don't have access to such machines for testing.

dougy83 commented Jun 17, 2014

This is still a problem in the current version (I have an HD4000). Re the autodetect, you could just render a test object in both SCS and Goldfeather and compare this to a correctly rendered model image (or CGAL-generated image) using L-2 (or L-1) norm of image difference. The render with the smallest difference norm corresponds to the algorithm to use. This could be done once when the software is first run on a machine.

Member

Do you have any links to open source L2 or L1 norm image difference code?

There is a problem with OpenGL in that it generates slightly different images on different platforms, given the same input. This has been an issue in the regression tests. There are not a lot of easy nice image diff programs out there, currently the main ones ive seen are

  • Imagemagick (what Marius created the test suite using)
  • phash
  • Hector Yee perceptualdiff

Thanks.

dougy83 commented Jun 20, 2014

Don,

The idea is to produce an output for each of SCS, Goldfeather and CGAL from a single scad model on the user's PC. The CGAL is used as the model, and is compared against the other two outputs using some distance metric. So if you can provide an array of pixels for each of these images, then it's very simple to compare them (as they should be pretty much exactly the same).

The L1 and L2 norms (L2 norm is actually squared) of the difference between two images might be defined as
image
image
where N is the number of pixels * number of channels and 'a' and 'b' are the images being compared. Either function is trivial and a three-liner.

Member

great idea, do you have a patch?

dougy83 commented Jun 20, 2014

I don't have a patch. I use Windows and I don't have a build environment set up, nor do I understand the inner workings of OpenSCAD. I can provide the norm function in C++, but that's hardly a contribution.

Member

give it a shot, reach for the stars!!!!

dougy83 commented Jun 20, 2014

Although I love the syntax and minimal learning curve of the OpenSCAD app, I don't want to get familiar with the guts of the existing code. Here's the L1 & L2^2 functions, which should work fine for aligned images.

double normL1(uint32_t *img1, uint32_t *img2, int width, int height)
{
    uint64_t sum = 0;
    uint8_t *img18 = (uint8_t*)img1, *img28 = (uint8_t*)img2;

    for(int i = 0; i < width*height*4; i++)
        sum += abs(*img18++ - *img28++);

    return (double)sum;
}

double normL2_2(uint32_t *img1, uint32_t *img2, int width, int height)
{
    uint64_t sum1 = 0, sum2 = 0;
    uint8_t *img18 = (uint8_t*)img1, *img28 = (uint8_t*)img2;

    for(int i = 0; i < width*height*2; i++)
    {
        int t = *img18++ - *img28++;
        sum1 += t*t;

        t = *img18++ - *img28++;
        sum2 += t*t;
    }

    return sum1 + (double)sum2;
}
Member

awesome awesome....thanks, thats very cool.

now...

do you know of a very nice clean simple .scad example that demonstrates the SCS vs Goldfeather issue on your HD4000?

i neglected to post any examples when i started this issue! but i know we have seen them over the years on different machines and user reports.

dougy83 commented Jun 20, 2014

I can get it tomorrow when I can access the HD4000 machine. Something as simple as the difference() between two different-sized cubes does not display properly. ... Scrap that: there are a number of examples in this thread - #198 (comment)

Owner
kintel commented Jun 20, 2014

The main difference between SCS and Goldfeather is that SCS can only handle convex primitives (and is more efficient). We always fall back on Goldfeather for non-convex primitives, so difference() {cube(...); cube(...);} should do it

Owner
kintel commented Jun 20, 2014

Such an image difference makes sense on two run on the exact same computer. This issue is really about the test framework, which must work across OS'es, OpenSCAD versions and library versions.
..but what's discussed here does make sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment