Skip to main content

rectInspect is a Python library for automated image defect detection. It allows users to detect, highlight, and manually inspect defects in images based on customizable width and height rules. You can also interactively draw rectangles on images to measure dimensions and areas. The library supports skipping certain rectangle sizes and is designed for fast, easy, and flexible inspection of defects in various types of images.

Project description

rectInspect

A Python library for detecting and highlighting defects in images using customizable width and height rules.
This is the source code of version 0.0.1, created as a starter project for building a Python package.

Quickstart

The library provides easy-to-use tools for detecting image defects and manually inspecting them using rectangles.

Initialize Detector

You can initialize the defect detector with threshold, minimum area, width/height arrays, and optional rectangles to remove.

import rectInspect

# Initialize detector
detector = rectInspect.highlight_defects(
    threshold_ratio=0.2,
    kernal_size = 20,
    min_area=100,
    width_arr=[1,5,2],
    height_arr=[8,48,66],
    remove_rec=[(64,35),(124,5)]  # [(Width, height)] to skip
)

Process Image

Process an image to detect defects and get the filtered result.

# Process the image
filtered = detector.process_image("2.jpeg")

Detect Defects

Detect defects based on initialized parameters. Returns the number of detected items.

# Detect defects
detected_items = detector.detect_defects(filtered, detector.merged_contours,offset_x,offset_y)

# Print results
detector.print_results(detected_items)

Save Highlighted Image

Save the image with defects highlighted in red rectangles.

# Save the highlighted defects
detector.save_highlited_defect_image(filtered, detected_items)

Draw Rectangles Manually

You can also interactively draw rectangles on an image and see their width, height, and area.

# Draw rectangles interactively
detector.draw_rectangle_with_mouse("final.jpg")

Features

  • Detect defects using contour analysis.
  • Specify multiple width and height ratios using arrays.
  • Optionally remove rectangles that match certain width/height dimensions.
  • Interactive rectangle drawing with real-time width, height, and area display.
  • Save final images with highlighted defects.

Installation

pip install rectInspect

rectInspect

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rectinspect-0.0.3.tar.gz (16.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rectinspect-0.0.3-py3-none-any.whl (16.5 kB view details)

Uploaded Python 3

File details

Details for the file rectinspect-0.0.3.tar.gz.

File metadata

  • Download URL: rectinspect-0.0.3.tar.gz
  • Upload date:
  • Size: 16.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for rectinspect-0.0.3.tar.gz
Algorithm Hash digest
SHA256 f5ac5fe2d578df845beabf3206f02861e7ca4ccefd248f4376c56902f92a30c1
MD5 ebdb8b24a8f3bdc646e7906d7acd7293
BLAKE2b-256 489217719d7d29733fdbde6cd59dc7d5da033829f38efea64f1adf8ab8f7159c

See more details on using hashes here.

File details

Details for the file rectinspect-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: rectinspect-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 16.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for rectinspect-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 57dff4d0af31c7e66ce1818124b3100e82815c8227f8d3f5ada79bf20c81a54c
MD5 882ee736d16b5603ba7c629216f61585
BLAKE2b-256 30bf9b81b1d42eb51409a0b127a2c815cd4f45c949559f3b60a4be0546b731b8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page