
python如何获取鼠标点击图片的像素点坐标
发布日期:2021-05-10 09:15:15
浏览次数:24
分类:精选文章
本文共 1671 字,大约阅读时间需要 5 分钟。
# -*- coding: utf-8 -*-"""@File : get_actual_depth.py@Time : 2020/11/10 15:22@Author : Dontla@Email : sxana@qq.com@Software: PyCharm"""import cv2import numpy as npcount = 15path = './capture_depth_color_data/2020-11-6_14-56-19/'def get_actual_depth(count): depth_img = np.load('{}{}.npy'.format(path, count)) # 图片路径 img = cv2.imread('{}{}.jpg'.format(path, count)) flag = False a = [] b = [] def on_EVENT_LBUTTONDOWN(event, x, y, flags, param): if event == cv2.EVENT_LBUTTONDOWN: xy = "%d,%d" % (x, y) a.append(x) b.append(y) cv2.circle(img, (x, y), 1, (0, 0, 255), thickness=-1) # 绘圆点 cv2.putText(img, xy, (x, y), cv2.FONT_HERSHEY_PLAIN, 1.0, (0, 0, 0), thickness=1) cv2.imshow("{}.jpg".format(count), img) # print(x, y) print(a[0], b[0]) print(depth_img[b[0], a[0]]) while True: cv2.namedWindow("{}.jpg".format(count), cv2.WINDOW_NORMAL) cv2.setWindowProperty("{}.jpg".format(count), cv2.WND_PROP_FULLSCREEN, cv2.WINDOW_FULLSCREEN) cv2.setMouseCallback("{}.jpg".format(count), on_EVENT_LBUTTONDOWN) cv2.imshow("{}.jpg".format(count), img) cv2.waitKey(0) if len(a) > 0: if depth_img[b[0], a[0]] > 0: actual_depth = depth_img[b[0], a[0]] # print(actual_depth) break else: a = [] b = [] np.save('{}{}_actual_depth.npy'.format(path, count), actual_depth) # a = np.load('{}{}_actual_depth.npy'.format(path, count))while True: get_actual_depth(count) count += 1

发表评论
最新留言
哈哈,博客排版真的漂亮呢~
[***.90.31.176]2025年04月15日 00时14分03秒
关于作者

喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
重载和重写的区别:
2021-05-10
finally,final,finalize() 的区别
2021-05-10
搭建Vue项目步骤
2021-05-10
docker镜像命令
2021-05-10
docker容器命令
2021-05-10
CentOS7使用keepalive实现nginx的高可用
2021-05-10
Centos7.4下mysql5.6开启ssl
2021-05-10
oracle查看字符集后修改oracle服务端和客户端字符集的步骤
2021-05-10
Oracle闪回查询总结
2021-05-10
NAT端口复用型
2021-05-10
android中自定义标题栏左边距问题
2021-05-10
c学习-28
2021-05-10
Linux环境编程--03 文件IO
2021-05-10
使用C语言获取文件夹地址的方法收藏
2021-05-10
微盟实习
2021-05-10
HDU——3374 String Problem (最大最小表示法+循环节+kmp)
2021-05-10
文件读写(java)
2021-05-10
Markdown中Latex常见数学符号
2021-05-10