12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- import cv2
- import yaml
- import numpy as np
- import sys
- import os
- def test():
- pers_file = "./yaml/pers.yaml"
- W, H = 640, 360
- init_files="./yaml/init.yaml"
-
- with open(init_files, "r") as f:
- init_data = yaml.load(f)
-
- source = init_data["source"]
-
- img = cv2.imread('./img.jpg')
- def on_EVENT_LBUTTONDOWN(event, x, y, flags, param):
- if event == cv2.EVENT_LBUTTONDOWN:
- xy = "%d,%d" % (x, y)
- cv2.circle(img, (x, y), 1, (255, 0, 0), thickness=-1)
- print((x,y))
- cv2.putText(img, xy, (x, y), cv2.FONT_HERSHEY_PLAIN,
- 1.5, (255, 255, 255), thickness=2)
- cv2.imshow("image", img)
- cv2.namedWindow("image", cv2.WINDOW_AUTOSIZE)
- cv2.setMouseCallback("image", on_EVENT_LBUTTONDOWN)
- cv2.imshow("image", img)
- #fs = cv2.FileStorage(pers_file, cv2.FILE_STORAGE_WRITE)
-
- while (True):
- try:
- if cv2.waitKey(10) & 0xFF == ord('q'):
- break
- except Exception:
- cv2.destroyWindow("image")
- break
- if __name__=='__main__':
- test()
|