1 Star 1 Fork 0

jin_ming_2006 / autoSweep

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
mkMap.py 1005 Bytes
一键复制 编辑 原始数据 按行查看 历史
jin_ming_2006 提交于 2016-09-16 15:19 . initial version
#!/usr/local/bin/python
#-*-coding:utf-8-*-
import numpy as np
import cv2
from matplotlib import pyplot as plt
currentWindowId = 0
def prepareWindow(img, title, ifGray = False):
global currentWindowId
currentWindowId = currentWindowId +1
plt.subplot(3,3,currentWindowId)
plt.title(title)
plt.xticks([])
plt.yticks([])
if(ifGray):
plt.imshow(img,'gray')
else:
plt.imshow(img)
img = cv2.imread('room2.jpg')
gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
ret, thresh = cv2.threshold(gray,0,255,cv2.THRESH_BINARY+cv2.THRESH_OTSU)
bg = thresh
prepareWindow(bg,"original", True)
kernel = np.ones((3,3),np.uint8)
#去噪音
bigObstacle = cv2.morphologyEx(thresh, cv2.MORPH_CLOSE,kernel, iterations=2)
prepareWindow(bigObstacle,"real map", True)
cv2.imwrite('multiRoom.pgm',bigObstacle)
greyBigObstacle = bigObstacle
greyBigObstacle[bigObstacle<256] = 220
prepareWindow(greyBigObstacle,"graph",True)
cv2.imwrite('room_grey.pgm',greyBigObstacle)
plt.show()
Python
1
https://gitee.com/jin_ming_2006/autoSweep.git
git@gitee.com:jin_ming_2006/autoSweep.git
jin_ming_2006
autoSweep
autoSweep
master

搜索帮助