Skip to content

rweaton/spatial-config-analysis

Repository files navigation

Spatial Configuration Analyzer

Spatial_Config_Analyzer_GUI.png

Spatial Configuration Analyzer is an application to detect differences in arrangements of grouped objects (e.g. dice) in real-time, as compared to an ideal configuration. In this graph-based approach, if two objects (represented as nodes) are nearest neighbors, then they are linked by a graph edge. The error detection algorithm uses Networkx-based search for monomorphism between graphs of YOLO-detected inference objects and the graph of the desired or ideal configuration. Details about the motivation, methodology, strengths and weaknesses of the approach can be found in this slide presentation Graph-based Error Detection.

Setup

Install dependencies

Clone repo, navigate to its root directory. Create conda virtual environment spatial_config_env via commands

conda env create -f environment.yml
conda activate spatial_config_env

This virtual environment contains the Poetry dependency manager that we will use to install the remaining dependencies of the application.

poetry install --no-root 

Determine camera id

Spatial Configuration Analyzer requires input from a camera so make sure to have one connected to your system. You can find its index id for OpenCV using the following command called from the repository root directory

python ./src/list_cams.py

Take note of the index value listed to the left of the camera that you would like to provide visual input to the analyzer. This camera id index is used for settings configuration in the next step.

Configure

Edit option flags in ./scripts/run_gui.sh for custom configuration. Make sure to replace the camera id index value you found above for the --camera-id option before starting the run script. Default settings are as follows:

python ../src/pack_compare_gui.py \
    --ideal-graph-path "../assets/IdealGraphExample_gui_save.gml" \
    --camera-id 1200 \
    --dim-rescale-factor 1.0 \
    --neighbor-detection-method voronoi_tessellation \
    --max-separation 1.0 \
    --model-weights-path "../assets/yolov8_weights/best.pt" \
    --device "mps" \
    --inference-rate 2.0 \
    --gui-refresh-rate 5.

Image capture FOV

Position your webcam over the field of view that will contain the grouped objects to be analyzed. For the example case with dice, depicted above, I positioned a webcam facing downward to capture about a square foot surface of my desktop. This field of view will contain the assortment of items to be analyzed via real-time visual object detection and on-command graph comparison. In the dice example, the FOV is where dice reside he as they come to rest after being rolled.

Start the GUI

To start the GUI application, navigate to the repository root directory and enter commands

cd scripts
bash ./run_gui.sh

Operating the GUI

Spatial Configuration Analyzer operation guide

About

Detect and report changes in relative configuration in groups of items using graphs

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published