test01.py 1.0 KB

12345678910111213141516171819202122232425262728
  1. import cv2
  2. import matplotlib.pyplot as plt
  3. img = cv2.imread(r"C:\Code\ML\Project\CheckCardBoxAndDefectServer\_temp_work\temp_area_result.jpg")
  4. x1_min = 251
  5. y1_min = 273
  6. x1_max = 2636
  7. y1_max = 3662
  8. x2_min = 146
  9. y2_min = 177
  10. x2_max = 2735
  11. y2_max = 3767
  12. img = cv2.line(img, pt1=(x1_min, y1_min), pt2=(x1_min, y1_max), color=(0, 0, 255), thickness=4)
  13. img = cv2.line(img, pt1=(x1_min, y1_min), pt2=(x1_max, y1_min), color=(0, 0, 255), thickness=4)
  14. img = cv2.line(img, pt1=(x1_max, y1_max), pt2=(x1_min, y1_max), color=(0, 0, 255), thickness=4)
  15. img = cv2.line(img, pt1=(x1_max, y1_max), pt2=(x1_max, y1_min), color=(0, 0, 255), thickness=4)
  16. img = cv2.line(img, pt1=(x2_min, y2_min), pt2=(x2_min, y2_max), color=(0, 200, 255), thickness=4)
  17. img = cv2.line(img, pt1=(x2_min, y2_min), pt2=(x2_max, y2_min), color=(0, 200, 255), thickness=4)
  18. img = cv2.line(img, pt1=(x2_max, y2_max), pt2=(x2_min, y2_max), color=(0, 200, 255), thickness=4)
  19. img = cv2.line(img, pt1=(x2_max, y2_max), pt2=(x2_max, y2_min), color=(0, 200, 255), thickness=4)
  20. plt.imshow(img)
  21. plt.show()