Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- start = time()
- def pixelFindColor2(match, p_x, p_x_max, p_y, tolerance=0):
- while not p_x == p_x_max:
- p_x += 1
- colour = grab_pixel(p_x, p_y)
- if colour == match:
- print('found match = {} {}'.format((p_x, p_y), colour))
- return p_x, p_y
- if tolerance > 0:
- for index in range(len(colour)):
- if colour[index]-tolerance > match[index]:
- print("x{},y{} +t{} mi{}".format(p_x, p_y, colour[index]-tolerance, match[index]))
- # too high
- pass
- elif colour[index]+tolerance < match[index]:
- print("x{},y{} +t{} mi{}".format(p_x, p_y, colour[index]+tolerance, match[index]))
- # too low
- pass
- else:
- print('tolerance found match = {} {}'.format((p_x, p_y), colour))
- return p_x, p_y
- print('Search done no match, retry!')
- return p_x, p_y
- x_2, y_2 = pixelFindColor2((121, 174, 98), 1688, 1835, 823, tolerance=30)
- # with 10 workers and 20 tasks, with each task being .5 seconds, then the completed job
- # is ~1 second using threading. Normally 20 tasks with .5 seconds each would take 10 seconds.
- print('Entire job took:',time() - start)
Advertisement
Add Comment
Please, Sign In to add comment