flutter_tencent_ocr 0.1.2 copy "flutter_tencent_ocr: ^0.1.2" to clipboard
flutter_tencent_ocr: ^0.1.2 copied to clipboard

Flutter plugin for tencent ocr,supports identification of ID cards, bank cards, business licenses, etc..

flutter_tencent_ocr #

身份证识别 #

  Future idCardOCR() async {
    final ByteData imageBytes =
        await rootBundle.load('assets/images/image6.png');

    FlutterTencentOcr.iDCardOCR(
      SecretId,
      SecretKey,
      IDCardOCRRequest.fromParams(
          config: IDCardOCRConfig.fromParams(reshootWarn: true),
          imageBase64: base64Encode(imageBytes.buffer.asUint8List())),
    ).then((onValue) {
      setState(() {
        _message = onValue.toString();
      });
    }).catchError(
      (error) {
        setState(() {
          _message = error;
        });
      },
    );
  }

银行卡识别 #

  Future bankOCR() async {
    final ByteData imageBytes =
        await rootBundle.load('assets/images/bank.jpeg');

    FlutterTencentOcr.bankCardOCR(
      SecretId,
      SecretKey,
      GeneralOCRRequest.fromParams(
          imageBase64: base64Encode(imageBytes.buffer.asUint8List())),
    ).then((onValue) {
      setState(() {
        _message = onValue.toString();
      });
    }).catchError(
      (error) {
        setState(() {
          _message = error;
        });
      },
    );
  }

营业执照 #

  Future bizLicenseOCR() async {
    final ByteData imageBytes = await rootBundle.load('assets/images/biz.png');

    FlutterTencentOcr.bizLicenseOCR(
      SecretId,
      SecretKey,
      GeneralOCRRequest.fromParams(
          imageBase64: base64Encode(imageBytes.buffer.asUint8List())),
    ).then((onValue) {
      setState(() {
        _message = onValue.toString();
      });
    }).catchError(
      (error) {
        setState(() {
          _message = error;
        });
      },
    );
  }

统一调用的方法 #

  Future otherOCR() async {
    
    final ByteData imageBytes = await rootBundle.load('assets/images/biz.png');

    Map map = {"ImageBase64": base64Encode(imageBytes.buffer.asUint8List())};

    FlutterTencentOcr.ocrRequest(
            SecretId, SecretKey, "BizLicenseOCR", jsonEncode(map))
        .then((onValue) {
      setState(() {
        _message = onValue.toString();
      });
    }).catchError(
      (error) {
        setState(() {
          _message = error;
        });
      },
    );
  }

运行examle #

在 main.dart 同级目录下新建文件: local_config.dart

/// 腾讯OCR生成的秘钥串
const String SecretId = "xxxxxx"; 
const String SecretKey = "xxxxxxx"; 

5
likes
30
points
24
downloads

Publisher

verified publishermrliuys.cn

Weekly Downloads

Flutter plugin for tencent ocr,supports identification of ID cards, bank cards, business licenses, etc..

Repository (GitHub)

License

unknown (license)

Dependencies

crypto, dio, flutter, hex

More

Packages that depend on flutter_tencent_ocr