pqpo / SmartCropper

🔥 A library for cropping image in a smart way that can identify the border and correct the cropped image. 智能图片裁剪框架。自动识别边框,手动调节选区,使用透视变换裁剪并矫正选区;适用于身份证,名片,文档等照片的裁剪。

Home Page:https://pqpo.me/2017/09/11/opencv-border-recognition/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CropImageView设置setImageBitmap后并没有出现剪裁区域

Theoneee opened this issue · comments

引入:

implementation 'com.github.pqpo:SmartCropper:v2.1.4'

配置

   aaptOptions {
        noCompress "tflite"
        noCompress "lite"
    }

初始化

SmartCropper.buildImageDetector(this)

布局

       <me.pqpo.smartcropperlib.view.CropImageView
            android:id="@+id/iv_crop"
            app:civShowEdgeMidPoint="true"
            android:background="@color/qmui_config_color_pure_black"
            app:civLineColor="?attr/app_skin_primary_color"
            app:civMagnifierCrossColor="@color/qmui_config_color_red"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />

设置Bitmap

    private fun setCropBitmap(path:String){
        getDataBinding().ivCrop.visible()
        lifecycleScope.launch {
            val bitmap =   withContext(Dispatchers.IO){
                val options = BitmapFactory.Options()
                options.inJustDecodeBounds = true
                BitmapFactory.decodeFile(path, options)
                options.inJustDecodeBounds = false
                options.inSampleSize = calculateSampleSize(options)
                BitmapFactory.decodeFile(path, options)
            }
            withContext(Dispatchers.Main){
                getDataBinding().ivCrop.setImageBitmap(bitmap)
            }
        }
    }

S20524-09164069

Demo显示正常

S20524-09174247

APK里也是有so库的
image