- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有以下图像,其中包含无人机捕获的汽车和空 parking 位。我想检测空的公园空间并绘制一个看起来像预期图像的框。
这是我的代码:
import cv2
import numpy as np
from matplotlib import pyplot as plt
%matplotlib inline
img = cv2.imread('parking.jpg')
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
gray = cv2.cvtColor(img,cv2.COLOR_RGB2GRAY)
blurred = cv2.bilateralFilter(gray,21,41,41)
edged = cv2.Canny(blurred,400,600)
thresh = cv2.adaptiveThreshold(blurred, 255, cv2.ADAPTIVE_THRESH_GAUSSIAN_C, cv2.THRESH_BINARY, 5, 40)
mask = cv2.bitwise_not(edged)
thresh = cv2.bitwise_and(thresh,thresh,mask=mask)
kernel = cv2.getStructuringElement(cv2.MORPH_RECT,(3,3))
thresh = cv2.morphologyEx(thresh,cv2.MORPH_OPEN,kernel)
contours, hierarchy = cv2.findContours(thresh, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
output = img.copy()
cv2.drawContours(output, contours, -1, (0,255,0), 1)
plt.imshow(output)
最佳答案
我认为这种方法行不通。有两种方法可以解决这个问题:
关于python - 如何使用 morphologyEx 和 drawContours 检测空的公园空间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57672783/
我正在编写一个 c++ 代码,用于比较使用 CPU 和 GPU 版本的 opencv morphologyEx 方法的性能。这是我的代码: #include #include #include
去除验证码背景后。 图像保留数字和噪声。 噪声线都是一种颜色:RGB(127,127,127) 然后使用形态学方法。 kernel = cv2.getStructuringElement(cv
我想用白色边框填充我的灰度图像,以便在 opencv(在 Python 中)中进行形态关闭。文档并没有真正说明函数需要什么。我一直在尝试以下两个示例但无济于事: smooth_mask = cv2.m
我有以下图像,其中包含无人机捕获的汽车和空 parking 位。我想检测空的公园空间并绘制一个看起来像预期图像的框。 这是我的代码: import cv2 import numpy as np fro
如何使用新的emgu版本打开和关闭图像处理? 我发现了这个: www.stackoverflow.com/questions/11567350/opening-and-closing-using-op
我在一个使用形态学函数的 opencv 项目中工作。现在我正在尝试在 gpu 支持下进行。 当我使用 opencv 3.0 和 cuda 7.5 支持编译我的程序时,它接受除了 morphologyE
我需要在我的图像处理项目中调用 cvMorphologyEx,我使用这一行来完成。 cvMorphologyEx(src1,dest1,NULL,NULL,CV_MOP_OPEN); 编译正常,但运行
我是一名优秀的程序员,十分优秀!