def find_min(): # Size size = [ 5, 5 ]; print size # Loop while err != 0 err = 0 while err == 0: # Try a bunch of times mx = min( 2**(size[0] * size[1]), 100**2 ) for i in xrange( mx ): if i%100 == 0: print i # Generate a random matrix mtx = generate_rand( size ) [ err, found_s ] = find_error( mtx ) # If error, try the compliment if err != 0: for i in mtx: for k in xrange(len(i)): i[k] = 1 - i[k] [ err, found_s2 ] = find_error( mtx ) # If error, break if err != 0: break # If err == 0, increase size if err == 0: size[0 if size[0] < size[1] else 1] += 1 print size # Print info print 'Min size matrix found is {} x {}'.format(size[0], size[1]) print 'Error: ', err for i in mtx: for k in xrange(len(i)): i[k] = 1 - i[k] print_image(mtx) print "Found " print_image(found_s) for i in mtx: for k in xrange(len(i)): i[k] = 1 - i[k] print_image(mtx) print "Found " print_image(found_s2)
#x좌표 패딩값.(좌) x = 0 font = ImageFont.load_default() #"Bazzi.ttf"라는 글꼴 외에도 다른 ttc, ttf 파일을 추가하면 원하는 글꼴을 이용하여 출력하실 수 있습니다.(하단코드 Bazzi.ttf 부분 수정) font_ko = ImageFont.truetype( "/home/pi/Adafruit_Python_SSD1306/examples/Bazzi.ttf", 12, 0) sw = 0 #list에서 가져온 텍스트를 이용하기 위해 save_text라는 리스트를 선언. save_text = list() rt.url_decode(save_text) #로고 출력 filename = "/home/pi/Adafruit_Python_SSD1306/examples/Alpha.ppm" img.print_image(filename) #인공지능실행 #os.system('python3 /home/pi/Adafruit_Python_SSD1306/examples/first.py') while True: draw.rectangle((0, 0, width, height), outline=0, fill=0) info = "Who?" if sw == 0: draw.text((x, top), "Info", font=font, fill=255) draw.text((x + 20, top + 25), unicode(save_text[sw], 'utf-8', 'ignore'), font=font_ko, fill=255) print("0")