sheljoy / Obstacle-Detection-and-Path-Planning

Processing an Image to find obstacles and the minimum path between two similar objects using OpenCV.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool


# Obstacle-Detection-and-Path-Planning

Path planning is a technique used to find the shortest path between a source and destination. Path planning ensures that navigation is done in least time and in most optimized way, saving energy and providing a optimized way of the doing task.

Given:

A set of test images, each containing

  1. 10x10 grid, making 100 squares
  2. Obstacles marked as black square
  3. Objects defined by three features, viz. Shape, Size and Color

The squares are identified by the coordinate (x,y) where x is the column and y is the row to which the square belongs. Each square can be empty or have an Obstacle or have an Object.

The program returns 2 major findings:

  1. The coordinates of occupied grid:

    The code returns a python list having ‘n’ python tuples, where ‘n’ denotes number of occupied grid in test image. Grid is to be considered occupied if either grid has an Obstacle or an Object. Each tuple has two elements, first element is the x-coordinate of an Obstacle/Object and second element is the y-coordinate of the Obstacle.

  2. The minimum path:

    For each object in the test images, a matching object which is nearest to it is found using compare_ssim function from scikit-image. Object is said to be nearest to another Object, if length of path traversed between two objects is smallest. Traversal is done by moving either horizontally or vertically. The length of the path is determined by the number of moves made during traversal. A* search is used to find this shortest path.

The code return a python dictionary. Format for creating dictionary is as follows:

  • Key for dictionary is a tuple - (x,y) coordinate of an Object
  • first element of dictionary is a tuple - (x,y) coordinate of an object nearest to it
  • second element is a list of tuples having (x,y) coordinate of all grids traversed i.e all route path
  • third element of dictionary should be number of moves taken for traversal

##Basic Usage

Run main.py to check the results. You can edit the test image from main.py to see different results.

The process_image.py contains the major code. Check that script to see the main functionality. Follow the comments to undertand the code better.

astarsearch.py contains the implementation of A* search algo.

traversal.py contains the script to traverse through the image to find objects/min path.

##Dependencies

Use pip to install.

  1. Install OpenCV for Python

    For Windows

    For Ubuntu

Install skimage (or scikit-image)

Open command prompt and type in:
```pip install scikit-image```

Install numpy

Open command prompt and type in:
```pip install numpy```

About

Processing an Image to find obstacles and the minimum path between two similar objects using OpenCV.

License:MIT License


Languages

Language:Python 100.0%