Skip to main content
The detect command processes a directory of images, isolates objects that match a target color using HSV-space segmentation, and extracts geometric features for each detected contour.

Syntax

./run-cli detect --input-dir <path> [options]

Options

--input-dir
string
required
Directory containing the input images to process. Short alias: -i.
--output-dir
string
Write results to this directory instead of creating a session (legacy mode). Short alias: -o.When this flag is set, no session is created and the features.csv file is written to the parent of this directory.
--session
string
Create or resume a named session. Short alias: -s.When provided, results are stored under the centralized session directory using the given name. If neither --session nor --output-dir is set, a session is created automatically using the input directory name.
--color
string
default:"#A98876"
Target color for segmentation in hexadecimal format. Short alias: -c.Objects whose dominant color falls within the HSV range derived from this hex value are selected as detections.
--min-area
number
default:"50"
Minimum contour area in pixels. Contours smaller than this value are discarded.
--max-area
number
default:"5000"
Maximum contour area in pixels. Contours larger than this value are discarded.

Output files

The command produces two categories of output:
FileDescription
features.csvOne row per detected object with columns: image_filename, contour_index, area, perimeter, centroid_x, centroid_y, circularity, aspect_ratio, solidity, extent
<image>/01_hsv.pngHSV-converted source image (saved when save_intermediate=True)
<image>/02_mask_initial.pngRaw color mask before morphological operations
<image>/03_mask_closed.pngMask after MORPH_CLOSE
<image>/04_mask_morph_final.pngMask after MORPH_OPEN
<image>/05_raw_contours.pngAll raw contours before area filtering (red outlines)
<image>/06_filtered_contours_final.pngContours that passed the area filter (green outlines)

Session vs. legacy output mode

Examples

# Detect with all defaults — session auto-created from directory name
./run-cli detect -i ./data/raw/images

# Custom target color and area bounds
./run-cli detect -i ./data/raw/images --color "#C4A882" --min-area 100 --max-area 3000

# Named session for reproducibility
./run-cli detect -i ./data/raw/images --session excavation-site-a

# Legacy output to a specific directory
./run-cli detect -i ./data/raw/images -o ./output/detection