3D scene visual testing

Eyeshot contains a built-in image comparison to perform an accurate check between images. The general idea is very simple - pixel-by-pixel comparison.
Listed below are the methods you can use for this purpose.

ViewportLayout.CompareWithReferenceImage(): compares 2 bitmaps and returns an image showing the different pixels and the mismatch percentage between them.

ViewportLayout.CreateReferenceImage(): creates a bitmap with a transparent background starting from the current scene1.

Expected image Current image Differences
Expected.jpg Current.jpg Differences.jpg

Code snippet:

Bitmap expected = new Bitmap("Original.bmp");
Bitmap current = viewportLayout1.CreateReferenceImage(viewType.Trimetric);
double mismatch = viewportLayout1.CompareWithReferenceImage(expected, current, out Bitmap diffImage);
Console.WriteLine($"The mismatch percentage is {mismatch}");

 

1If you need to customize the output images, you can use the ViewportLayout.RenderToBitmap() method instead.

Was this article helpful?
2 out of 2 found this helpful
Have more questions? Submit a request

Comments

2 comments
  • Marcello,

    many thanks for this kind of helper! I have one question before trying this functionality out. Some years ago we tried to do such visual test on our own. Therefore we used images that one could obtain from the viewport. We used created reference images in our automatic tests. But we regularly stumbled into trouble because the rendered images where dependend on hardware plattform having slight differences. This even happened when turning of hardware rendering. We also observed certain issues at the image boundaries at that earlier time.

    So I am interested in knowing if your provided way is effected by the hardware plattform or not. Or, if there is any strategy, let's say that images are almost correct if the mismatch is below 3%?

    Any recommendations are appriciated.
    Thanks and greetings
    Olaf

  • Hi Olaf,

    unfortunately also our method is affected by the hardware platform.
    In our experience, even a mismatch of 0.01% can, at times, reveal the fact that something important has changed. Therefore, we decided to perform the "official" image comparison always on the same machine.

Please sign in to leave a comment.