相关疑难解决方法(0)

使用鼠标单击/事件获取像素位置

我希望在显示图像时通过右键单击鼠标来收集像素位置(row-i,col-i)。

这是一个关于从互联网下载的图片的简单示例:

import urllib
import cv2
from win32api import GetSystemMetrics

path_image = urllib.urlretrieve("http://www.bellazon.com/main/uploads/monthly_06_2013/post-37737-0-06086500-1371727837.jpg", "local-filename.jpg")[0]
img = cv2.imread(path_image,0)
width = GetSystemMetrics(0)
height = GetSystemMetrics(1)
scale_width = width / img.shape[1]
scale_height = height / img.shape[0]
scale = min(scale_width, scale_height)
window_width = int(img.shape[1] * scale)
window_height = int(img.shape[0] * scale)
cv2.namedWindow('image', cv2.WINDOW_NORMAL)
cv2.resizeWindow('image', window_width, window_height)
cv2.imshow('image', img)
cv2.waitKey(0)
cv2.destroyAllWindows()
Run Code Online (Sandbox Code Playgroud)

此时,我希望了解在 .txt 文件中收集和存储像素位置的最佳方法list

python opencv position

3
推荐指数
1
解决办法
2万
查看次数

标签 统计

opencv ×1

position ×1

python ×1