How to detect the road in the diablo2?
The pic will be like this.
First question how to paste code in the post code
seems not work for me.
I search the web to get the contours. Use the code below but the result seems not that satisfied so how to locate the road in the pic.
import numpy as np
import cv2
im = cv2.imread('path.png')
imgray = cv2.cvtColor(im,cv2.COLOR_BGR2GRAY)
ret,thresh = cv2.threshold(imgray,127,255,0)
im2, contours, hierarchy = cv2.findContours(thresh,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)
cv2.namedWindow("Contours", cv2.WINDOW_NORMAL)
cv2.imshow("Contours", im2)
cv2.drawContours(im, contours, -1, (0,255,0), 3)
cv2.drawContours(im, contours, 3, (0,255,0), 3)
cnt = contours[4]
cv2.drawContours(im, [cnt], 0, (0,255,0), 3)
cv2.waitKey(0)
cv2.destroyAllWindows()
You should use the HSV colorspace to threshold the color of the road.