code
stringlengths
3
6.57k
cv2.imdecode(nparr, cv2.IMREAD_COLOR)
cv2.putText()
enumerate(self.get_coords(page_index)
pts.append([int(pt['x'])
int(pt['y'])
print(pts)
cv2.polylines(image, [np.array(pts)
enumerate(region['regions'])
pts.append([int(pt['x'])
int(pt['y'])
cv2.polylines(image, [np.array(pts)
cv2.putText(image, str(line_index)
enumerate(line['regions'])
pts.append([int(pt['x'])
int(pt['y'])
cv2.polylines(image, [np.array(pts)
cv2.putText(image, str(word_index)
print(str(e)
print(region)
print(self.prefix)
os.path.join(self.save_dir , '{}_{}_{}.png'.format(self.prefix,self.regions,page_index)
cv2.imwrite(image_path , image)
google_ocr_v15(url,headers,pdf_name)
requests.post(url,json=file,headers=headers)
res.json()
upload_file(pdf_file,headers,url)
open(pdf_file,'rb')
requests.post(url, headers=headers, files=files)
response.json()
download_file(download_url,headers,outputfile,f_type='json')
str(outputfile)
requests.get(download_url,headers=headers)
res.json()
save_json(path,res)
open(path, "w", encoding='utf8')
json.dump(res, write_file,ensure_ascii=False )
bulk_search(job_id,bs_url,headers)
print(job_id)
requests.post(bs_url,json=bs_request,headers=headers, timeout = 10000)
print(res.json()
while(1)
res.json()
res.json()
print(in_progress)
sleep(0.5)
print(in_progress)
requests.post(bs_url,json=bs_request,headers=headers, timeout = 10000)
execute_module(module,url,input_file,module_code,pdf_dir,overwirte=True , draw=True)
os.path.join(pdf_dir,'{}.json'.format(module_code)
os.path.exists(output_path)
print(' loading *****************{}'.format(module_code )
open(output_path,'r')
json.load(wd_file)
format(module_code)
open(wf_res,'r')
json.load(wd_file)
upload_file(output_path,headers,upload_url)
upload_file(input_file,headers,upload_url)
print('upload response **********', res)
module(url,headers,pdf_name)
module(url,headers,input_file)
download_file(download_url,headers,json_file)
save_json(output_path,response)
print(' response *****************{} {}'.format(module_code ,response )
bulk_search(job_id,bs_url,headers)
save_json(pdf_dir + '/{}_wf.json'.format(module_code)
print('bulk search response **************',json_file )
download_file(download_url,headers,json_file)
save_json(output_path,response)
Draw(response,pdf_dir,regions='lines',prefix=module_code)
Draw(response,pdf_dir,regions='regions',prefix=module_code)
evaluate__and_save_input(pdf_files,output_dir,headers,word_url,layout_url,download_url,upload_url,bs_url)
pdf.split('/')
split('.')
print(pdf , ' is being processed')
os.path.join(output_dir,pdf_name)
os.system('mkdir -p "{}"'.format(pdf_output_dir)
execute_module(google_ocr_v15,word_url,input_file=pdf,module_code='gv',pdf_dir=pdf_output_dir,overwirte=False , draw=False)
main(path,headers,word_url,layout_url,download_url,upload_url,bs_url)
glob.glob(path + '/*.pdf')
evaluate__and_save_input(pdf_names,output_path,headers,word_url,layout_url,download_url,upload_url,bs_url)
main(path,headers,word_url,layout_url,download_url,upload_url,bs_url)
bound_coordinate(corrdinate,max)
int(corrdinate)
get_image_from_box(image, box, height=140)
np.sqrt((box[1, 1] - box[2, 1])
print("scale is ",scale)
int(np.sqrt((box[0, 0] - box[1, 0])
max(abs(box[0, 0] - box[1, 0])
abs(box[2, 0] - box[3, 0])
max(abs(box[0, 1] - box[3, 1])
abs(box[1, 1] - box[2, 1])
np.float32(box)
np.float32([[0, 0], [int(w)
int(w)
int(height)
int(height)
cv2.getPerspectiveTransform(pts1, pts2)
cv2.warpPerspective(image,M,(int(w)
int(height)