Esempio n. 1
0
def processCamUploadImage(b64_Filedata):

    # Convert base64Image to openCV Image
    openCVImage = convrt.base64_to_openCVImage(b64_Filedata)

    # # Enhance Passport Image improve Ocr Results
    # openCVImage = cv2.cvtColor(openCVImage, cv2.COLOR_BGR2GRAY)

    croppedImage, preProcessAlerts = preProcessROICrop(openCVImage)

    # Run OCR Text Extraction
    # Format extracted data
    if croppedImage is not None:
        croppedImageGray = preProcessImageEnhance(croppedImage)
        extractedData, textExtractionAlerts = getVisaTextExtraction(croppedImageGray)
    else:
        openCVImageGray = preProcessImageEnhance(openCVImage)
        extractedData, textExtractionAlerts = getVisaTextExtraction(openCVImageGray)

    alertMessages = preProcessAlerts + textExtractionAlerts

    if len(alertMessages)>0:
        alertMessages.sort()
        responseError = getResponseError(alertMessages[0])
    else:
        responseError = None

    return extractedData, responseError
def processCamUploadImage(b64_Filedata, pp_data):

    # Convert base64Image to openCV Image
    openCVImage = convrt.base64_to_openCVImage(b64_Filedata)

    # Enhance STL Image improve Ocr Results
    openCVImage = cv2.cvtColor(openCVImage, cv2.COLOR_BGR2GRAY)

    # Extract name from the passport
    try:
        matchName = pp_data[json_names.__PP_NAME__]
    except:
        matchName = None

    # Format extracted data
    extractedData, alertMessages = extract_information.extract_info_stl(
        openCVImage, matchName)

    if len(alertMessages) > 0:
        alertMessages.sort()
        responseError = getResponseError(alertMessages[0])
    else:
        responseError = None

    return extractedData, responseError
def processCamUploadImage(b64_Filedata):

    # Convert base64Image to openCV Image
    openCVImage = convrt.base64_to_openCVImage(b64_Filedata)

    # Enhance Passport Image improve Ocr Results
    # openCVImage = cv2.cvtColor(openCVImage, cv2.COLOR_BGR2GRAY)

    # Run passport eye to extract details and
    mrz = preprocessCamUpload(openCVImage)

    # Format extracted data
    extractedData, alertMessages = formatPassportEyeData(mrz)

    if len(alertMessages) > 0:
        alertMessages.sort()
        responseError = getResponseError(alertMessages[0])
    else:
        responseError = None

    return extractedData, responseError