Example #1
0
def recognize(pic, dir_train_pics):
	pic = Image.open(pic)
	#print 'preprocessor.preprocess'
	pic_preprocessed = preprocessor.preprocess(pic)
	block_array = []
	#print 'spliter.split'
	spliter.split(pic_preprocessed, block_array)
	captcha = ""
	if len(block_array) >= THRESHOLD_BLOCK_NUMBER:
		#print 'recognize_block_array'
		captcha = recognize_block_array(block_array, dir_train_pics)
	return captcha
Example #2
0
def recognize(pic, dir_train_pics):
	pic = Image.open(pic)
	print 'preprocessor.preprocess'
	pic_preprocessed = preprocessor.preprocess(pic)
	block_array = []
	print 'spliter.split'
	spliter.split(pic_preprocessed, block_array)
	captcha = ""
	if len(block_array) == 4:
		print 'recognize_block_array'
		captcha = recognize_block_array(block_array, dir_train_pics)
	return captcha
Example #3
0
def upload_file():
    if request.method == 'POST':
        f = request.files['file']
        f.save("../audio" + secure_filename(f.filename))
        fileName = spliter.split(f.filename[:-4])
        global STEMS
        STEMS = request.form.get('stems')
        return redirect(url_for('down', title=fileName))
Example #4
0
def getLink(link=None):
    if request.method == 'POST':
        temp = 'succ'
        yt = YouTube(request.form['link'])
        yt.streams.filter(only_audio=True).first().download()
        fileName = spliter.split(yt.title)
        global Thumb
        Thumb = yt.thumbnail_url
    else:
        temp = None
    return redirect(url_for('down', title=fileName))
Example #5
0
def getLink(link=None):
    if request.method == 'POST':
        temp = 'succ'
        yt = YouTube(request.form['link'])
        yt.streams.filter(only_audio=True).first().download("../audio")
        global THUMB
        THUMB = yt.thumbnail_url
        global STEMS
        STEMS = request.form.get('stems')
        fileName = spliter.split(yt.title, STEMS)
    else:
        temp = None
    return redirect(url_for('down', title=fileName))
Example #6
0
def tokenize(pouet, print_function=False):
    return mark_indentation(inner_group(space_group(_tokenize(group(split(pouet)), print_function))))
Example #7
0
	pic_step3 = 3

	for pic_ptr in xrange(deal_number):

		pic_ptr_str = str('%04d' % pic_ptr)
		image_path = dir_path_base + pic_ptr_str + '.jpg'

		pic = Image.open(image_path)
		pic_preprocessed = preprocessor.preprocess(pic)

		output_path = dir_path_step + str(pic_step1) + '/' + pic_ptr_str + '_' + str(pic_step1) + '.jpg'
		print output_path
		pic_preprocessed.save(output_path)

		block_array = []
		spliter.split(pic_preprocessed, block_array)
		for i in xrange(len(block_array)):
			output_path = dir_path_step + str(pic_step2) + '/' + pic_ptr_str + '_' + str(pic_step2) + '_' + str(i) + '.jpg'
			print output_path
			block_array[i].save(output_path)

	for pic_ptr in xrange(deal_number):

		pic_ptr_str = str('%04d' % pic_ptr)
		image_path = dir_path_base + pic_ptr_str + '.jpg'

		captcha = recognizer.recognize(image_path, dir_path_train)
		if captcha != "":
			pic = Image.open(image_path)
			output_path = dir_path_step + str(pic_step3) + '/' + pic_ptr_str + '_' + str(pic_step3) + '_' + captcha + '.jpg'
			pic.save(output_path)
Example #8
0
def upload_file():
    if request.method == 'POST':
        f = request.files['file']
        f.save(secure_filename(f.filename))
        fileName = spliter.split(f.filename)
        return redirect(url_for('down', title=fileName))