def __init__(self, master=None): super().__init__(master) self.master = master self.source_image = None self.selected_letter = None self.selected_letter_snake = None # GUI setup self.pack() self.create_widgets() # Controls self.bind_keyboard_events() if '-d' in sys.argv: self.debug = True else: self.debug = False if self.debug: print('DEBUG MODE IS ON') source_image = get_image_from_file('resources/test_text.tif') charactar_image = get_image_from_file('resources/beit-test.tif') self.set_source_image(source_image) contoured_image = get_letter_contours(charactar_image) self.add_selectable_letter_image(contoured_image)
def output(ff, frame): num = entry.get() n = str(num) image = n + '.png' imgbytes = image_helpers.get_image_from_file(image) rekesp = client.detect_faces(Image={'Bytes': imgbytes}, Attributes=['ALL']) how_many = len(rekesp['FaceDetails']) ff.tkraise() text = "사람 수는 총 " + how_many + "명입니다." l = Label(ff, text=text) l.place(x=150, y=100) l.img = PhotoImage(file=image) l.config(font=(44)) l.config(image=l.img, compound='bottom') l.pack() Button(ff, text='RESTART', command=lambda: raise_frame(f1)).place(x=100, y=410) Button(ff, text='Quit', command=lambda: root.destroy()).place(x=170, y=410)
def output(ff3, ff4): num = entry.get() #엔트리값 받아오기 image = num + '.png' imgbytes = image_helpers.get_image_from_file(image) rekesp = client.detect_faces(Image={'Bytes': imgbytes}, Attributes=['ALL']) how_many = len(rekesp['FaceDetails']) ff3.tkraise() #프레임f3로 이동 label1 = Label(ff3) # 라벨 생성 label1.place(x=150, y=100) # 위치 label1.img = PhotoImage(file='result.png') # 이미지 label1.config(image=label1.img, compound='bottom') # 이미지추가 label1.pack() # 배치 #사람 수 te = Label(ff3, text=how_many) te.place(x=170, y=90) #위치 te.config(font=(44)) #글자크기 수정 #+버튼 bu1 = Button(ff3, command=lambda: raise_frame(ff4)) #프레임4로 이동 bu1.place(x=130, y=170) logo = PhotoImage(file='+.png') #이미지 bu1.img = logo.subsample(5, 5) bu1.config(image=bu1.img, compound=LEFT, bd=0) #quit버튼 bu2 = Button(ff3, command=lambda: root.destroy()) #클릭시 종료 bu2.place(x=170, y=170) logo1 = PhotoImage(file='quit.png') #이미지 bu2.img = logo1.subsample(5, 5) bu2.config(image=bu2.img, compound=LEFT, bd=0) #4번째 프레임 l = Label(ff4) #사진출력 l.place(x=150, y=100) #위치 l.img = PhotoImage(file=image) l.config(image=l.img, compound='bottom') l.pack()
import boto3 from pprint import pprint import image_helpers COLLECTION = "myCollection" image_id = COLLECTION client = boto3.client('rekognition') #client.create_collection(CollectionId=COLLECTION) imgurl = 'https://www.parrots.org/images/uploads/dreamstime_C_47716185.jpg' imgurl = 'http://www.idothat.us/images/idothat-img/features/pool-patio-lanai/ft-pool-patio-lanai-2.jpg' imgurl = 'http://docs.aws.amazon.com/rekognition/latest/dg/images/text.png' # grab the image from online imgbytes = image_helpers.get_image_from_url(imgurl) imgfile = 'text-image.png' imgbytes = image_helpers.get_image_from_file(imgfile) rekresp = client.index_faces(Image={'Bytes': imgbytes}, CollectionId=COLLECTION, ExternalImageId=image_id, DetectionAttributes=['ALL']) pprint(rekresp)
import boto3 from pprint import pprint import image_helpers as ih client = boto3.client('rekognition') img_path = 'images/socket-background.jpg' img_bytes = ih.get_image_from_file(img_path) rek_resp = client.detect_labels(Image={'Bytes': img_bytes}) pprint(rek_resp) print('Here is what I see in the image:\n') for label in rek_resp['Labels']: print(label['Name'])
#imgbytes = image_helpers.get_image_from_url(imgurl) #filename = '/home/jf/Downloads/invoice-test/invoice4.png' parser = argparse.ArgumentParser(description='Recive a Path of a Folder') parser.add_argument('directory', type=str, help='A folder path') args = parser.parse_args() folder = args.directory + '/' filenames = os.listdir(folder) print(filenames) list_imgbytes = [] for filename in filenames: list_imgbytes.append( image_helpers.get_image_from_file(folder + filename)) #response=client.detect_text(Image={'S3Object':{'Bucket':bucket,'Name':photo}}) list_response = [] for imgbytes in list_imgbytes: list_response.append(client.detect_text(Image={'Bytes': imgbytes})) list_textDetections = [] for response in list_response: list_textDetections.append(response['TextDetections']) print(response) #Json file with open('data.json', 'a') as outfile: json.dump(response, outfile, sort_keys=True,
#imgurl = 'https://i.imgur.com/1FwHQja.png' #imgbytes = image_helpers.get_image_from_url(imgurl) #filename = '/home/jf/Downloads/invoice-test/invoice4.png' parser = argparse.ArgumentParser(description='Recive a Path of a Folder') parser.add_argument('directory', type=str, help='A folder path') args = parser.parse_args() folder = args.directory + '/y' filenames = os.listdir(folder) print(filenames) list_imgbytes = [] for filename in filenames: list_imgbytes.append(image_helpers.get_image_from_file(folder + filename)) #response=client.detect_text(Image={'S3Object':{'Bucket':bucket,'Name':photo}}) list_response = [] for imgbytes in list_imgbytes: list_response.append(client.detect_text(Image={'Bytes': imgbytes})) list_textDetections=[] for response in list_response: list_textDetections.append(response['TextDetections']) print(response) #Json file with open('data.json', 'a') as outfile: json.dump(response, outfile, sort_keys = True, indent = 4, ensure_ascii = False)