Skip to content

Commit a165130

Browse files
committed
Initial commit
0 parents  commit a165130

File tree

744 files changed

+305748
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

744 files changed

+305748
-0
lines changed

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
*.iml
2+
.gradle
3+
local.properties
4+
.idea
5+
.DS_Store
6+
build/
7+
app/build/
8+
app/.externalNativeBuild

README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
## 基于EasyPR的车牌识别android实现
2+
3+
EasyPR4Android,基于[EasyPR](https://github.com/liuruoze/EasyPR)1.6的android实现, 提供编译好的[mrcar.apk](https://github.com/imistyrain/EasyPR4Android/releases)安装运行demo.
4+
5+
### 效果图
6+
7+
特性:摄像头实时预览
8+
9+
![live](cameralive.png)
10+
11+
### 编译和运行:
12+
13+
环境: android studio3.5开发实现,ndk版本为R16b,OpenCV版本为3.2,android SDK版本为28,最低要求21。
14+
15+
* 1.下载并配置[android studio 3.5](http://www.android-studio.org/)
16+
17+
* 2.配置NDK16b[ndk r16b](http://blog.csdn.net/shuzfan/article/details/52690554)
18+
19+
* 3.编译并运行,也可以直接下载编译好的[apk](https://github.com/imistyrain/EasyPR4Android/releases)安装使用
20+
21+
本项目定义了三个Activity, 其中
22+
23+
* [PhotoActivity](app/src/main/java/yanyu/com/mrcar/PhotoActivity.java)是从图片和系统相机抓取图片进行识别
24+
25+
* [CVCameraActivity](app/src/main/java/yanyu/com/mrcar/CVCameraActivity.java)是用OpenCV的JavaCameraView实时识别,由于OpenCV实现的限制,其只能用于横屏,虽然也有trick能使其支持竖屏,但会有性能损失,为此产生了第三种
26+
27+
* [CameraActivity](app/src/main/java/yanyu/com/mrcar/CameraActivity.java)原始摄像头实时识别,抓取NV21数据送到jni中,并将其抓换成RGB数据进行处理,其支持竖屏识别。
28+
29+
### 参考:
30+
31+
* 1.[Native方式集成OpenCV](https://github.com/ShawnZhang31/opencv-android-studio)
32+
33+
* 2.[JNI两种注册过程实战](https://blog.csdn.net/xsf50717/article/details/54693802)
34+
35+
* 3.[Android Camera1 教程 · 第二章 · 预览](https://www.jianshu.com/p/705d4792e836)
36+
37+
* 4.[ios 端车牌识别](https://github.com/imistyrain/EasyPR-Swift)

app/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

app/CMakeLists.txt

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Sets the minimum version of CMake required to build the native
2+
# library. You should either keep the default value or only pass a
3+
# value of 3.4.0 or lower.
4+
5+
cmake_minimum_required(VERSION 3.4.1)
6+
7+
set(LIB_DIR ${CMAKE_CURRENT_LIST_DIR}/src/main/jniLibs/${ANDROID_ABI}/)
8+
9+
#add include dir
10+
include_directories(src/main/jni/include)
11+
include_directories(src/main/jni)
12+
13+
#add source files
14+
aux_source_directory(src/main/jni SOURCE_FILES)
15+
aux_source_directory(src/main/jni/src/core SOURCE_FILES_CORE)
16+
aux_source_directory(src/main/jni/src/train SOURCE_FILES_TRAIN)
17+
aux_source_directory(src/main/jni/src/util SOURCE_FILES_UTIL)
18+
aux_source_directory(src/main/jni/thirdparty/LBP SOURCE_FILES_LBP)
19+
aux_source_directory(src/main/jni/thirdparty/mser SOURCE_FILES_MSER)
20+
aux_source_directory(src/main/jni/thirdparty/svm SOURCE_FILES_SVM)
21+
aux_source_directory(src/main/jni/thirdparty/textDetect SOURCE_FILES_TEXTDETECT)
22+
aux_source_directory(src/main/jni/thirdparty/xmlParser SOURCE_FILES_XML)
23+
list(REMOVE_ITEM SOURCE_FILES main.cpp)
24+
list(APPEND SOURCE_FILES ${SOURCE_FILES_CORE})
25+
list(APPEND SOURCE_FILES ${SOURCE_FILES_SOURCE_FILES_SVM})
26+
list(APPEND SOURCE_FILES ${SOURCE_FILES_CORE})
27+
list(APPEND SOURCE_FILES ${SOURCE_FILES_TRAIN})
28+
list(APPEND SOURCE_FILES ${SOURCE_FILES_UTIL})
29+
list(APPEND SOURCE_FILES ${SOURCE_FILES_LBP})
30+
list(APPEND SOURCE_FILES ${SOURCE_FILES_MSER})
31+
list(APPEND SOURCE_FILES ${SOURCE_FILES_TEXTDETECT})
32+
list(APPEND SOURCE_FILES ${SOURCE_FILES_XML})
33+
list(APPEND SOURCE_FILES "src/main/jni/jni.cpp")
34+
35+
add_library(lib_opencv_java3 SHARED IMPORTED)
36+
add_library(lib_freetype STATIC IMPORTED)
37+
set_target_properties(lib_opencv_java3 PROPERTIES IMPORTED_LOCATION ${LIB_DIR}/libopencv_java3.so)
38+
set_target_properties(lib_freetype PROPERTIES IMPORTED_LOCATION ${LIB_DIR}/libfreetype2-static.a)
39+
add_library(mrcar SHARED ${SOURCE_FILES})
40+
41+
find_library(log-lib log)
42+
target_link_libraries(mrcar lib_opencv_java3 ${log-lib} lib_freetype)

app/build.gradle

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
apply plugin: 'com.android.application'
2+
3+
android {
4+
compileSdkVersion 28
5+
buildToolsVersion "28.0.3"
6+
defaultConfig {
7+
applicationId "yanyu.com.mrcar"
8+
minSdkVersion 21
9+
targetSdkVersion 28
10+
versionCode 1
11+
versionName "1.0"
12+
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13+
ndk{
14+
abiFilters 'arm64-v8a'//armeabi-v7a
15+
}
16+
externalNativeBuild {
17+
cmake {
18+
cppFlags "-std=c++11 -fexceptions"
19+
}
20+
}
21+
}
22+
buildTypes {
23+
release {
24+
minifyEnabled false
25+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
26+
}
27+
}
28+
29+
externalNativeBuild {
30+
cmake {
31+
path "CMakeLists.txt"
32+
}
33+
}
34+
}
35+
36+
dependencies {
37+
implementation fileTree(include: ['*.jar'], dir: 'libs')
38+
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
39+
exclude group: 'com.android.support', module: 'support-annotations'
40+
})
41+
implementation 'com.android.support:appcompat-v7:28.0.0'
42+
androidTestImplementation 'junit:junit:4.12'
43+
implementation project(path: ':openCVLibrary320')
44+
}

app/proguard-rules.pro

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Add project specific ProGuard rules here.
2+
# By default, the flags in this file are appended to flags specified
3+
# in D:\Java\adroidsdk/tools/proguard/proguard-android.txt
4+
# You can edit the include path and order by changing the proguardFiles
5+
# directive in build.gradle.
6+
#
7+
# For more details, see
8+
# http://developer.android.com/guide/developing/tools/proguard.html
9+
10+
# Add any project specific keep options here:
11+
12+
# If your project uses WebView with JS, uncomment the following
13+
# and specify the fully qualified class name to the JavaScript interface
14+
# class:
15+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16+
# public *;
17+
#}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package yanyu.com.mrcar;
2+
3+
import android.app.Application;
4+
import android.test.ApplicationTestCase;
5+
6+
/**
7+
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
8+
*/
9+
public class ApplicationTest extends ApplicationTestCase<Application> {
10+
public ApplicationTest() {
11+
super(Application.class);
12+
}
13+
}

app/src/main/AndroidManifest.xml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="yanyu.com.mrcar" >
4+
<uses-permission android:name="android.permission.CAMERA"/>
5+
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
6+
<uses-permission android:name="android.permission.VIBRATE"/>
7+
8+
<application
9+
android:allowBackup="true"
10+
android:icon="@mipmap/ic_launcher"
11+
android:label="@string/app_name"
12+
android:theme="@style/AppTheme" >
13+
<!--PhotoActivity-->
14+
<activity
15+
android:name=".CameraActivity"
16+
android:label="@string/app_name"
17+
android:configChanges="keyboardHidden|orientation">
18+
<intent-filter>
19+
<action android:name="android.intent.action.MAIN" />
20+
<category android:name="android.intent.category.LAUNCHER" />
21+
</intent-filter>
22+
</activity>
23+
</application>
24+
25+
</manifest>

0 commit comments

Comments
 (0)