示例#1
0
def recognizeFile(filePath, resultFilePath, language, outputFormat):
    processor = AbbyyOnlineSdk()

    if "ABBYY_APPID" in os.environ:
        processor.ApplicationId = os.environ["ABBYY_APPID"]

    if "ABBYY_PWD" in os.environ:
        processor.Password = os.environ["ABBYY_PWD"]

    # Proxy settings
    if "http_proxy" in os.environ:
        proxyString = os.environ["http_proxy"]
        print "Using proxy at %s" % proxyString
        processor.Proxy = urllib2.ProxyHandler({"http": proxyString})

    print "Uploading.."
    settings = ProcessingSettings()
    settings.Language = language
    settings.OutputFormat = outputFormat
    task = processor.ProcessImage(filePath, settings)
    if task == None:
        print "Error"
        return
    print "Id = %s" % task.Id
    print "Status = %s" % task.Status

    # Wait for the task to be completed
    sys.stdout.write("Waiting..")
    # Note: it's recommended that your application waits at least 2 seconds
    # before making the first getTaskStatus request and also between such requests
    # for the same task. Making requests more often will not improve your
    # application performance.
    # Note: if your application queues several files and waits for them
    # it's recommended that you use listFinishedTasks instead (which is described
    # at http://ocrsdk.com/documentation/apireference/listFinishedTasks/).

    while task.IsActive() == True:
        time.sleep(5)
        sys.stdout.write(".")
        task = processor.GetTaskStatus(task)

    print "Status = %s" % task.Status

    if task.Status == "Completed":
        if task.DownloadUrl != None:
            processor.DownloadResult(task, resultFilePath)
            print "Result was written to %s" % resultFilePath
    else:
        print "Error processing task"
示例#2
0
import os
import re
import sys
import time
import urllib2
import urllib

from AbbyyOnlineSdk import *


processor = AbbyyOnlineSdk()

# if "ABBYY_APPID" in os.environ:
# 	processor.ApplicationId = os.environ["ABBYY_APPID"]
	
processor.ApplicationId = "frameConverter"

# if "ABBYY_PWD" in os.environ:
# 	processor.Password = os.environ["ABBYY_PWD"]
	
processor.Password = "******"

# Proxy settings
if "http_proxy" in os.environ:
	proxyString = os.environ["http_proxy"]
	print "Using proxy at %s" % proxyString
	processor.Proxy = urllib2.ProxyHandler( { "http" : proxyString })


# Recognize a file at filePath and save result to resultFilePath
def recognizeFile( filePath, resultFilePath, language, outputFormat ):
示例#3
0
import base64
import getopt
import MultipartPostHandler
import os
import re
import sys
import time
import urllib2
import urllib

from AbbyyOnlineSdk import *

processor = AbbyyOnlineSdk()

#if "ABBYY_APPID" in os.environ:
processor.ApplicationId = 'Email Signature Finder and Parser'  #os.environ["ABBYY_APPID"]

#if "ABBYY_PWD" in os.environ:
processor.Password = '******'  #os.environ["ABBYY_PWD"]

# Proxy settings
if "http_proxy" in os.environ:
    proxyString = os.environ["http_proxy"]
    print "Using proxy at %s" % proxyString
    processor.Proxy = urllib2.ProxyHandler({"http": proxyString})


# Recognize a file at filePath and save result to resultFilePath
def recognizeFile(filePath, resultFilePath, language, outputFormat):
    print "Uploading.."
    settings = ProcessingSettings()
示例#4
0
import getopt
import MultipartPostHandler
import os
import re
import sys
import time
import urllib2
import urllib

from AbbyyOnlineSdk import *


processor = AbbyyOnlineSdk()

if "ABBYY_APPID" in os.environ:
	processor.ApplicationId = os.environ["ABBYY_APPID"]

if "ABBYY_PWD" in os.environ:
	processor.Password = os.environ["ABBYY_PWD"]

# Proxy settings
if "http_proxy" in os.environ:
	proxyString = os.environ["http_proxy"]
	print "Using proxy at %s" % proxyString
	processor.Proxy = urllib2.ProxyHandler( { "http" : proxyString })


# Recognize a file at filePath and save result to resultFilePath
def recognizeFile( filePath, resultFilePath, language, outputFormat ):
	print "Uploading.."
	settings = ProcessingSettings()
示例#5
0
import MultipartPostHandler
import os
import re
import sys
import time
import urllib2
import urllib

from AbbyyOnlineSdk import *

processor = AbbyyOnlineSdk()

# if "ABBYY_APPID" in os.environ:
# 	processor.ApplicationId = os.environ["ABBYY_APPID"]

processor.ApplicationId = "frameConverter"

# if "ABBYY_PWD" in os.environ:
# 	processor.Password = os.environ["ABBYY_PWD"]

processor.Password = "******"

# Proxy settings
if "http_proxy" in os.environ:
    proxyString = os.environ["http_proxy"]
    print "Using proxy at %s" % proxyString
    processor.Proxy = urllib2.ProxyHandler({"http": proxyString})


# Recognize a file at filePath and save result to resultFilePath
def recognizeFile(filePath, resultFilePath, language, outputFormat):
示例#6
0
import base64
import getopt
import MultipartPostHandler
import os
import re
import sys
import time
import urllib2
import urllib

from AbbyyOnlineSdk import *

processor = AbbyyOnlineSdk()

if "ABBYY_APPID" in os.environ:
    processor.ApplicationId = os.environ["ABBYY_APPID"]

if "ABBYY_PWD" in os.environ:
    processor.Password = os.environ["ABBYY_PWD"]

# Proxy settings
if "http_proxy" in os.environ:
    proxyString = os.environ["http_proxy"]
    print "Using proxy at %s" % proxyString
    processor.Proxy = urllib2.ProxyHandler({"http": proxyString})


# Recognize a file at filePath and save result to resultFilePath
def recognizeFile(filePath, resultFilePath, language, outputFormat):
    print "Uploading.."
    settings = ProcessingSettings()
示例#7
0
import getopt
import MultipartPostHandler
import os
import re
import sys
import time
import urllib2
import urllib

from AbbyyOnlineSdk import *


processor = AbbyyOnlineSdk()

#if "ABBYY_APPID" in os.environ:
processor.ApplicationId = 'Email Signature Finder and Parser'#os.environ["ABBYY_APPID"]

#if "ABBYY_PWD" in os.environ:
processor.Password = '******'#os.environ["ABBYY_PWD"]

# Proxy settings
if "http_proxy" in os.environ:
	proxyString = os.environ["http_proxy"]
	print "Using proxy at %s" % proxyString
	processor.Proxy = urllib2.ProxyHandler( { "http" : proxyString })


# Recognize a file at filePath and save result to resultFilePath
def recognizeFile( filePath, resultFilePath, language, outputFormat ):
	print "Uploading.."
	settings = ProcessingSettings()
示例#8
0
#!/usr/bin/python
import os
import sys
import json
from lxml import etree
import dateutil.parser
from AbbyyOnlineSdk import *  

def getconfig(cfg):
    return [x.strip() for x in open((os.path.dirname(__file__) or ".")+"/config.txt") if x.startswith(cfg)][0].split("=")[1]

processor = AbbyyOnlineSdk()
processor.ApplicationId = os.getenv("ABBYY_APPID") or getconfig("ABBYY_APPID")
processor.Password = os.getenv("ABBYY_PWD") or getconfig("ABBYY_PWD")

class OCR:
    def __init__(self, imageid):
        self.runocr(imageid)
        self.lines = self.process(etree.parse(open(imageid + ".xml")).getroot())

    def runocr(self, imageid):
        if os.path.exists(imageid + ".xml"):
            return
	settings = ProcessingSettings()
	settings.Language = "English"
	settings.OutputFormat = "xml"
	settings.ImageSource = "photo"
	settings.profile = "textExtraction"
	task = processor.ProcessImage(imageid+".jpg", settings)
	if task == None:
		return
示例#9
0
文件: OCR.py 项目: armant/babeml
import argparse
import base64
import getopt
import MultipartPostHandler
import os
import re
import sys
import time
import urllib2
import urllib

from AbbyyOnlineSdk import *


processor = AbbyyOnlineSdk()
processor.ApplicationId = 'babe(m)l'
processor.Password = '******'

#if "ABBYY_APPID" in os.environ:
#	processor.ApplicationId = os.environ["ABBYY_APPID"]

#if "ABBYY_PWD" in os.environ:
#	processor.Password = os.environ["ABBYY_PWD"]

# Proxy settings
if "http_proxy" in os.environ:
	proxyString = os.environ["http_proxy"]
	print "Using proxy at %s" % proxyString
	processor.Proxy = urllib2.ProxyHandler( { "http" : proxyString })

示例#10
0
import base64
import getopt
import MultipartPostHandler
import os
import re
import sys
import time
import urllib2
import urllib

from AbbyyOnlineSdk import *

processor = AbbyyOnlineSdk()

if "ReasegurosOCR" in os.environ:
    processor.ApplicationId = os.environ["ReasegurosOCR"]

if "Lzkn0dpJqrLHTUV7besocZ0z" in os.environ:
    processor.Password = os.environ["Lzkn0dpJqrLHTUV7besocZ0z"]

# Proxy settings
if "http_proxy" in os.environ:
    proxyString = os.environ["http_proxy"]
    print "Using proxy at %s" % proxyString
    processor.Proxy = urllib2.ProxyHandler({"http": proxyString})


# Recognize a file at filePath and save result to resultFilePath
def recognizeFile(filePath, resultFilePath, language, outputFormat):
    print "Uploading.."
    settings = ProcessingSettings()