Skip to content

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

Notifications You must be signed in to change notification settings

phinm91/SmartCropper

 
 

Repository files navigation

SmartCropper

English | 中文

A library for cropping image in a smart way that can identify the border and correct the cropped image. Applicable to ID cards, business cards, documents and other photos of the crop. If you like, welcome star, fork or follow me.

You can also follow my other library SmartCamera: SmartCamera is an Android camera extension library,provides a scanning module that can recognizes whether the object's border inside the camera matches the area in real time.

Features

  • Crop image in a smart way that can identify the border.
  • Support drag anchors, magnifying glass effect to enhance the positioning experience.
  • Use the perspective transform to crop and correct the selection to restore the front image.
  • Support rich UI settings, such as auxiliary lines, mask, anchor, magnifying glass and so on.

Sample(link

1. Select a image, use the perspective transform to crop and correct the selection:

2. drag anchors, magnifying glass effect to enhance the positioning experience:

gif:

Import

if version >= v1.2.4:

aar download: https://github.com/pqpo/SmartCropper/releases

else:

Step 1. Add it in your root build.gradle at the end of repositories:

	allprojects {
		repositories {
			...
			maven { url 'https://jitpack.io' }
		}
	}

Step 2. Add the dependency

	dependencies {
	        compile 'com.github.pqpo:SmartCropper:v2.1.3'
	}

note:

-keep class me.pqpo.smartcropperlib.**{*;}

Usage

1. Use CropImageView in your xml file.

<me.pqpo.smartcropperlib.view.CropImageView   
        android:id="@+id/iv_crop"  
        android:layout_width="match_parent" 
        android:layout_height="match_parent" />  

note: CropImageView extends from ImageView,and ScaleType must be center type,If you set ScaleType to fit_end,fit_start,matrix will throws an error。

2. Set image to crop:

ivCrop.setImageToCrop(selectedBitmap); 

It will identify the border by native(c/c++), and show Image.

3. Crop the image:

Bitmap crop = ivCrop.crop();

Optimization of intelligent selection algorithm:

Tensorflow HED Net instant of Canny:

  1. build.gradle :
aaptOptions {
    noCompress "tflite"
    noCompress "lite"
}
  1. Application.onCreate:
SmartCropper.buildImageDetector(this);

Features

  • Optimization point sorting algorithm
  • CropImageView selection magnifying effect
  • CropImageView xml settings
  • Optimization of intelligent selection algorithm
  • Please submit ISSUEs

Author:

License

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.

About

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

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Java 99.0%
  • Other 1.0%