How to use touch_image method in ATX

Best Python code snippet using ATX

request.py

Source:request.py Github

copy

Full Screen

1# -*- coding: utf-8 -*-2"""3リクエストサービス サンプルコード4<< --注意-- >>5On FP-version6As FP-version need the whole form with pictures or images you have to7custmoize the following source cord.We leave that job to you as the each8designs of form will be quite diffent.9On SP-version10The templatetags will provide the links.11As the SP-version only needs to create the link,12you can use this cord as the templatetags.13*A sample for the template14{% get_request_form request_users=player_friends_list submit_value="sendrequest" title="testtitle" body="bossisstrong" callbackurl=callbackurl mobile_url=mobile_url touch_url=touch_url option_params=option_params %}15{% get_request_form player_friends_list "sendrequest" "testtitle" "bossisstrong" callbackurl mobile_url touch_url option_params %}16 FP版について17 FP版では画像などを含むフォームを生成する必要がありますが、フォームのデザインは18 各場合によって著しく異なりますので共通化はしていません。19 下記のコードを参考にご自身のtemplatetagsをお書き下さい。20SP版について21 templatetagsでリンクを提供しています22 SP版はリンク生成のみなので、templatetagsとして利用できます23<< -------- >>24* テンプレートでは以下のように使う25例26{% get_request_form request_users=player_friends_list submit_value="リクエストを送信する" title="テストタイトル" body="ボスが強いよ" callbackurl=callbackurl mobile_url=mobile_url touch_url=touch_url option_params=option_params %}27{% get_request_form player_friends_list "リクエストを送信する" "テストタイトル" "ボスが強いよ" callbackurl mobile_url touch_url option_params %}28"""29import os30import urllib31from django import template32from gsocial.log import Log33register = template.Library()34abs_path = os.path.dirname(os.path.abspath(__file__))35file_path = abs_path + '/../templates/opensocial/request.html'36file_path_sp = abs_path + '/../templates/opensocial/request_sp.html'37@register.inclusion_tag(file_path)38def get_request_form( request_users,39 submit_value,40 title,41 body,42 callbackurl,43 mobile_url,44 touch_url,45 option_params={} ):46 u"""47 リクエストサービスのフォームを生成し、返す48 フィーチャーフォン版49 外部テンプレート: gsocial/templates/opensocial/request.html50 使い方::51 {% get_request_form <request_users> <submit_value> <title> <body> <callbackurl> <mobile_url> <touch_url> <option_params> %}52 引数:53 :request_users: リクエストを送信したいユーザリスト54 (to_user_id[]に渡すパラメータ)55 :submit_value: 送信ボタンの文言56 :title: リクエストのタイトル(必須)57 :body: 本文58 :callbackurl: リクエストした後に遷移するURL59 :mobile_url: リクエストをユーザがクリックした際の飛び先のURL(FP)60 :touch_url: リクエストをユーザがクリックした際の飛び先のURL(SP)61 :option_params: オプションディクショナリ62 option_params:63 :backto_url: リクエスト送信確認画面からアプリへ戻るためのURL64 :mobile_image: メッセージに含める画像のURL(FP)65 :touch_image: メッセージに含める画像のURL(SP)66 :list_type: リクエストの対象となるユーザの種別67 :editable: メッセージをユーザに入力させる68 :expire_time: リクエストが期限切れとなる日時(UTC FORMAT)69 Create the form for the request service and return it.(For FP)70 Customize the following source cord with your own designs of the forms.71 Arguments:72 :request_users: A Userlist whom you want to send request.(A parameter to be handed to to_user_id[])73 :submit_value: A letter on submit botton74 :title: The title of request(indispensable)75 :body: Message76 :callbackurl: A URL which will be redirected after the request.77 :mobile_url: A URL which will be redirected after the click(FP).78 :touch_url: A URL which will be redirected after the click(SP).79 :option_params: a optional dictionary80 option_params:81 :backto_url: A URL of the application from the "request sent confirmation"screen82 :mobile_image: URL of the image which will be contain in the message(FP)83 :touch_image: URL of the image which will be contain in the message(SP)84 :list_type: The type of subjected users.85 :editable: Whether User is allowed to edit or not.86 :expire_time: The expire date of the request(UTC FORMAT)87 """88 # checks the content of option_params89 # option_paramsの中身をチェック90 # TODO : もっと綺麗にしたい91 keys = option_params.keys()92 backto_url = option_params['backto_url'] if 'backto_url' in keys else None93 mobile_image = option_params['mobile_image'] if 'mobile_image' in keys else None94 touch_image = option_params['touch_image'] if 'touch_image' in keys else None95 list_type = option_params['list_type'] if 'list_type' in keys else None96 editable = option_params['editable'] if 'editable' in keys else None97 expire_time = option_params['expire_time'] if 'expire_time' in keys else None98 # title is indispensable,so check.99 # titleは必須のため、チェック100 if not title:101 Log.error('title is empty.', body)102 raise103 # if list_type was not setted,use "specified"104 # list_typeの指定が無かった場合、specifiedを指定する105 if list_type == None:106 list_type = 'specified'107 # body is indispensable when editable is True,so check108 # bodyはeditableがtrueでない場合は必須のため、チェック109 # TODO : editable==Trueの場合、メッセージをユーザに入力させる110 # そのため、フォーム生成のhtml側で、入力フォームを生成する必要がある111 if editable != True:112 if body == None:113 Log.error('body is empty.', body)114 raise115 if request_users:116 temp = []117 for user in request_users:118 user_params = {}119 user_params['id'] = user['id'] if 'id' in user else None120 user_params['nickname'] = user['nickname'] if 'nickname' in user else None121 user_params['thumbnail'] = user['thumbnail'] if 'thumbnail' in user else None122 temp.append(user_params)123 return {124 'request_users': temp,125 'submit_value': submit_value,126 'title': title,127 'body': body,128 'callbackurl': callbackurl,129 'mobile_url': mobile_url,130 'touch_url': touch_url,131 'backto_url': backto_url,132 'mobile_image': mobile_image,133 'touch_image': touch_image,134 'list_type': list_type,135 'editable': editable,136 'expire_time': expire_time,137 }138@register.inclusion_tag(file_path_sp)139def get_request_form_sp( request_users,140 submit_value,141 title,142 body,143 callbackurl,144 mobile_url,145 touch_url,146 option_params={} ):147 u"""148 リクエストサービスのリンクを作成し、返す149 スマートフォン版150 外部テンプレート: gsocial/templates/opensocial/request_sp.html151 使い方::152 {% get_request_form <request_users> <submit_value> <title> <body> <callbackurl> <mobile_url> <touch_url> <option_params> %}153 引数:154 :request_users: リクエストを送信したいユーザリスト155 (to_user_id[]に渡すパラメータ)156 :submit_value: 送信ボタンの文言157 :title: リクエストのタイトル(必須)158 :body: 本文159 :callbackurl: リクエストした後に遷移するURL160 :mobile_url: リクエストをユーザがクリックした際の飛び先のURL(FP)161 :touch_url: リクエストをユーザがクリックした際の飛び先のURL(SP)162 :option_params: オプションディクショナリ163 option_params:164 :backto_url: リクエスト送信確認画面からアプリへ戻るためのURL165 :mobile_image: メッセージに含める画像のURL(FP)166 :touch_image: メッセージに含める画像のURL(SP)167 :list_type: リクエストの対象となるユーザの種別168 :editable: メッセージをユーザに入力させる169 :expire_time: リクエストが期限切れとなる日時(UTC FORMAT)170 Create the link for the request service and return it.(For SP)171 Arguments:172 :request_users: A Userlist whom you want to send request.(A parameter to be handed to to_user_id[])173 :submit_value: A letter on submit botton174 :title: The title of request(indispensable)175 :body: Message176 :callbackurl: A URL which will be redirected after the request.177 :mobile_url: A URL which will be redirected after the click(FP).178 :touch_url: A URL which will be redirected after the click(SP).179 :option_params: a optional dictionary180 option_params:181 :backto_url: A URL of the application from the "request sent confirmation"screen182 :mobile_image: URL of the image which will be contain in the message(FP)183 :touch_image: URL of the image which will be contain in the message(SP)184 :list_type: The type of subjected users.185 :editable: Whether User is allowed to edit or not.186 :expire_time: The expire date of the request(UTC FORMAT)187 """188 # check the content of option_params189 # option_paramsの中身をチェック190 # TODO : もっと綺麗にしたい191 keys = option_params.keys()192 backto_url = option_params['backto_url'] if 'backto_url' in keys else None193 mobile_image = option_params['mobile_image'] if 'mobile_image' in keys else None194 touch_image = option_params['touch_image'] if 'touch_image' in keys else None195 list_type = option_params['list_type'] if 'list_type' in keys else None196 editable = option_params['editable'] if 'editable' in keys else None197 expire_time = option_params['expire_time'] if 'expire_time' in keys else None198 # title is indispensable ,so check199 # titleは必須のため、チェック200 if not title:201 Log.error('title is empty.', body)202 raise203 # if list_type was not setted ,use "specified"204 # list_typeの指定が無かった場合、specifiedを指定する205 if list_type == None:206 list_type = 'specified'207 # if editable is True body is indispensable,so check208 # bodyはeditableがtrueでない場合は必須のため、チェック209 # TODO : editable==Trueの場合、メッセージをユーザに入力させる210 # そのため、フォーム生成のhtml側で、入力フォームを生成する必要がある211 if editable != True:212 if body == None:213 Log.error('body is empty.', body)214 raise215 # encode216 # エンコードする217 callbackurl = urllib.quote(callbackurl)218 # create a parameter to be handed to user_to_id219 # user_to_idに渡すパラメータを生成220 request_user_ids_str = ','.join(request_users)221 return {222 'request_users': request_user_ids_str,223 'submit_value': submit_value,224 'title': title,225 'body': body,226 'callbackurl': callbackurl,227 'mobile_url': mobile_url,228 'touch_url': touch_url,229 'backto_url': backto_url,230 'mobile_image': mobile_image,231 'touch_image': touch_image,232 'list_type': list_type,233 'editable': editable,234 'expire_time': expire_time,...

Full Screen

Full Screen

kmeans.py

Source:kmeans.py Github

copy

Full Screen

1##################################2# FORAGE DE DONNES #3# TP2 - CLUSTERING DE COULEURS #4# Auteurs : - MELLIER Valentin #5# - LAUGIER Alexis #6##################################7#Libs utilisés dans le fichier kmeans.py8from PIL.Image import *9from random import *10from math import sqrt11def euclidian_distance(p1, p2):12 return sqrt((p1[0]-p2[0])**2+(p1[1]-p2[1])**2+(p1[2]-p2[2])**2)13def manhattan_distance(p1, p2):14 return (abs(p1[0]-p2[0])+abs(p1[1]-p2[1])+abs(p1[2]-p2[2]))15def KMeansOnImage(imagepath,k,iter,dist):16 #Ouverture de l'image de référence17 untouch_image=open(imagepath).load()18 #Ouverture de l'image qui sera modifié19 touch_image = open(imagepath)20 #Récupération des dimensions21 width, height = touch_image.size22 #Génération aléatoire de k centroïdes dans l'image23 centroids = generateKColors(k,touch_image)24 #Chargement de l'image qui sera modifiée25 Update_image = touch_image.load()26 for i in range(0,iter):27 #Variable contenant les pixels rattachés à chaque centroïde28 get_pix_for_each_centroids=[[] for r in range(k)]29 #On parcourt l'image30 for x in range(width):31 for y in range(height): 32 centroids_dist_from_pix=[]33 #Pour chaque centroïde34 for elem in centroids:35 #On stocke les distances du pixel(x,y) à chaque centroïde36 if dist=="manhattan" : 37 centroids_dist_from_pix.append(manhattan_distance(elem,untouch_image[x,y]))38 elif dist=="euclidian":39 centroids_dist_from_pix.append(euclidian_distance(elem,untouch_image[x,y]))40 41 42 #On assigne le pixel au centroïde le plus proche43 get_pix_for_each_centroids[centroids_dist_from_pix.index(min(centroids_dist_from_pix))].append(untouch_image[x,y])44 Update_image[x,y] = centroids[centroids_dist_from_pix.index(min(centroids_dist_from_pix))] 45 #On replace chaque centroïde en calculant la moyenne des distances aux autres pixels46 centroids=computeMean(centroids, get_pix_for_each_centroids)47 touch_image.save("./result/result_image_kmeans.png")48 49 50 51def computeMean(centroids, centroidsPixList):52 #On calcule la moyenne et on retourne la nouvelle valeur du centroïde53 for elem in centroidsPixList:54 r_sum=055 g_sum=056 b_sum=057 for rgbtuple in elem:58 r_sum+=rgbtuple[0]59 g_sum+=rgbtuple[1]60 b_sum+=rgbtuple[2]61 centroids[centroidsPixList.index(elem)]=(int(r_sum/(len(elem)+1)),int(g_sum/(len(elem)+1)),int(b_sum/(len(elem)+1)))62 return centroids63#Définition de centroïdes random dans l'image64def generateKColors(k,image):65 init_Kcentroid_list=[]66 for i in range(0,k):67 init_Kcentroid_list.append(image.getpixel((randint(0,image.size[0]-1),randint(0,image.size[1]-1))))68 return init_Kcentroid_list...

Full Screen

Full Screen

main.py

Source:main.py Github

copy

Full Screen

...29 self.select_support()30 self.start_training()31 self.training.start()32 def tap_training_button(self):33 Util.touch_image(self.images.home.training_button)34 def select_training(self):35 Util.touch_image(self.images.select.next_button)36 def select_umamusume(self):37 Util.touch_image(self.target_umamusume.thumbnail)38 Util.touch_image(self.images.select.next_button)39 def select_random_parents(self):40 Util.touch_image(self.images.select.parents_random_select)41 Util.touch_image(self.images.select.ok_button)42 Util.touch_image(self.images.select.next_button)43 def select_support(self):44 Util.touch_image(self.images.select.support_random_select)45 Util.touch_image(self.images.select.ok_button)46 def start_training(self):47 Util.touch_image(self.images.select.start_training)48 Util.touch_image(self.images.select.confirm_starting_training)49if __name__ == '__main__':50 args = sys.argv51 if not len(args) == 2:52 print('Invalid arguments.')53 exit(1)54 umamusume_name = args[1]55 main = Main(umamusume_name)...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run ATX automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful