Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Convert Image to Occupancy Grid

I was wondering how I might turn a bird's eye view image of a map into an occupancy grid. I use an edge detection algorithm to detect obstacles in the bird's eye view image and would like to then translate this information into an occupancy grid (the black squares would be obstacles as detected by the edge detection algorithm, and the white squares would be free space).

image of map

I would like to turn the image above into something along the lines of this (the image below is just a random maze, it doesn't actually pair up with the map):

maze

My code for edge detection:

import cv2
import numpy as np

roomimg = cv2.imread("/Users/2020shatgiskessell/Desktop/roomimage.jpg")
gray = cv2.cvtColor(roomimg, cv2.COLOR_BGR2GRAY)

gray = np.float32(gray)
dst = cv2.cornerHarris(gray,2,3,0,0.04)

dst = cv2.dilate(dst, None)

roomimg[dst>0.01*dst.max()]=[0,0,255]


cv2.imshow('dst',roomimg)
if cv2.waitKey(0) & 0xff == 27:
cv2.destroyAllWindows()

Convert Image to Occupancy Grid

I was wondering how I might turn a bird's eye view image of a map into an occupancy grid. I use an edge detection algorithm to detect obstacles in the bird's eye view image and would like to then translate this information into an occupancy grid (the black squares would be obstacles as detected by the edge detection algorithm, and the white squares would be free space).

image of mapThe image I would like to convert:

https://imgur.com/a/6UL6g

I would like to turn the image above into something along the lines of this (the image below is just a random maze, it doesn't actually pair up with the map):

mazehttps://imgur.com/a/H3uNd

My code for edge detection:

import cv2
import numpy as np

roomimg = cv2.imread("/Users/2020shatgiskessell/Desktop/roomimage.jpg")
gray = cv2.cvtColor(roomimg, cv2.COLOR_BGR2GRAY)

gray = np.float32(gray)
dst = cv2.cornerHarris(gray,2,3,0,0.04)

dst = cv2.dilate(dst, None)

roomimg[dst>0.01*dst.max()]=[0,0,255]


cv2.imshow('dst',roomimg)
if cv2.waitKey(0) & 0xff == 27:
cv2.destroyAllWindows()

Convert Image to Occupancy Grid

I was wondering how I might turn a bird's eye view image of a map into an occupancy grid. I use an edge detection algorithm to detect obstacles in the bird's eye view image and would like to then translate this information into an occupancy grid (the black squares would be obstacles as detected by the edge detection algorithm, and the white squares would be free space).

The image I would like to convert:

https://imgur.com/a/6UL6g

I would like to turn the image above into something along the lines of this (the image below is just a random maze, it doesn't actually pair up with the map):

https://imgur.com/a/H3uNdhttps://imgur.com/a/t0l97

My code for edge detection:

import cv2
import numpy as np

roomimg = cv2.imread("/Users/2020shatgiskessell/Desktop/roomimage.jpg")
gray = cv2.cvtColor(roomimg, cv2.COLOR_BGR2GRAY)

gray = np.float32(gray)
dst = cv2.cornerHarris(gray,2,3,0,0.04)

dst = cv2.dilate(dst, None)

roomimg[dst>0.01*dst.max()]=[0,0,255]


cv2.imshow('dst',roomimg)
if cv2.waitKey(0) & 0xff == 27:
cv2.destroyAllWindows()

Convert Image to Occupancy Grid

I was wondering how I might turn a bird's eye view image of a map into an occupancy grid. I use an edge detection algorithm to detect obstacles in the bird's eye view image and would like to then translate this information into an occupancy grid (the black squares would be obstacles as detected by the edge detection algorithm, and the white squares would be free space).

The image I would like to convert:

https://imgur.com/a/6UL6g

I would like to turn the image above into something along the lines of this (the image below is just a random maze, it doesn't actually pair up with the map):crudely hand drawn)

https://imgur.com/a/t0l97https://imgur.com/a/vPQNu

My code for edge detection:

import cv2
import numpy as np

roomimg = cv2.imread("/Users/2020shatgiskessell/Desktop/roomimage.jpg")
gray = cv2.cvtColor(roomimg, cv2.COLOR_BGR2GRAY)

gray = np.float32(gray)
dst = cv2.cornerHarris(gray,2,3,0,0.04)

dst = cv2.dilate(dst, None)

roomimg[dst>0.01*dst.max()]=[0,0,255]


cv2.imshow('dst',roomimg)
if cv2.waitKey(0) & 0xff == 27:
cv2.destroyAllWindows()