def route(): #在注册前需要访问route.php,以防直接访问注册页面地址失效 print("——————————访问主界面——————————") res = requests.get(url=init_link,headers=header,proxies={"https": "{}://127.0.0.1:{}".format(init.proxy_rules,init.tor_sockets_port),"http":"{}://127.0.0.1:{}".format(init.proxy_rules,init.tor_sockets_port)}) temp = 0 while res.status_code!=200: print("[-] 加载注册页面失败,正在重新加载***") temp +=1 if temp == 5: print("[-] 网络也许有问题,请重新进行配置") break res = requests.get(url=final_link,headers=header,proxies={"https": "{}://127.0.0.1:{}".format(init.proxy_rules,init.tor_sockets_port),"http":"{}://127.0.0.1:{}".format(init.proxy_rules,init.tor_sockets_port)}) soup = BeautifulSoup(res.content,'html.parser') img = soup.findAll('img',attrs={'title':'只能刷新页面换验证码, 为安全因素去除了js代码, 无法点此刷新'}) for i in img: pass #print(i.get('src')) picture_link = i.get('src') #验证码地址 picture_local_link = save_picture(picture_link) text1 = ocr.main(picture_local_link)=='' ? '':ocr.main(picture_local_link) text2 = Identify(picture_local_link)=='' '':Identify(picture_local_link) route_header = {'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9', 'Accept-Encoding': 'gzip, deflate', 'Accept-Language': 'zh-CN,zh;q=0.9,zh-TW;q=0.8,en;q=0.7', 'Cache-Control': 'max-age=0', 'Connection': 'keep-alive', 'Content-Length': '65', 'Content-Type': 'application/x-www-form-urlencoded', 'Cookie': 'PHPSESSID=v6uplodl8gp57qst14idjjvo6f; random=1042', 'Host': 'deepmix2z2ayzi46.onion', 'Origin': 'http://deepmix2z2ayzi46.onion', 'Referer': 'http://deepmix2z2ayzi46.onion/index.php', 'Upgrade-Insecure-Requests': '1', 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36'} print(text1,text2)
def upload_file(): start_time = time.time() if 'image' not in request.files: finish_time = time.time() - start_time json_content = { 'message': "image is empty", 'time_elapsed': str(round(finish_time, 3)) } else: imagefile = request.files['image'].read() npimg = np.frombuffer(imagefile, np.uint8) image = cv2.imdecode(npimg, cv2.IMREAD_COLOR) # Note: Uncomment for YOLO feature # image = yolo_detect.main(image) nik, nama, tempat_lahir, tgl_lahir = ocr.main(image) finish_time = time.time() - start_time json_content = { 'nik': str(nik), 'nama': str(nama), 'tempat_lahir': str(tempat_lahir), 'tgl_lahir': str(tgl_lahir), 'time_elapsed': str(round(finish_time, 3)) } python2json = json.dumps(json_content) return app.response_class(python2json, content_type='application/json')
def main(): if request.method == 'POST': file = request.files['file'] if file: path = os.path.join(tempfile.gettempdir(), file.filename) file.save(path) return Response(ocr.main(path), mimetype='text/plain') return '''
import getframe import ocr video = '2' # getframe.main(video) ocr.main(video)
def main(): method = sys.argv[1] input = sys.argv[2] id = sys.argv[3] home = os.path.expanduser('~')+'\\.IF5181\\' dir = home+id+'\\' if not os.path.isdir(dir): if os.path.isdir(home): shutil.rmtree(home, ignore_errors=True) if not os.path.isdir(home): os.mkdir(home) os.mkdir(dir) os.chdir('py') if method == 'histogram': img = gambar.read(input) hist = gambar.get_histogram(img) json_save({ 'r': list(gambar.get_histogram(img[:, :, 0])), 'g': list(gambar.get_histogram(img[:, :, 1])), 'b': list(gambar.get_histogram(img[:, :, 2])), }, dir+'histogram.json') elif method == 'equalize': img = gambar.read(input) gray = gambar.to_gray(img) hist_gray = gambar.get_histogram(gray) result, hist_result = gambar.equalize(gray, hist_gray) gambar.save(gray, dir+'gray.jpg') json_save(list(hist_gray), dir+'histogram_gray.json') gambar.save(result, dir+'equalized.jpg') json_save(list(hist_result), dir+'histogram_equalized.json') elif method == 'otsu': img = gambar.read(input) gray = gambar.to_gray(img) gambar.save(gray, dir+'gray.jpg') bw = gambar.to_bw(gray) gambar.save(bw, dir+'binary.jpg') elif method == 'derajat0': img = gambar.read(input) gray = gambar.to_gray(img) gambar.save(gray, dir+'gray.jpg') average = konvolusi.derajat0(gray, 'average') gambar.save(average, dir+'derajat0-average.jpg') homogen = konvolusi.derajat0(gray, 'homogen') gambar.save(homogen, dir+'derajat0-homogen.jpg') difference = konvolusi.derajat0(gray, 'difference') gambar.save(difference, dir+'derajat0-difference.jpg') elif method == 'derajat1': img = gambar.read(input) gray = gambar.to_gray(img) gambar.save(gray, dir+'gray.jpg') sobel = konvolusi.derajat1(gray, 'sobel') gambar.save(sobel, dir+'derajat1-sobel.jpg') prewitt = konvolusi.derajat1(gray, 'prewitt') gambar.save(prewitt, dir+'derajat1-prewitt.jpg') elif method == 'derajat2': img = gambar.read(input) gray = gambar.to_gray(img) gambar.save(gray, dir+'gray.jpg') kirsch = konvolusi.derajat2(gray, 'kirsch') gambar.save(kirsch, dir+'derajat2-kirsch.jpg') prewitt = konvolusi.derajat2(gray, 'prewitt') gambar.save(prewitt, dir+'derajat2-prewitt.jpg') elif method == 'gauss': img = gambar.read(input) gambar.save(konvolusi.gaussian(img), dir+'gauss.jpg') elif method == 'chaincode': img = gambar.read(input) gray = gambar.to_gray(img) bw = gambar.to_bw(gray) gambar.save(bw, dir+'binary.jpg') kopong = gambar.koponging(bw) gambar.save(kopong, dir+'kopong.jpg') code = chaincode.get_chaincode(kopong) belok = chaincode.get_kodebelok(code) json_save(code, dir+'chaincode.json') json_save(belok, dir+'kodebelok.json') elif method == 'skeleton': img = gambar.read(input) gray = gambar.to_gray(img) bw = gambar.to_bw(gray) gambar.save(bw, dir+'binary.jpg') tulang = zhangsuen.penulangan(bw) gambar.save(tulang, dir+'tulang.jpg') ujung, simpangan = zhangsuen.get_identity(tulang) json_save({ 'ujung': [[int(y), int(x)] for y, x in ujung], 'simpangan': [[int(y), int(x)] for y, x in simpangan], }, dir+'tulang-identity.json') code = zhangsuen.get_chaincode(tulang) belok = chaincode.get_kodebelok(code) json_save(code, dir+'tulang-chaincode.json') json_save(belok, dir+'tulang-kodebelok.json') elif method == 'ocr': result = ocr.main(input) json_save({ 'result': result }, dir+'ocr-result.json') elif method == 'face-warna': img = gambar.read(input) masker = wajah.get_masker(img) maskered = wajah.draw_masker(img, masker) gambar.save(maskered, dir+'face-masker.jpg') wajahs = wajah.get_wajahs(masker) kotaked = wajah.draw_kotak(img, wajahs) gambar.save(kotaked, dir+'face-kotak.jpg') elif method == 'face-bentuk': img = gambar.read(input) wajah.limatitik(img) wajah.titikobjek(img) elif method == 'face-recognition': facer.main(input)
def main(pdf_path, result_dir): ocr.main(pdf_path, result_dir + '/raw') df = parsing.parse_directory(result_dir + '/raw') df.to_csv(result_dir + '/result.csv')