Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
imistyrain committed Jul 4, 2020
0 parents commit a165130
Show file tree
Hide file tree
Showing 744 changed files with 305,748 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
*.iml
.gradle
local.properties
.idea
.DS_Store
build/
app/build/
app/.externalNativeBuild
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
## 基于EasyPR的车牌识别android实现

EasyPR4Android,基于[EasyPR](https://github.com/liuruoze/EasyPR)1.6的android实现, 提供编译好的[mrcar.apk](https://github.com/imistyrain/EasyPR4Android/releases)安装运行demo.

### 效果图

特性:摄像头实时预览

![live](cameralive.png)

### 编译和运行:

环境: android studio3.5开发实现,ndk版本为R16b,OpenCV版本为3.2,android SDK版本为28,最低要求21。

* 1.下载并配置[android studio 3.5](http://www.android-studio.org/)

* 2.配置NDK16b[ndk r16b](http://blog.csdn.net/shuzfan/article/details/52690554)

* 3.编译并运行,也可以直接下载编译好的[apk](https://github.com/imistyrain/EasyPR4Android/releases)安装使用

本项目定义了三个Activity, 其中

* [PhotoActivity](app/src/main/java/yanyu/com/mrcar/PhotoActivity.java)是从图片和系统相机抓取图片进行识别

* [CVCameraActivity](app/src/main/java/yanyu/com/mrcar/CVCameraActivity.java)是用OpenCV的JavaCameraView实时识别,由于OpenCV实现的限制,其只能用于横屏,虽然也有trick能使其支持竖屏,但会有性能损失,为此产生了第三种

* [CameraActivity](app/src/main/java/yanyu/com/mrcar/CameraActivity.java)原始摄像头实时识别,抓取NV21数据送到jni中,并将其抓换成RGB数据进行处理,其支持竖屏识别。

### 参考:

* 1.[Native方式集成OpenCV](https://github.com/ShawnZhang31/opencv-android-studio)

* 2.[JNI两种注册过程实战](https://blog.csdn.net/xsf50717/article/details/54693802)

* 3.[Android Camera1 教程 · 第二章 · 预览](https://www.jianshu.com/p/705d4792e836)

* 4.[ios 端车牌识别](https://github.com/imistyrain/EasyPR-Swift)
1 change: 1 addition & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
42 changes: 42 additions & 0 deletions app/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Sets the minimum version of CMake required to build the native
# library. You should either keep the default value or only pass a
# value of 3.4.0 or lower.

cmake_minimum_required(VERSION 3.4.1)

set(LIB_DIR ${CMAKE_CURRENT_LIST_DIR}/src/main/jniLibs/${ANDROID_ABI}/)

#add include dir
include_directories(src/main/jni/include)
include_directories(src/main/jni)

#add source files
aux_source_directory(src/main/jni SOURCE_FILES)
aux_source_directory(src/main/jni/src/core SOURCE_FILES_CORE)
aux_source_directory(src/main/jni/src/train SOURCE_FILES_TRAIN)
aux_source_directory(src/main/jni/src/util SOURCE_FILES_UTIL)
aux_source_directory(src/main/jni/thirdparty/LBP SOURCE_FILES_LBP)
aux_source_directory(src/main/jni/thirdparty/mser SOURCE_FILES_MSER)
aux_source_directory(src/main/jni/thirdparty/svm SOURCE_FILES_SVM)
aux_source_directory(src/main/jni/thirdparty/textDetect SOURCE_FILES_TEXTDETECT)
aux_source_directory(src/main/jni/thirdparty/xmlParser SOURCE_FILES_XML)
list(REMOVE_ITEM SOURCE_FILES main.cpp)
list(APPEND SOURCE_FILES ${SOURCE_FILES_CORE})
list(APPEND SOURCE_FILES ${SOURCE_FILES_SOURCE_FILES_SVM})
list(APPEND SOURCE_FILES ${SOURCE_FILES_CORE})
list(APPEND SOURCE_FILES ${SOURCE_FILES_TRAIN})
list(APPEND SOURCE_FILES ${SOURCE_FILES_UTIL})
list(APPEND SOURCE_FILES ${SOURCE_FILES_LBP})
list(APPEND SOURCE_FILES ${SOURCE_FILES_MSER})
list(APPEND SOURCE_FILES ${SOURCE_FILES_TEXTDETECT})
list(APPEND SOURCE_FILES ${SOURCE_FILES_XML})
list(APPEND SOURCE_FILES "src/main/jni/jni.cpp")

add_library(lib_opencv_java3 SHARED IMPORTED)
add_library(lib_freetype STATIC IMPORTED)
set_target_properties(lib_opencv_java3 PROPERTIES IMPORTED_LOCATION ${LIB_DIR}/libopencv_java3.so)
set_target_properties(lib_freetype PROPERTIES IMPORTED_LOCATION ${LIB_DIR}/libfreetype2-static.a)
add_library(mrcar SHARED ${SOURCE_FILES})

find_library(log-lib log)
target_link_libraries(mrcar lib_opencv_java3 ${log-lib} lib_freetype)
44 changes: 44 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 28
buildToolsVersion "28.0.3"
defaultConfig {
applicationId "yanyu.com.mrcar"
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
ndk{
abiFilters 'arm64-v8a'//armeabi-v7a
}
externalNativeBuild {
cmake {
cppFlags "-std=c++11 -fexceptions"
}
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}

externalNativeBuild {
cmake {
path "CMakeLists.txt"
}
}
}

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.android.support:appcompat-v7:28.0.0'
androidTestImplementation 'junit:junit:4.12'
implementation project(path: ':openCVLibrary320')
}
17 changes: 17 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in D:\Java\adroidsdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
13 changes: 13 additions & 0 deletions app/src/androidTest/java/yanyu/com/mrcar/ApplicationTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package yanyu.com.mrcar;

import android.app.Application;
import android.test.ApplicationTestCase;

/**
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
*/
public class ApplicationTest extends ApplicationTestCase<Application> {
public ApplicationTest() {
super(Application.class);
}
}
25 changes: 25 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="yanyu.com.mrcar" >
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.VIBRATE"/>

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<!--PhotoActivity-->
<activity
android:name=".CameraActivity"
android:label="@string/app_name"
android:configChanges="keyboardHidden|orientation">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>
Loading

0 comments on commit a165130

Please sign in to comment.