Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. import cv2
  2. import numpy as np
  3.  
  4.  
  5. def nothing(x):
  6. pass
  7.  
  8. newim = cv2.imread("C:/Users/Slayer/Desktop/znak1.png")
  9. table = []
  10. cv2.namedWindow('swift')
  11. part = newim
  12.  
  13.  
  14. def handleclick(event, x, y, flags, param):
  15. global part, table
  16. if event == cv2.EVENT_LBUTTONDOWN:
  17. print(x,y)
  18. table.append((x, y))
  19. if len(table) >= 2:
  20.  
  21. px1, py1 = table[0]
  22. px2, py2 = table[1]
  23.  
  24. part = cv2.bitwise_not(newim[py1:py2, px1:px2])
  25. newim[py1:py2, px1:px2] = part
  26. table = []
  27.  
  28.  
  29. cv2.setMouseCallback('swift', handleclick)
  30.  
  31. while True:
  32. cv2.imshow('swift', newim)
  33. k = cv2.waitKey(1) & 0xFF
  34. if k == ord('q'):
  35. break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement