我正在尝试检测该车道图像上的边缘。首先使用高斯滤镜对图像进行模糊处理,然后应用Canny边缘检测,但仅产生空白图像而没有检测到边缘。
我这样做是这样的:
#imports
import matplotlib.pyplot as plt
import numpy as np
import cv2
import matplotlib.image as mpimg
image= mpimg.imread("Screenshot from Lane Detection Test Video 01.mp4.png")
image = image[:,:,:3]
image_g = cv2.cvtColor(image, cv2.COLOR_RGB2GRAY)
image_blurred = cv2.GaussianBlur(image_g, (3, 3), 0)
threshold_low = 50
threshold_high = 100
image_blurred = image_blurred.astype(np.uint8)
image_canny = cv2.Canny(image_blurred, threshold_low, threshold_high)
plt.imshow(image_canny,cmap='gray')
答案 0 :(得分:1)
您应该始终检查数据。只需简单地逐步运行脚本并检查中间值,就会发现问题所在:mpimg.imread
将图像读取为浮点数组,其值介于0到1之间。模糊后,将其转换为uint8
,它将几乎所有值都设置为0。只需在投射到uint8
之前的某个时候将图像乘以255,就可以解决您的问题。