同步操作将从 hsj-xiaokang/SmartCropper 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
简单易用的智能图片裁剪库,适用于身份证,名片,文档等照片的裁剪。 如果觉得还不错,欢迎 star,fork。
你也可以关注我的另一个库 SmartCamera: SmartCamera 是一个 Android 相机拓展库,能够实时采集并且识别相机内物体边框是否吻合指定区域。
使用机器学习算法代理 Canny 算法,提高识别率(基于 TensorFlow 的 HED 网络). 感谢:https://github.com/fengjian0106/hed-tutorial-for-document-scanning
aaptOptions {
noCompress "tflite"
noCompress "lite"
}
SmartCropper.buildImageDetector(this);
1.根目录下的 build.gradle 添加:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
2.添加依赖
dependencies {
compile 'com.github.pqpo:SmartCropper:v2.1.3'
}
注意:由于使用了 JNI, 请不要混淆
-keep class me.pqpo.smartcropperlib.**{*;}
<me.pqpo.smartcropperlib.view.CropImageView
android:id="@+id/iv_crop"
android:layout_width="match_parent"
android:layout_height="match_parent" />
注意: CropImageView 继承至 ImageView,但是 ScaleType 必须为居中类型,如果手动设置成 fit_end,fit_start,matrix 将会报错。
ivCrop.setImageToCrop(selectedBitmap);
该方法内部会使用 native 代码智能识别边框,并绘制图片与选区。在 native 层实现,大大的提高了运行效率,运行时间与图片大小成正比,在大图片的情况下,可以考虑在子线程执行,或者压缩传入的图片。
Bitmap crop = ivCrop.crop();
根据选区裁剪出选区内的图片,并使用透视变换矫正成正面图片。
注意:改方法主要逻辑也是位于 native 层,运行时间与图片大小成正比,在大图片的情况下,可以考虑在子线程执行,或者压缩传入的图片。
name | format | description |
---|---|---|
civMaskAlpha | integer | 选区外蒙版的透明度,取值范围 0-255 |
civShowGuideLine | boolean | 是否显示辅助线,默认 true |
civLineColor | color | 选区线的颜色 |
civLineWidth | dimension | 选区线的宽度 |
civShowMagnifier | boolean | 在拖动的时候是否显示放大镜,默认 true |
civMagnifierCrossColor | color | 放大镜十字准心的颜色 |
civGuideLineWidth | dimension | 辅助线宽度 |
civGuideLineColor | color | 辅助线颜色 |
civPointFillColor | color | 锚点内部区域填充颜色 |
civPointFillAlpha | integer | 锚点内部区域填充颜色透明度 |
Copyright 2017 pqpo
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。