本文へ移動
cccskills
無料GitHub で公開

matlab-use-visual-inspection

Build machine vision inspection systems with MATLAB Visual Inspection Toolbox. Covers the full arc from problem selection through deployment: anomaly detection (Student-Teacher, PatchCore, FastFlow, FCDD), object detection (YOLOX), counting (CounTR, shape matching), gauging and measurement (caliper, fitcircle, fitangle), blob analysis (regionprops, calibrated measurement), shape matching for fixturing and localization, synthetic data generation for training augmentation, and deployment to standalone apps, embedded C/C++, NVIDIA GPUs (TensorRT), NPUs (ONNX), and Beckhoff PLCs. Routes to rule-based tools when problems are geometric and deterministic, AI-based tools when defect appearance varies, and hybrid pipelines combining both.

インストール方法を見る

含まれるファイル(10)

  • SKILL.md12.3 KB
  • manifest.yaml629 B
  • references/blob-analysis.md7.0 KB
  • references/count-objects.md6.4 KB
  • references/deploy-inspection.md10.1 KB
  • references/detect-anomaly.md10.0 KB
  • references/detect-objects.md11.4 KB
  • references/match-shape.md7.1 KB
  • references/measure-gauging.md11.1 KB
  • references/synthetic-data.md11.7 KB

SKILL.md(原文)

インストールする前に、エージェントに与えられる指示の中身を確認できます。

Visual Inspection with MATLAB

Build machine vision inspection systems using Visual Inspection Toolbox. Select the right approach — rule-based, AI-based, or hybrid — based on problem characteristics, then implement, train, and deploy.

When to Use

Defect detection and classification

  • Detecting anomalies on manufactured parts (scratches, dents, contamination)
  • Training anomaly detectors with good-part images only (one-class learning)
  • Detecting and localizing defects with bounding boxes (YOLOX)
  • Classifying defect types or severity levels

Measurement and gauging

  • Measuring widths, gaps, angles, diameters on parts
  • Calibrated measurement in physical units (mm, degrees)
  • Vision fixturing — locating parts and repositioning measurement tools
  • Blob analysis — area, perimeter, shape metrics of segmented regions

Counting and localization

  • Counting identical rigid parts via shape matching
  • Few-shot counting with intra-class variation (CounTR)
  • Locating parts by edge geometry for downstream inspection

Training data augmentation

  • Generating synthetic labeled data via copy-paste augmentation
  • Expanding small defect datasets for YOLOX training

Deployment

  • Packaging inspection as standalone executables (MATLAB Compiler)
  • Generating C/C++ for embedded/edge targets (MATLAB Coder)
  • GPU-accelerated inference with TensorRT (GPU Coder)
  • ONNX export for NPUs, AI accelerators, smart camera SDKs
  • Deploying to Beckhoff TwinCAT industrial PLCs

When NOT to Use

  • Camera acquisition, frame grabber configuration — use Image Acquisition Toolbox
  • PLC communication, OPC UA, MQTT protocols — use Industrial Communication Toolbox
  • General image processing unrelated to inspection (artistic filters, medical imaging)

Must-Follow Rules

Approach Selection

  • Rule-based for geometric, deterministic problems — when defects are dimensional deviations or parts have known geometry, use caliper/fitcircle/matchshape. No training data needed
  • AI-based for variable appearance — when defect appearance can't be enumerated, use anomaly detection or YOLOX. Requires training data
  • Hybrid when parts move — use matchshape to fixture (locate + normalize pose), then AI on the cropped/warped region. Anomaly detectors are NOT rotation/scale invariant

Anomaly Detection

  • Anomaly detectors require consistent pose — CNN backbones are not rotation/scale invariant. Fixture with matchshape + imwarp to canonical orientation before training and inference
  • Choose detector by data availability — >100 good images: studentTeacherAnomalyDetector; <100 images: patchCoreAnomalyDetector; have anomaly labels: fcddAnomalyDetector
  • Use classify for inference — returns [tf, score, map] for anomaly map visualization

Object Detection (YOLOX)

  • Use AutoResize=false for full-resolution inference — prevents downscaling that loses small defects. Pair with tiled training when objects are small relative to image
  • Synthetic data benefits YOLOX most — copy-paste augmentation via objectInsertionDatastore is proven for detection tasks

Measurement

  • Vision fixturing pattern — matchshape locates part → transform measurement positions to detected pose → measure at repositioned locations
  • Calibrated measurements require imageToWorldPlane — converts pixel measurements to physical units using camera calibration
  • images.geotrans.Warper for production rectification — precompute the mapping once, apply per frame for maximum throughput

Deployment

  • Always use persistent + isempty guard in codegen entry points — load model once, infer many times
  • coder.loadDeepLearningNetwork for DL models — not coder.load (which is for structs/shape models)
  • coder.Constant for MAT file path — codegen requires compile-time constant paths
  • Pass detector objects directly to exportONNXNetwork — never extract .Network or .Backbone first. The object-level export includes pre/post-processing logic
  • ONNX for NPUs/AI accelerators; GPU Coder + TensorRT for NVIDIA — don't use ONNX for Jetson/Orin

Pipeline Construction

Machine vision inspections compose tools in sequence:

  1. Acquire — Get the image (Image Acquisition Toolbox)
  2. Fixture — Locate a stable reference feature (matchshape)
  3. Reposition — Transform measurement positions to detected pose
  4. Inspect — Apply measurement or classification at repositioned locations
  5. Decide — Compare to tolerances → pass/fail
  6. Communicate — Send results to PLC/SCADA (Industrial Communication Toolbox)

Common Hybrid Patterns

PatternRule-Based PartAI Part
Fixture + classifymatchshape locates part, crops ROIAnomaly detector on cropped region
Fixture + detectmatchshape locates partYOLOX finds defects relative to fixture
Pose normalize + anomalymatchshape + imwarp to canonical poseAnomaly detector on normalized image
Segment + measureThresholding / morphologyregionprops on segmented blobs

Primary Decision: Rule-Based vs. AI-Based

Choose Rule-Based WhenChoose AI-Based When
Defects have predictable, enumerable geometryDefect appearance varies unpredictably
Lighting and positioning are tightly controlledBackground or part appearance varies
Need dimensional measurements (mm, degrees)Need classification without precise measurement
Few or no labeled examples availableHave labeled training data (or can generate synthetic)
Require explainable, auditable decisionsAccuracy matters more than explainability

Key Functions

FunctionPurposeToolboxAvailable From
shapemodelBuild edge-geometry model from templateVisual Inspection ToolboxR2026b
matchshapeFind model instances in search imageVisual Inspection ToolboxR2026b
caliperMeasure edge distances along a profileVisual Inspection ToolboxR2026b
fitangleMeasure angle between edgesVisual Inspection ToolboxR2026b
fitcircleMeasure circle center and radiusVisual Inspection ToolboxR2026b
studentTeacherAnomalyDetectorOne-class anomaly detection (>100 good images)Visual Inspection ToolboxR2026b
patchCoreAnomalyDetectorOne-class anomaly detection (few-shot, <100 images)Visual Inspection ToolboxR2026b
fastFlowAnomalyDetectorNormalizing-flow anomaly detectionVisual Inspection ToolboxR2026b
fcddAnomalyDetectorSemi-supervised anomaly detectionVisual Inspection ToolboxR2026b
yoloxObjectDetectorObject/defect detection with bounding boxesVisual Inspection ToolboxR2026b
counTRObjectCounterCounting with intra-class variation (few-shot)Visual Inspection ToolboxR2026b
objectInsertionDatastoreSynthetic labeled training data (copy-paste)Visual Inspection ToolboxR2026b
regionpropsBlob area, perimeter, shape featuresImage Processing ToolboxR2006a
imageToWorldPlaneCalibrated world-unit measurementComputer Vision ToolboxR2022b

Decision Trees

"I need to detect defects"

SituationApproach
Defect appearance unpredictable; good-part images onlyAnomaly detection
Classify defect types with bounding boxes; have labeled dataYOLOX object detection
Defects are geometric deviations from known shapeShape matching + gauging
Dimensional out-of-tolerance (too wide, too narrow)Caliper / fitcircle / fitangle

"I need to measure parts"

SituationApproach
Widths, gaps, edge-to-edge distancescaliper
Angles between edgesfitangle
Hole diameters, arc radiifitcircle
Area, perimeter, shape of segmented blobsregionprops
Need measurements in mm (physical units)Camera calibration + rectification
Part position varies image-to-imageVision fixturing with matchshape

"I need to count objects"

SituationApproach
Identical rigid parts, controlled backgroundshapemodel / matchshape
Intra-class variation, few labeled examplesCounTR (few-shot counting)
Multiple classes, complex scenes, have labelsYOLOX detection → count

"I need to locate parts"

SituationApproach
Rigid part, known edge geometryshapemodel / matchshape
Variable appearance, multiple classesYOLOX detection

"I don't have enough training data"

SituationApproach
Have segmented defect examples + clean imagesCopy-paste synthetic data
Good-part images only (no defect labels)Anomaly detection (one-class)
No data at all, defects are geometricRule-based (no training needed)

"I need to deploy"

TargetPath
Standalone app, full MATLAB featuresMATLAB Compiler
Monitoring dashboard or UI appMATLAB Compiler
Embedded CPU (x86, ARM)MATLAB Coder
NVIDIA Jetson/Orin or dGPUGPU Coder + TensorRT
NPU or AI acceleratorONNX export
Smart camera with vendor SDKONNX export
Beckhoff industrial PLCMATLAB Coder → TwinCAT

Patterns

Each reference file contains executable code patterns, API calling conventions, and worked examples for its topic. Load the relevant reference before writing code.

Conventions

  • Always: use machine vision terminology (rule-based, tool chaining, fixturing)
  • Always: recommend the specific VIT function, not generic IPT building blocks
  • Always: consider hybrid pipelines (rule-based fixturing + AI classification)
  • Always: ensure anomaly detector receives images in consistent pose
  • Always: use persistent + isempty for model loading in codegen entry points
  • Always: pass detector objects directly to exportONNXNetwork (never extract .Network)
  • Never: recommend AI when the problem is purely dimensional measurement
  • Never: recommend rule-based when defect appearance is highly variable
  • Never: use coder.load for deep learning models (use coder.loadDeepLearningNetwork)
  • Never: use ONNX export for NVIDIA targets (use GPU Coder + TensorRT)
  • Prefer: anomaly detection when only good-part images are available
  • Prefer: YOLOX when labeled defect examples with bounding boxes exist
  • Prefer: shapemodel/matchshape over YOLOX for locating rigid parts
  • Prefer: images.geotrans.Warper for production rectification throughput
  • Prefer: MATLAB Compiler for dashboards and UI-based monitoring apps

References

Load when...Reference
Training or using anomaly detectorsreferences/detect-anomaly.md
Locating parts by shape, vision fixturingreferences/match-shape.md
Training or using YOLOX object detectorsreferences/detect-objects.md
Counting objects (shape matching, CounTR, YOLOX)references/count-objects.md
Measuring with caliper, fitcircle, fitanglereferences/measure-gauging.md
Blob analysis, regionprops, calibrated measurementreferences/blob-analysis.md
Deploying models (Compiler, Coder, TensorRT, ONNX)references/deploy-inspection.md
Generating synthetic training datareferences/synthetic-data.md

Copyright 2026 The MathWorks, Inc.


レビュー

まだレビューはありません。使ってみた感想をお寄せください。

同じリポジトリのスキル

概要と使いどころ

Guide for accessing financial and economic data in MATLAB using the Datafeed Toolbox. Covers Bloomberg (market data via bloomberg/blp/bloombergHypermedia), FRED (Federal Reserve economic data via fredrs), Haver Analytics (economic data via haver/haverdirect/haverview), and LSEG Datastream (historical data via datastreamws). Use when connecting to any of these data providers from MATLAB.

日本語の概要は準備中です。原文の説明を表示しています。

matlab/matlab-agentic-toolkit1,1502026年10月9日 更新

Read BEFORE writing any code that adds Additive White Gaussian Noise (AWGN) to signals and converts between SNR, Eb/No, Es/No, and per-subcarrier SNR for communications simulations, using awgn(), convertSNR(), berawgn(). The default MATLAB patterns for AWGN (e.g., 'measured' option, manual SNR formulas) produce subtly incorrect results. This skill specifies the correct calling conventions, required function usage, and critical anti-patterns that must be avoided.

日本語の概要は準備中です。原文の説明を表示しています。

matlab/matlab-agentic-toolkit1,1502026年10月9日 更新

Analyze AMS waveform data using Mixed-Signal Blockset utilities: phase noise measurement, clock jitter, anti-aliased resampling, timing measurements, lock time, INL/DNL, ADC/DAC calibration, HSpice import. Use when analyzing time-domain voltage from PLL/VCO/clock simulations, measuring phase noise from variable-step solver output, computing jitter, or resampling non-uniform data.

日本語の概要は準備中です。原文の説明を表示しています。

matlab/matlab-agentic-toolkit1,1502026年10月9日 更新

Design and analyze electrically large antenna structures using MATLAB Antenna Toolbox. Covers reflector antennas (parabolic, Cassegrain, Gregorian, offset, corner, cylindrical, spherical, custom STL), reflectarrays and reconfigurable intelligent surfaces (RIS), antennas installed on platforms (vehicles, aircraft, ships, satellites), and radar cross section (RCS) analysis. Includes solver selection (MoM-PO, PO, MoM, FMM), mesh control, and GPU acceleration. Use when the user wants to design a dish/reflector antenna, reflectarray, analyze an antenna on a platform, or compute RCS.

日本語の概要は準備中です。原文の説明を表示しています。

matlab/matlab-agentic-toolkit1,1502026年10月9日 更新

Analyze data using MATLAB. Use when the task involves tables, timetables, time-series data, numeric arrays, sensor matrices, or gridded data — including but not limited to exploring, row filtering, sorting, cleaning, transforming, aggregating, smoothing, padding, trimming, and answering questions about data. MATLAB provides extensive, easy-to-use built-in functions for these workflows with no additional products required.

日本語の概要は準備中です。原文の説明を表示しています。

matlab/matlab-agentic-toolkit1,1502026年10月9日 更新

S-parameters, insertion loss, fields, currents, mesh control, and solver selection for RF PCB performance validation. TRIGGER: user asks to compute S-parameters, analyze insertion/return loss, extract fields or currents, compare MoM vs FEM, or control mesh for any RF PCB component. Invoke BEFORE writing sparameters() or solver code — API is non-obvious. SKIP: designing or creating components (use the specific matlab-design-pcb-* skill), material/stackup setup only (use matlab-manage-pcb-material), optimization sweeps (use matlab-optimize-pcb-design), PDN/IR-drop analysis (use matlab-analyze-pcb-pdn).

日本語の概要は準備中です。原文の説明を表示しています。

matlab/matlab-agentic-toolkit1,1502026年10月9日 更新

matlab のスキルをすべて見る

このスキルの問題を報告する