python - 显示输出时使用opencv显示更大的图像尺寸
问题描述
在执行模板匹配时,显示的输出尺寸非常小,这无助于确定边界框的位置,如何在显示输出时显示更大的图像?
这是我的代码:
import cv2
import numpy as np
from matplotlib import pyplot as plt
%matplotlib inline
img_rgb = cv2.imread('ddd/radiobutton.png')
img_gray = cv2.cvtColor(img_rgb, cv2.COLOR_BGR2GRAY)
template = cv2.imread('ddd/temp.png', 0)
height, width = template.shape[::]
res = cv2.matchTemplate(img_gray, template, cv2.TM_CCOEFF_NORMED)
plt.imshow(res, cmap='gray')
min_val, max_val, min_loc, max_loc = cv2.minMaxLoc(res)
top_left = min_loc
bottom_right = (top_left[0]+ width, top_left[1]+height)
# cv2.rectangle(img_rgb, top_left, bottom_right, (255, 0, 0), 2)
cv2.rectangle(img_rgb, top_left, bottom_right, (255, 0, 0), 10)
cv2.imshow("Matched image", img_rgb)
plt.imshow(img_rgb)
plt.show(1900,2000)
解决方案
您可以使用以下行更改图形大小:
plt.figure(figsize=(x, y))
参数x
和y
需要设置,为您的特定图像。
推荐阅读
- javascript - 使用 JavaScript 向 url 添加参数
- sql - 如何使用 INSERT INTO SELECT 和 NOT EXISTS 避免重复的主键值
- java - @NonNull 注解允许在验证中使用空值
- sql-server - 数据库从磁盘分配新空间,即使数据库上有 160 GB 空间可用
- python - 从python中的xlsx文件中的一组行中获取一个随机项
- uwp - 无法在 UWP Windows 应用程序打包解决方案中打开 AppServiceConnection
- reactjs - 如何将 React 集成到 React Native WebView 中?
- javascript - 实现 PDF.js 查看器示例
- python - state_dict 中的意外键:“模型”、“选择”
- powershell - 将一列复制到另一列