Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import cv2
- import numpy as np
- def nothing(x):
- pass
- newim = cv2.imread("C:/Users/Slayer/Desktop/znak1.png")
- table = []
- cv2.namedWindow('swift')
- part = newim
- def handleclick(event, x, y, flags, param):
- global part, table
- if event == cv2.EVENT_LBUTTONDOWN:
- print(x,y)
- table.append((x, y))
- if len(table) >= 2:
- px1, py1 = table[0]
- px2, py2 = table[1]
- part = cv2.bitwise_not(newim[py1:py2, px1:px2])
- newim[py1:py2, px1:px2] = part
- table = []
- cv2.setMouseCallback('swift', handleclick)
- while True:
- cv2.imshow('swift', newim)
- k = cv2.waitKey(1) & 0xFF
- if k == ord('q'):
- break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement