Skip to content

julius-kr/Automated_Quality_Analysis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Automated Quality Analysis

This project provides a Python script for performing automated quality analysis by comparing a 3D design (STL file) with a 3D scan (PLY file). The script performs the following steps:

  1. Loading and Processing: Loads the STL design file and the PLY scan file and converts the STL into a point cloud format.
  2. Visualization: Previews the point clouds for initial inspection.
  3. Point Cloud Registration: Uses the Iterative Closest Point (ICP) algorithm to align the scan point cloud to the design point cloud.
  4. Similarity Scoring: Computes a similarity score based on the alignment of the two point clouds.
  5. Visualization: Displays the aligned point clouds and their differences.

Installation

It is recommended to use Python 3.12.7 in a virtual environment to ensure compatibility.

Steps:

  1. Clone or Download the Repository:

    Clone this repository or download the code files to your local machine.

  2. Create a Virtual Environment:

    python3.12 -m venv .venv
  3. Activate the Virtual Environment:

    • On Windows:

      .venv\Scripts\activate
    • On Unix or MacOS:

      source .venv/bin/activate
  4. Install the Required Packages:

    pip install -r requirements.txt

    requirements.txt content:

    numpy==2.1.3
    pandas==2.2.3
    pyntcloud==0.3.1
    scipy==1.14.1
    trimesh==4.5.2
    pyvista==0.44.2

Usage

The main script is automated_quality_analysis.py. It takes two arguments:

  • STL File: The path to the 3D design file (e.g., design_model.stl).
  • PLY File: The path to the 3D scan file (e.g., scan_data.ply).

Run the script using the following command:

python automated_quality_analysis.py <filename.stl> <filename.ply>

Example:

cd /src
python automated_quality_analysis.py example_path/design_model.stl example_path/scan_data.ply

Features

  • Loading and Processing: Efficiently loads and processes large STL and PLY files into point clouds.
  • Visualization: Provides previews of both the design and scan point clouds for visual inspection.
  • Point Cloud Registration: Implements the ICP algorithm for accurate alignment of point clouds.
  • Similarity Scoring: Calculates a similarity score based on the Mean Squared Error (MSE) between the aligned point clouds.
  • Final Visualization:
    • Colored Dots: Represent the scan cloud (normalized distances).
    • Gray Dots: Represent the design cloud.

Modules and Functions

The project includes the following Python modules and key functions:

automated_quality_analysis.py

This is the main script that orchestrates the quality analysis process.

  • main(stl_file, ply_file): Performs the automated quality analysis steps, including loading files, visualization, ICP registration, similarity scoring, and final visualization.

point_cloud_utils.py

Contains utility functions for point cloud operations.

  • compute_sample_fraction(total_points, target_num_points=1000000, scaling_factor=1.0): Computes the sampling fraction for point clouds.
  • perform_icp(source_points, target_points, max_iterations=20, tolerance=1e-6): Aligns two point clouds by minimizing the distance between them iteratively (Iterative Closest Point).
  • downsample_points(points, max_points=1000000): Reduces the number of points in a cloud.
  • align_cloud_scales(source_points, target_points): Normalizes point clouds to the same scale on all axes.

visualization.py

Contains functions for visualizing point clouds.

  • visualize_point_cloud(cloud, target_num_points, coloring, compression_factor, title): Visualizes a single point cloud using PyVista.
  • plot_point_clouds_multi_view(cloud1, cloud2, target_num_points, compression_factor, title): Visualizes two aligned point clouds with PyVista.

Dependencies

Ensure the following Python packages are installed in your virtual environment:

  • numpy
  • pandas
  • pyntcloud
  • scipy
  • trimesh
  • pyvista

These are specified in the requirements.txt file.

Troubleshooting

  • Error Loading STL or PLY Files: Verify that the files are not corrupted and the paths are correct.
  • NaN or Infinite Values in Aligned Points: Check the input data for inconsistencies or preprocessing requirements.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages