python - 识别车内车辆登记的轮廓区域
问题描述
我正在尝试识别德国车辆登记的轮廓区域。我遵循了一些教程,并有了将 cv2 findContours 与 HoughLinesP 结合使用的想法。挑战在于注册是由坐在车内的人持有的。
- 手打破注册的轮廓
- 汽车有其他轮廓,例如注册,例如汽车收音机
- 配准超出了图像的边界。
当我根据我创建的线条裁剪图像时,我从收音机而不是注册中得到了一些东西。因为注册的线路没有连接。
如果有人能指出我正确的方向,我将不胜感激。
def crop_image(dilated):
binary = cv2.threshold(dilated, 150, 255, cv2.THRESH_BINARY)[1]
cv2.imshow("binary", binary)
edges = cv2.Canny(binary, 150, 84, apertureSize=3)
cv2.imshow("canny", edges)
dilted_lines = dilated
lines = cv2.HoughLinesP(edges, 1, 3.14 / 180, 100, minLineLength=15, maxLineGap=500)
for line in lines:
l = line[0]
cv2.line(dilted_lines, (l[0], l[1]), (l[2], l[3]),
(0, 255, 0), 4)
cv2.imshow("lines", dilted_lines)
contours, _ = cv2.findContours(edges, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
sortedCnt = sorted(contours, key=lambda x: cv2.contourArea(x))
x, y, w, h = cv2.boundingRect(sortedCnt[-1])
cv2.imshow("crop", dilated[y:y + h, x:x + w])
解决方案
推荐阅读
- objectify - Objectify 中的会话缓存不会针对实体的更新而更新。它只返回过时的数据
- python - Usage examples show input to a python function that isn't separated by commas?
- java - 有没有简单的方法从遗留的 java MongoClient 中提取连接字符串
- ios - 如何让按钮快速挑选出不同的随机文本字符串?
- r - 在 R 中使用整洁的数据创建桑基图
- javascript - 为什么 Firestore Cloud Function 返回错误的请求响应?
- c++ - 在 cpp 中将多边形添加到网格中(使用 maya api 接口)
- javascript - 我想使用父类获取跨度内的数据
- python - Django:如何链接到特定用户?
- python - Python boto3 - Athena Query - start_query_execution - 请求中包含的安全令牌无效