Created
December 23, 2016 06:10
-
-
Save KarthiAru/2253b5f4ff1ae669a5ca925fa7ff20e3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(httr) | |
key <- '[your apikey]' | |
img_url <- '[your image url]' | |
# Submit an OCR job | |
request <- POST(url='https://api.havenondemand.com/1/api/async/ocrdocument/v1', | |
body = list(apikey = key, | |
url = img_url, | |
mode = 'document_photo')) | |
# Get the Job ID of the above request | |
job_id <- content(request)$jobID | |
# Use the Job ID for retrieval | |
result <- POST(url=paste0('https://api.havenondemand.com','/1/job/result/',job_id), | |
body=list(apikey = key)) | |
# Check status | |
status <- content(result)$status | |
# Merge the text result | |
ocr_text <- unlist(content(result)$actions[[1]]$result$text_block) | |
ocr_text <- paste(stri_replace_all(ocr_text, regex = '\n|\r', replacement = ' '), sep = ' ', collapse = ' ') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment