/pathfinder

Console utility to find path on RGB image

Primary LanguagePython

Path Finder

Console utility to find path on RGB image


Maintainability python-ci


Installation

pip3 install --upgrade git+https://github.com/mnogom/pathfinder.git

or clone repo. Make sure you have poetry

git clone https://github.com/mnogom/pathfinder.git
cd pathfinder
make install

Usage

  1. From command line:
usage: pathfinder [-h] [-s X Y] [-g X Y] [-r REDUCE_FACTOR] [-w WHITE_VALUE]
                  path

Path finder

positional arguments:
  path                  Path of image

optional arguments:
  -h, --help            show this help message and exit
  -s X Y, --start X Y   start coordinates
  -g X Y, --goal X Y    goal coordinates
  -r REDUCE_FACTOR, --reduce-factor REDUCE_FACTOR
                        reduce factor
  -w WHITE_VALUE, --white-value WHITE_VALUE
                        white value
  1. From Python
import pathfinder

plan = pathfinder.read('path/to/file.jpg', reduce_factor=5, white_value=240)
pathfinder.get_path(start_x, start_y, goal_x, goal_y, plan)
output_image = pathfinder.get_image_with_path(plan)
pathfinder.put_image(output_image, 'path/to/pathed_file.jpg')

Features

  1. Set up white value for outline image
  2. Reduce image for performance improvement
  3. Working with only RGB image

Examples

  1. Input image examples/1/plan.jpg Input image
pathfinder examples/1/plan.jpg -s 420 380 -g 250 40 -r 5 -w 240

Output image

pathfinder examples/1/plan.jpg -s 420 380 -g 520 600 -r 5 -w 240

Output image

pathfinder examples/1/plan.jpg -s 420 380 -g 45 350 -r 5 -w 240

Output image

  1. Input image examples/2/maze.jpg Input image
pathfinder examples/2/maze.jpg -s 20 300 -g 620 300 -r 8

Output image