Product Quality Control System via Computer Vision

We design and deploy artificial intelligence systems: from prototype to production-ready solutions. Our team combines expertise in machine learning, data engineering and MLOps to make AI work not in the lab, but in real business.
Showing 1 of 1 servicesAll 1566 services
Product Quality Control System via Computer Vision
Complex
~1-2 weeks
FAQ
AI Development Areas
AI Solution Development Stages
Latest works
  • image_web-applications_feedme_466_0.webp
    Development of a web application for FEEDME
    1161
  • image_ecommerce_furnoro_435_0.webp
    Development of an online store for the company FURNORO
    1041
  • image_logo-advance_0.png
    B2B Advance company logo design
    561
  • image_crm_enviok_479_0.webp
    Development of a web application for Enviok
    823
  • image_logo-aider_0.jpg
    AIDER company logo development
    762
  • image_crm_chasseurs_493_0.webp
    CRM development for Chasseurs
    848

System Development контроля качества продукции через компьютерное зрение

Контроль качества через CV — комплексная задача: проверка внешнего вида, геометрических параметров, комплектности, правильности маркировки, упаковки. В отличие от отдельной детекции дефектов, система QC обычно включает несколько проверочных точек на разных этапах производства.

Architecture многоточечной QC системы

Этап 1: Входной контроль сырья/компонентов
    ↓
Этап 2: Промежуточный контроль (на конвейере)
    ↓
Этап 3: Финальный контроль готовой продукции
    ↓
Этап 4: Контроль упаковки и маркировки
from dataclasses import dataclass, field
from enum import Enum

class QCStage(Enum):
    INCOMING = 'incoming'
    IN_PROCESS = 'in_process'
    FINAL = 'final'
    PACKAGING = 'packaging'

@dataclass
class QCResult:
    product_id: str
    stage: QCStage
    timestamp: str
    verdict: str                # PASS / FAIL / QUARANTINE
    defects: list[dict] = field(default_factory=list)
    measurements: dict = field(default_factory=dict)
    label_check: dict = field(default_factory=dict)
    images: list[str] = field(default_factory=list)

class ProductQCSystem:
    def __init__(self, config: dict):
        self.defect_detector = DefectDetector(config['defect_model'])
        self.measurement_engine = MeasurementEngine(config['reference_data'])
        self.label_verifier = LabelVerifier(config['label_templates'])
        self.completeness_checker = CompletenessChecker(config['bom'])

    def inspect(self, image: np.ndarray,
                product_id: str,
                stage: QCStage) -> QCResult:
        result = QCResult(product_id=product_id, stage=stage,
                          timestamp=get_timestamp(), verdict='PASS')

        if stage == QCStage.FINAL:
            # Полная проверка
            result.defects = self.defect_detector.inspect(image)['defects']
            result.measurements = self.measurement_engine.measure(image)
            result.label_check = self.label_verifier.verify(image)
            completeness = self.completeness_checker.check(image)

            # Определение verdict
            has_critical_defect = any(d['severity'] == 'critical'
                                      for d in result.defects)
            measurement_ok = result.measurements.get('within_tolerance', True)
            label_ok = result.label_check.get('verified', True)
            complete = completeness.get('complete', True)

            if has_critical_defect or not measurement_ok:
                result.verdict = 'FAIL'
            elif not label_ok or not complete:
                result.verdict = 'QUARANTINE'

        return result

Измерение геометрических параметров

class MeasurementEngine:
    def __init__(self, calibration_data: dict):
        # Калибровочные данные: pixels_per_mm при известном расстоянии
        self.pixels_per_mm = calibration_data['pixels_per_mm']
        self.tolerance = calibration_data['tolerance_mm']

    def measure(self, image: np.ndarray) -> dict:
        # Поиск контура детали
        gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
        _, binary = cv2.threshold(gray, 0, 255,
                                   cv2.THRESH_BINARY + cv2.THRESH_OTSU)
        contours, _ = cv2.findContours(binary, cv2.RETR_EXTERNAL,
                                        cv2.CHAIN_APPROX_SIMPLE)

        if not contours:
            return {'measured': False}

        main_contour = max(contours, key=cv2.contourArea)

        # Bounding rect для ширины/высоты
        x, y, w, h = cv2.boundingRect(main_contour)
        width_mm = w / self.pixels_per_mm
        height_mm = h / self.pixels_per_mm

        # Минимальный описывающий прямоугольник (rotated)
        rect = cv2.minAreaRect(main_contour)
        rect_w, rect_h = rect[1]
        angle = rect[2]

        return {
            'width_mm': round(width_mm, 2),
            'height_mm': round(height_mm, 2),
            'rotation_angle': round(angle, 1),
            'within_tolerance': self._check_tolerance(width_mm, height_mm),
            'area_mm2': round(cv2.contourArea(main_contour) /
                              self.pixels_per_mm**2, 2)
        }

Верификация маркировки и этикеток

class LabelVerifier:
    def __init__(self, templates: dict):
        self.ocr = PaddleOCR(use_angle_cls=True, lang='ru')
        self.templates = templates  # ожидаемые паттерны для продукта

    def verify(self, image: np.ndarray, product_sku: str) -> dict:
        # OCR этикетки
        ocr_result = self.ocr.ocr(image, cls=True)
        extracted_text = '\n'.join([line[1][0] for line in ocr_result[0]])

        template = self.templates.get(product_sku, {})
        checks = {}

        # Проверка обязательных полей
        for field_name, pattern in template.items():
            match = re.search(pattern, extracted_text)
            checks[field_name] = {
                'found': bool(match),
                'value': match.group() if match else None
            }

        all_found = all(v['found'] for v in checks.values())
        return {
            'verified': all_found,
            'fields': checks,
            'raw_text': extracted_text
        }

SPC (Statistical Process Control) интеграция

После каждого измерения данные идут в SPC-модуль, который строит контрольные карты Шухарта (X-bar/R chart) и автоматически сигнализирует о выходе процесса за контрольные пределы.

Метрика QC-системы Типичное значение
Recall дефектов (критических) 98–99.5%
False rejection rate 1–3%
Throughput 600–3000 шт/час
Latency на деталь 50–150 ms
Масштаб проекта Срок
Один продукт, одна проверочная точка 6–8 недель
Многопродуктовая система, несколько этапов 12–18 недель
Enterprise QC с SPC и ERP-интеграцией 18–28 недель