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.4.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.4-py3-none-any.whl (16.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: rectinspect-0.0.4.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.4.tar.gz
Algorithm Hash digest
SHA256 96c8208712876cc49ef87b6fa117bd8fe0787223b84873bdc1acf1bd468e5977
MD5 b01602178aee3935cc5b4439b1692bd6
BLAKE2b-256 8ea567113f83bcddf7f04a247b40b2f47ac27aef0c22748819e8f326868ac7bf

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rectinspect-0.0.4-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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 d53b55c8dec751fa24c03da85dcdef3ba369856640a5f2b83b48e86b1e1e5120
MD5 bab46c4b02fea92ab82275e1ac2973ca
BLAKE2b-256 681a6b9865a7159767946de3f187e0502961a845ccecea49efbfa6d949a0486e

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