Android 识别车牌信息

打开我们心爱的Android Studio

导入需要的资源

gradle

java 复制代码
//开源车牌识别安卓SDK库
    implementation("com.github.HyperInspire:hyperlpr3-android-sdk:1.0.3")
java 复制代码
button.setOnClickListener(v -> {
            Log.d("Test", "");
            try (InputStream file = getAssets().open("lp1.jpg")) {
                Bitmap lpImg = BitmapFactory.decodeStream(file);
                Bitmap showImg = null;

                if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
                    showImg = Bitmap.createBitmap(lpImg.getWidth(), lpImg.getHeight(), Bitmap.Config.RGB_565, false);
                }

                if (showImg != null) {

                    canvas.setBitmap(showImg);
//                绘制画笔
                    Paint paint = new Paint();
                    paint.setStrokeWidth(2);//设置画笔宽为2
                    paint.setARGB(255, 255, 0, 0);
                    paint.setStyle(Paint.Style.STROKE);
//                绘制画笔到画布上
                    canvas.drawBitmap(lpImg, 0, 0, new Paint());
                    Plate[] plates = HyperLPR3.getInstance().plateRecognition(lpImg, HyperLPR3.CAMERA_ROTATION_0, HyperLPR3.STREAM_BGRA);
//                    自定义字符串内容
                    StringBuilder builder = new StringBuilder();
                    for (int i = 0; i < plates.length; i++) {
                        Plate plate = plates[i];

                        canvas.drawRect(plate.getX1(), plate.getY1(), plate.getX2(), plate.getY2(), paint);

                        builder.append('第').append(i+1).append("车牌").append("\n");
                     builder.append("车牌内容").append(plate.getCode()).append("\n");
                    }
                    img.setImageBitmap(showImg);
                    text.setText(builder.toString());
                }
            } catch (IOException e) {
                Toast.makeText(this, "图像加载失败了", Toast.LENGTH_SHORT).show();
            }
        });
相关推荐
麻辣璐璐1 天前
EditText属性运用之适配RTL语言和LTR语言的输入习惯
android·xml·java·开发语言·安卓
北京自在科技1 天前
谷歌 Find Hub 网页端全面升级:电脑可直接管理追踪器与耳机
android·ios·安卓·findmy
ROLL.73 天前
Git和Repo
java·git·安卓
lI-_-Il4 天前
OpenClaw Termux:手机端一键部署 OpenClaw,把大模型装进口袋
人工智能·安卓
千里马学框架4 天前
Ubuntu 24 搭建aosp源码环境详细笔记
android·linux·ubuntu·framework·安卓·aosp·源码环境
SY.ZHOU5 天前
移动端架构体系(五):终篇总结
flutter·ios·系统架构·安卓·鸿蒙
Lsk_Smion6 天前
Sability安卓(三)_基础开发知识扫盲,开学XML......
android·java·android studio·安卓
weixin_408099677 天前
【实战教程】EasyClick 调用 OCR 文字识别 API(自动识别屏幕文字 + 完整示例代码)
前端·人工智能·后端·ocr·api·安卓·easyclick
SY.ZHOU8 天前
移动端架构体系(四):View层的组织与调用方案
flutter·ios·架构·系统架构·安卓
深念Y9 天前
魔百和CM201-YS救砖记 此型号emmc混发且易老化
安卓·电子·emmc·电视·维修·机顶盒·智能机顶盒