Download pool/shard008/Python/0071352_Threshold.py from Variable-role/sajaniemi_variable_dataset_large: direct link, hf CLI and curl.
- Browser
- Download file 1.78 kB
-
https://huggingface.co/datasets/Variable-role/sajaniemi_variable_dataset_large/resolve/main/pool/shard008/Python/0071352_Threshold.py
- Command line
-
hf download hf://datasets/Variable-role/sajaniemi_variable_dataset_large/pool/shard008/Python/0071352_Threshold.py
-
curl -L -o 0071352_Threshold.py https://huggingface.co/datasets/Variable-role/sajaniemi_variable_dataset_large/resolve/main/pool/shard008/Python/0071352_Threshold.py
1.78 kB
| import cv2 | |
| import numpy as np | |
| from matplotlib import pyplot as plt | |
| import os | |
| from desktopmagic.screengrab_win32 import getScreenAsImage as getMultiScreenAsImage | |
| from PIL import Image | |
| import os | |
| from pytank.Core.Classes import ScriptSettings | |
| ############################################### | |
| lastdur = os.getcwd() | |
| atext = "Configurator.media.Click()"#self.get_selected_text() | |
| folderpath = "C:\Elan_Tools\ImageScripter\ProgramData\SystemFiles\Python\Lib\site-packages\pytank\User\UserData\Applications\\" | |
| alist = atext.split('.') | |
| theapp = alist[0] | |
| print("App->") | |
| print(theapp) | |
| print('') | |
| theimage = alist[1] + '.png' | |
| print("Image->") | |
| print(theimage) | |
| print('') | |
| theAction = alist[2] | |
| print("Action->") | |
| print(theAction) | |
| print('') | |
| imagepath = folderpath + theapp + '\\' + theapp + '_' + theimage | |
| print("Path of Image->") | |
| print(imagepath) | |
| print('') | |
| if os.path.exists(imagepath): | |
| os.chdir(r"C:\Elan_Tools\Data\Playground") | |
| def Save_Multi_Monitor_ScreenShot(): | |
| im = getMultiScreenAsImage() | |
| name_Of_Image = 'templet.png' | |
| im.save(name_Of_Image, format='png') | |
| Save_Multi_Monitor_ScreenShot() | |
| ######################################################################## | |
| img_rgb = cv2.imread("templet.png") | |
| img_gray = cv2.cvtColor(img_rgb, cv2.COLOR_BGR2GRAY) | |
| template = cv2.imread(imagepath, 0) | |
| w, h = template.shape[::-1] | |
| res = cv2.matchTemplate(img_gray, template, cv2.TM_CCOEFF_NORMED) | |
| threshold = ScriptSettings.Threshold | |
| loc = np.where(res >= threshold) | |
| for pt in zip(*loc[::-1]): | |
| cv2.rectangle(img_rgb, pt, (pt[0] + w, pt[1] + h), (0, 0, 255), 2) | |
| cv2.imwrite("res.png", img_rgb) | |
| if os.path.exists("res.png"): | |
| img = Image.open("res.png") | |
| img.show() | |
| else: | |
| print('pass image') | |