Я пытаюсь получить набор точек, находящихся в середине этой кривой. я найти этот сценарий, но с моим лазером изображение не работает ...opencv и python - Обнаружение лазерной изогнутой линии
im_gray = cv2.imread(img, cv2.CV_LOAD_IMAGE_GRAYSCALE)
im_gray = cv2.Canny(im_gray,50,150,apertureSize = 3)
ret, im_bw = cv2.threshold(im_gray, 0, 255, cv2.THRESH_BINARY)
#(thresh, im_bw) = cv2.threshold(im_gray, 128, 255, cv2.THRESH_BINARY | cv2.THRESH_OTSU)
#thresh = 127
#im_bw = cv2.threshold(im_gray, thresh, 255, cv2.THRESH_BINARY)[1]
#ret, bw = cv2.threshold(im_bw, 0, 255, cv2.THRESH_BINARY)
cv2.imwrite('resultpoint_bw.png',im_bw)
# find contours of the binarized image
contours, heirarchy = cv2.findContours(im_bw, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE)
# curves
curves = np.zeros((im_bw.shape[0], im_bw.shape[1], 3), np.uint8)
cv2.imwrite('resultpoint_bw_2.png',im_bw)
for i in range(len(contours)):
# for each contour, draw the filled contour
draw = np.zeros((im_bw.shape[0], im_bw.shape[1]), np.uint8)
cv2.drawContours(draw, contours, i, (255,255,255), -1)
# for each column, calculate the centroid
for col in range(draw.shape[0]):
M = cv2.moments(draw[:, col])
if M['m00'] != 0:
x = col
y = int(M['m01']/M['m00'])
curves[y, x, :] = (0, 0, 255)
cv2.imwrite('resultpoint_0.png',curves)
в результате изображении на Poit неверен becouse является Контурами и не нуждаются в Контурах, но точка в аббревиатуре середины. ..
есть ли возможность сделать это?
Почему эти помеченные 'java' и' C++ '? – EdChum
becouse я ошибаюсь :) Мне нужно только pyton, C++ и opencv tag –
вы можете добавить свои образцы изображений? –