def _get_contact_from_aipocr(self, image): try: from aip import AipOcr except ImportError: _logger.error( _('Odoo module e2yun_cards_ocr depends on the baidu-aip python module.' )) raise UserError( _('Odoo module e2yun_cards_ocr depends on the baidu-aip python module.' )) result = {} if AipOcr: APP_ID = self.env['ir.config_parameter'].sudo().get_param( 'baidu_ocr_app_id', '16224769') API_KEY = self.env['ir.config_parameter'].sudo().get_param( 'baidu_ocr_app_key', 'FFG6BEOxGDnK7Dynslzfxpl1') SECRET_KEY = self.env['ir.config_parameter'].sudo().get_param( 'baidu_ocr_secret_key', '0vYlPKcUEqMA0kerjhRoQNWU0uiBCoTF') options = {} options["detect_direction"] = self.env['ir.config_parameter'].sudo( ).get_param('baidu_detect_direction', "true") options["probability"] = self.env['ir.config_parameter'].sudo( ).get_param('baidu_probability', "true") options["detect_language"] = self.env['ir.config_parameter'].sudo( ).get_param('baidu_detect_language', "true") options["language_type"] = self.env['ir.config_parameter'].sudo( ).get_param('baidu_language_type', "CHN_ENG") client = AipOcr(APP_ID, API_KEY, SECRET_KEY) result = client.businessCard(image, options) result2 = client.basicAccurate(image, options) return result, result2
def _get_contact_from_aipocr(self, image): contact = {} if AipOcr: APP_ID = self.env['ir.config_parameter'].sudo().get_param( 'baidu_app_id', '16224769') API_KEY = self.env['ir.config_parameter'].sudo().get_param( 'baidu_app_key', 'FFG6BEOxGDnK7Dynslzfxpl1') SECRET_KEY = self.env['ir.config_parameter'].sudo().get_param( 'baidu_secret_key', '0vYlPKcUEqMA0kerjhRoQNWU0uiBCoTF') options = {} options["detect_direction"] = self.env['ir.config_parameter'].sudo( ).get_param('baidu_detect_direction', "true") options["probability"] = self.env['ir.config_parameter'].sudo( ).get_param('baidu_probability', "true") options["detect_language"] = self.env['ir.config_parameter'].sudo( ).get_param('baidu_detect_language', "true") options["language_type"] = self.env['ir.config_parameter'].sudo( ).get_param('baidu_language_type', "CHN_ENG") client = AipOcr(APP_ID, API_KEY, SECRET_KEY) result = client.businessCard(image, options) return result