7 from nav_msgs.msg
import OccupancyGrid
18 resolution=mapData.info.resolution
19 Xstartx=mapData.info.origin.position.x
20 Xstarty=mapData.info.origin.position.y
22 img = np.zeros((h, w, 1), np.uint8)
34 o=cv2.inRange(img,0,1)
35 edges = cv2.Canny(img,0,255)
36 im2, contours, hierarchy = cv2.findContours(o,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)
37 cv2.drawContours(o, contours, -1, (255,255,255), 5)
39 res = cv2.bitwise_and(o,edges)
43 im2, contours, hierarchy = cv2.findContours(frontier,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)
44 cv2.drawContours(frontier, contours, -1, (255,255,255), 2)
46 im2, contours, hierarchy = cv2.findContours(frontier,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)
54 for i
in range(0,len(contours)):
57 cx = int(M[
'm10']/M[
'm00'])
58 cy = int(M[
'm01']/M[
'm00'])
59 xr=cx*resolution+Xstartx
60 yr=cy*resolution+Xstarty
61 pt=[np.array([xr,yr])]
63 all_pts=np.vstack([all_pts,pt])