🌶️ 3D scene visual testing

Eyeshot contains a utility to perform an accurate check between images.
The general idea is very simple: a pixel-by-pixel comparison.

The method devDept.ImageComparison.CompareImages() compares 2 bitmaps and returns an image showing the different pixels and the mismatch percentage between them.


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

Code snippet:

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

// This method shows the code internally used till Eyeshot 12 to generate the images. Feel free to change it. private Bitmap CreateReferenceImage(viewType viewType = viewType.Trimetric) { model1.ActiveViewport.AutoHideLabels model1.AntiAliasing = false; model1.AccurateTransparency = false; model1.ActiveViewport.DisplayMode = displayType.Flat; model1.Flat.ColorMethod = flatColorMethodType.EntityMaterial; model1.Flat.SilhouettesDrawingMode = silhouettesDrawingType.LastFrame;
Viewport viewport = model1.ActiveViewport; // Transparent background viewport.Background.StyleMode = backgroundStyleType.None; viewport.Camera.ProjectionMode = projectionType.Perspective; // Prepare the viewport for generating image viewport.Camera.FocalLength = 50; if (viewport.OriginSymbol != null) viewport.OriginSymbol.Visible = false; if (viewport.ViewCubeIcon != null) viewport.ViewCubeIcon.Visible = false; if (viewport.CoordinateSystemIcon != null) viewport.CoordinateSystemIcon.Visible = false; // allows to check proper face normal orientation model1.Backface.ColorMethod = backfaceColorMethodType.SingleColor; if (viewType != viewType.Other) { Size = new System.Drawing.Size(1024, 768); viewport.SetView(viewType); viewport.ZoomFit(4); } return model1.RenderToBitmap(1); }


Previous versions of this article: Eyeshot 11.


Was this article helpful?
1 out of 1 found this helpful



Please sign in to leave a comment.

Articles in this section

See more