提交Android版实时识别功能
This commit is contained in:
Regular → Executable
+1
@@ -1,4 +1,5 @@
|
|||||||
*.iml
|
*.iml
|
||||||
|
app.iml
|
||||||
.gradle
|
.gradle
|
||||||
/local.properties
|
/local.properties
|
||||||
/.idea/libraries
|
/.idea/libraries
|
||||||
|
|||||||
Regular → Executable
+25
-23
@@ -8,7 +8,7 @@
|
|||||||
</facet>
|
</facet>
|
||||||
<facet type="native-android-gradle" name="Native-Android-Gradle">
|
<facet type="native-android-gradle" name="Native-Android-Gradle">
|
||||||
<configuration>
|
<configuration>
|
||||||
<option name="SELECTED_BUILD_VARIANT" value="debug" />
|
<option name="SELECTED_BUILD_VARIANT" value="debug-armeabi-v7a" />
|
||||||
</configuration>
|
</configuration>
|
||||||
</facet>
|
</facet>
|
||||||
<facet type="android" name="Android">
|
<facet type="android" name="Android">
|
||||||
@@ -22,7 +22,8 @@
|
|||||||
<option name="ALLOW_USER_CONFIGURATION" value="false" />
|
<option name="ALLOW_USER_CONFIGURATION" value="false" />
|
||||||
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
|
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
|
||||||
<option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
|
<option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
|
||||||
<option name="RES_FOLDERS_RELATIVE_PATH" value="file://$MODULE_DIR$/src/main/res" />
|
<option name="RES_FOLDERS_RELATIVE_PATH" value="file://$MODULE_DIR$/src/main/res;file://$MODULE_DIR$/build/generated/res/rs/debug;file://$MODULE_DIR$/build/generated/res/resValues/debug" />
|
||||||
|
<option name="TEST_RES_FOLDERS_RELATIVE_PATH" value="" />
|
||||||
<option name="ASSETS_FOLDER_RELATIVE_PATH" value="/src/main/assets" />
|
<option name="ASSETS_FOLDER_RELATIVE_PATH" value="/src/main/assets" />
|
||||||
</configuration>
|
</configuration>
|
||||||
</facet>
|
</facet>
|
||||||
@@ -35,14 +36,12 @@
|
|||||||
<sourceFolder url="file://$MODULE_DIR$/src/main/cpp" isTestSource="false" />
|
<sourceFolder url="file://$MODULE_DIR$/src/main/cpp" isTestSource="false" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/main/cpp/src" isTestSource="false" />
|
<sourceFolder url="file://$MODULE_DIR$/src/main/cpp/src" isTestSource="false" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/debug" isTestSource="false" generated="true" />
|
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/debug" isTestSource="false" generated="true" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/debug" isTestSource="false" generated="true" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/debug" isTestSource="false" generated="true" />
|
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/debug" isTestSource="false" generated="true" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" />
|
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/debug" isTestSource="false" generated="true" />
|
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/debug" isTestSource="false" generated="true" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/debug" type="java-resource" />
|
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/debug" type="java-resource" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/debug" type="java-resource" />
|
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/debug" type="java-resource" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/androidTest/debug" isTestSource="true" generated="true" />
|
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/androidTest/debug" isTestSource="true" generated="true" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/androidTest/debug" isTestSource="true" generated="true" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/androidTest/debug" isTestSource="true" generated="true" />
|
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/androidTest/debug" isTestSource="true" generated="true" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/debug" isTestSource="true" generated="true" />
|
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/debug" isTestSource="true" generated="true" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/androidTest/debug" isTestSource="true" generated="true" />
|
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/androidTest/debug" isTestSource="true" generated="true" />
|
||||||
@@ -96,10 +95,12 @@
|
|||||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
|
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
|
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
|
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/.externalNativeBuild" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/generated/not_namespaced_r_class_sources" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/generated/source/r" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/build-info" />
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/build-info" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/builds" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/check-manifest" />
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/check-manifest" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/cmake" />
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/cmake" />
|
||||||
@@ -108,10 +109,9 @@
|
|||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-runtime-classes" />
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-runtime-classes" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-verifier" />
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-verifier" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/instant-run-apk" />
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/instant-run-apk" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/instant-run-main-apk-res" />
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/instant-run-resources" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaPrecompile" />
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaPrecompile" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" />
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/lint" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifest-checker" />
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifest-checker" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/prebuild" />
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/prebuild" />
|
||||||
@@ -129,34 +129,36 @@
|
|||||||
</content>
|
</content>
|
||||||
<orderEntry type="jdk" jdkName="Android API 27 Platform" jdkType="Android SDK" />
|
<orderEntry type="jdk" jdkName="Android API 27 Platform" jdkType="Android SDK" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
<orderEntry type="library" scope="TEST" name="Gradle: com.android.support.test:runner-1.0.2" level="project" />
|
<orderEntry type="library" name="Gradle: com.android.support:support-vector-drawable:27.1.1@aar" level="project" />
|
||||||
|
<orderEntry type="library" name="Gradle: com.android.support:support-core-utils:27.1.1@aar" level="project" />
|
||||||
|
<orderEntry type="library" name="Gradle: android.arch.lifecycle:livedata-core:1.1.0@aar" level="project" />
|
||||||
|
<orderEntry type="library" name="Gradle: android.arch.lifecycle:runtime:1.1.0@aar" level="project" />
|
||||||
<orderEntry type="library" name="Gradle: android.arch.lifecycle:common:1.1.0@jar" level="project" />
|
<orderEntry type="library" name="Gradle: android.arch.lifecycle:common:1.1.0@jar" level="project" />
|
||||||
<orderEntry type="library" name="Gradle: com.android.support:support-annotations:27.1.1@jar" level="project" />
|
<orderEntry type="library" name="Gradle: com.android.support:support-annotations:27.1.1@jar" level="project" />
|
||||||
<orderEntry type="library" name="Gradle: com.android.support:animated-vector-drawable-27.1.1" level="project" />
|
<orderEntry type="library" name="Gradle: android.arch.lifecycle:viewmodel:1.1.0@aar" level="project" />
|
||||||
<orderEntry type="library" name="Gradle: com.android.support:support-compat-27.1.1" level="project" />
|
<orderEntry type="library" name="Gradle: com.android.support.constraint:constraint-layout:1.1.2@aar" level="project" />
|
||||||
<orderEntry type="library" name="Gradle: android.arch.lifecycle:viewmodel-1.1.0" level="project" />
|
<orderEntry type="library" scope="TEST" name="Gradle: com.android.support.test.espresso:espresso-idling-resource:3.0.2@aar" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="Gradle: com.android.support.test:runner:1.0.2@aar" level="project" />
|
||||||
|
<orderEntry type="library" name="Gradle: com.github.bumptech.glide:glide:3.8.0@jar" level="project" />
|
||||||
|
<orderEntry type="library" name="Gradle: android.arch.core:runtime:1.1.0@aar" level="project" />
|
||||||
<orderEntry type="library" scope="TEST" name="Gradle: com.squareup:javawriter:2.1.1@jar" level="project" />
|
<orderEntry type="library" scope="TEST" name="Gradle: com.squareup:javawriter:2.1.1@jar" level="project" />
|
||||||
<orderEntry type="library" name="Gradle: com.android.support:support-vector-drawable-27.1.1" level="project" />
|
<orderEntry type="library" name="Gradle: com.android.support:animated-vector-drawable:27.1.1@aar" level="project" />
|
||||||
<orderEntry type="library" name="Gradle: com.android.support:support-core-ui-27.1.1" level="project" />
|
<orderEntry type="library" scope="TEST" name="Gradle: com.android.support.test.espresso:espresso-core:3.0.2@aar" level="project" />
|
||||||
<orderEntry type="library" name="Gradle: com.android.support.constraint:constraint-layout-1.1.2" level="project" />
|
|
||||||
<orderEntry type="library" name="Gradle: com.android.support:support-core-utils-27.1.1" level="project" />
|
|
||||||
<orderEntry type="library" scope="TEST" name="Gradle: com.google.code.findbugs:jsr305:2.0.1@jar" level="project" />
|
<orderEntry type="library" scope="TEST" name="Gradle: com.google.code.findbugs:jsr305:2.0.1@jar" level="project" />
|
||||||
<orderEntry type="library" scope="TEST" name="Gradle: com.android.support.test.espresso:espresso-core-3.0.2" level="project" />
|
|
||||||
<orderEntry type="library" scope="TEST" name="Gradle: javax.inject:javax.inject:1@jar" level="project" />
|
<orderEntry type="library" scope="TEST" name="Gradle: javax.inject:javax.inject:1@jar" level="project" />
|
||||||
<orderEntry type="library" name="Gradle: com.android.support:support-fragment-27.1.1" level="project" />
|
|
||||||
<orderEntry type="library" scope="TEST" name="Gradle: junit:junit:4.12@jar" level="project" />
|
<orderEntry type="library" scope="TEST" name="Gradle: junit:junit:4.12@jar" level="project" />
|
||||||
<orderEntry type="library" name="Gradle: android.arch.core:runtime-1.1.0" level="project" />
|
<orderEntry type="library" name="Gradle: com.android.support:support-core-ui:27.1.1@aar" level="project" />
|
||||||
<orderEntry type="library" scope="TEST" name="Gradle: org.hamcrest:hamcrest-core:1.3@jar" level="project" />
|
<orderEntry type="library" scope="TEST" name="Gradle: org.hamcrest:hamcrest-core:1.3@jar" level="project" />
|
||||||
<orderEntry type="library" scope="TEST" name="Gradle: com.android.support.test:monitor-1.0.2" level="project" />
|
<orderEntry type="library" name="Gradle: com.android.support:support-compat:27.1.1@aar" level="project" />
|
||||||
<orderEntry type="library" name="Gradle: com.android.support:appcompat-v7-27.1.1" level="project" />
|
<orderEntry type="library" name="Gradle: org.greenrobot:eventbus:3.0.0@jar" level="project" />
|
||||||
<orderEntry type="library" scope="TEST" name="Gradle: com.android.support.test.espresso:espresso-idling-resource-3.0.2" level="project" />
|
|
||||||
<orderEntry type="library" name="Gradle: com.android.support.constraint:constraint-layout-solver:1.1.2@jar" level="project" />
|
<orderEntry type="library" name="Gradle: com.android.support.constraint:constraint-layout-solver:1.1.2@jar" level="project" />
|
||||||
<orderEntry type="library" name="Gradle: android.arch.lifecycle:livedata-core-1.1.0" level="project" />
|
<orderEntry type="library" name="Gradle: com.android.support:support-fragment:27.1.1@aar" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="Gradle: com.android.support.test:monitor:1.0.2@aar" level="project" />
|
||||||
<orderEntry type="library" scope="TEST" name="Gradle: org.hamcrest:hamcrest-library:1.3@jar" level="project" />
|
<orderEntry type="library" scope="TEST" name="Gradle: org.hamcrest:hamcrest-library:1.3@jar" level="project" />
|
||||||
<orderEntry type="library" scope="TEST" name="Gradle: org.hamcrest:hamcrest-integration:1.3@jar" level="project" />
|
<orderEntry type="library" scope="TEST" name="Gradle: org.hamcrest:hamcrest-integration:1.3@jar" level="project" />
|
||||||
|
<orderEntry type="library" name="Gradle: com.android.support:appcompat-v7:27.1.1@aar" level="project" />
|
||||||
<orderEntry type="library" name="Gradle: android.arch.core:common:1.1.0@jar" level="project" />
|
<orderEntry type="library" name="Gradle: android.arch.core:common:1.1.0@jar" level="project" />
|
||||||
<orderEntry type="library" scope="TEST" name="Gradle: net.sf.kxml:kxml2:2.3.0@jar" level="project" />
|
<orderEntry type="library" scope="TEST" name="Gradle: net.sf.kxml:kxml2:2.3.0@jar" level="project" />
|
||||||
<orderEntry type="library" name="Gradle: android.arch.lifecycle:runtime-1.1.0" level="project" />
|
|
||||||
<orderEntry type="module" module-name="openCVLibrary342" />
|
<orderEntry type="module" module-name="openCVLibrary342" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
||||||
Regular → Executable
+2
@@ -59,5 +59,7 @@ dependencies {
|
|||||||
testImplementation 'junit:junit:4.12'
|
testImplementation 'junit:junit:4.12'
|
||||||
androidTestImplementation 'com.android.support.test:runner:1.0.2'
|
androidTestImplementation 'com.android.support.test:runner:1.0.2'
|
||||||
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
|
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
|
||||||
|
api 'com.github.bumptech.glide:glide:3.8.0'
|
||||||
|
implementation 'org.greenrobot:eventbus:3.0.0'
|
||||||
implementation project(':openCVLibrary342')
|
implementation project(':openCVLibrary342')
|
||||||
}
|
}
|
||||||
Regular → Executable
+2
@@ -50,6 +50,8 @@
|
|||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
<activity android:name=".CameraActivity"
|
||||||
|
/>
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
||||||
@@ -38,8 +38,7 @@ add_library( # Sets the name of the library.
|
|||||||
|
|
||||||
|
|
||||||
#target_link_libraries( hyperlpr lib_opencv)
|
#target_link_libraries( hyperlpr lib_opencv)
|
||||||
target_link_libraries(hyperlpr ${OpenCV_LIBS})
|
target_link_libraries(hyperlpr jnigraphics ${OpenCV_LIBS})
|
||||||
|
|
||||||
|
|
||||||
#连接现成的第三方库
|
#连接现成的第三方库
|
||||||
#set(INC_DIR /Users/mac02/Desktop/studiospace/test/PrjAnndroid/app/src/main/cpp/OpencvNative/include)
|
#set(INC_DIR /Users/mac02/Desktop/studiospace/test/PrjAnndroid/app/src/main/cpp/OpencvNative/include)
|
||||||
|
|||||||
Regular → Executable
Regular → Executable
@@ -21,8 +21,6 @@ namespace pr{
|
|||||||
"B", "C", "D", "E", "F", "G", "H", "J", "K", "L", "M", "N", "P", "Q", "R", "S", "T", "U", "V", "W", "X",
|
"B", "C", "D", "E", "F", "G", "H", "J", "K", "L", "M", "N", "P", "Q", "R", "S", "T", "U", "V", "W", "X",
|
||||||
"Y", "Z","港","学","使","警","澳","挂","军","北","南","广","沈","兰","成","济","海","民","航","空"};
|
"Y", "Z","港","学","使","警","澳","挂","军","北","南","广","沈","兰","成","济","海","民","航","空"};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const int SEGMENTATION_FREE_METHOD = 0;
|
const int SEGMENTATION_FREE_METHOD = 0;
|
||||||
const int SEGMENTATION_BASED_METHOD = 1;
|
const int SEGMENTATION_BASED_METHOD = 1;
|
||||||
|
|
||||||
@@ -37,24 +35,14 @@ namespace pr{
|
|||||||
PipelinePR(std::string detector_filename,
|
PipelinePR(std::string detector_filename,
|
||||||
std::string finemapping_prototxt,std::string finemapping_caffemodel,
|
std::string finemapping_prototxt,std::string finemapping_caffemodel,
|
||||||
std::string segmentation_prototxt,std::string segmentation_caffemodel,
|
std::string segmentation_prototxt,std::string segmentation_caffemodel,
|
||||||
std::string charRecognization_proto,std::string charRecognization_caffemodel);
|
std::string charRecognization_proto,std::string charRecognization_caffemodel,
|
||||||
// std::string segmentationfree_proto,std::string segmentationfree_caffemodel
|
std::string segmentationfree_proto,std::string segmentationfree_caffemodel
|
||||||
// );
|
);
|
||||||
~PipelinePR();
|
~PipelinePR();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
std::vector<std::string> plateRes;
|
std::vector<std::string> plateRes;
|
||||||
std::vector<PlateInfo> RunPiplineAsImage(cv::Mat plateImage,int method);
|
std::vector<PlateInfo> RunPiplineAsImage(cv::Mat plateImage,int method);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif //SWIFTPR_PIPLINE_H
|
#endif //SWIFTPR_PIPLINE_H
|
||||||
|
|||||||
Regular → Executable
+130
-5
@@ -2,7 +2,74 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include "include/Pipeline.h"
|
#include "include/Pipeline.h"
|
||||||
|
|
||||||
|
#include <android/log.h>
|
||||||
|
#include <android/bitmap.h>
|
||||||
|
|
||||||
|
#include <opencv2/opencv.hpp>
|
||||||
|
|
||||||
|
using namespace cv;
|
||||||
|
#define LOG_TAG "System.out"
|
||||||
|
#define LOGI(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__)
|
||||||
|
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__)
|
||||||
|
#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__)
|
||||||
|
jobject mat_to_bitmap(JNIEnv * env, Mat & src, bool needPremultiplyAlpha, jobject bitmap_config){
|
||||||
|
|
||||||
|
jclass java_bitmap_class = (jclass)env->FindClass("android/graphics/Bitmap");
|
||||||
|
jmethodID mid = env->GetStaticMethodID(java_bitmap_class,
|
||||||
|
"createBitmap", "(IILandroid/graphics/Bitmap$Config;)Landroid/graphics/Bitmap;");
|
||||||
|
|
||||||
|
jobject bitmap = env->CallStaticObjectMethod(java_bitmap_class,
|
||||||
|
mid, src.size().width, src.size().height, bitmap_config);
|
||||||
|
AndroidBitmapInfo info;
|
||||||
|
void* pixels = 0;
|
||||||
|
|
||||||
|
try {
|
||||||
|
//validate
|
||||||
|
CV_Assert(AndroidBitmap_getInfo(env, bitmap, &info) >= 0);
|
||||||
|
CV_Assert(src.type() == CV_8UC1 || src.type() == CV_8UC3 || src.type() == CV_8UC4);
|
||||||
|
CV_Assert(AndroidBitmap_lockPixels(env, bitmap, &pixels) >= 0);
|
||||||
|
CV_Assert(pixels);
|
||||||
|
|
||||||
|
//type mat
|
||||||
|
if(info.format == ANDROID_BITMAP_FORMAT_RGBA_8888){
|
||||||
|
Mat tmp(info.height, info.width, CV_8UC4, pixels);
|
||||||
|
if(src.type() == CV_8UC1){
|
||||||
|
cvtColor(src, tmp, CV_GRAY2RGBA);
|
||||||
|
} else if(src.type() == CV_8UC3){
|
||||||
|
cvtColor(src, tmp, CV_RGB2RGBA);
|
||||||
|
} else if(src.type() == CV_8UC4){
|
||||||
|
if(needPremultiplyAlpha){
|
||||||
|
cvtColor(src, tmp, COLOR_RGBA2mRGBA);
|
||||||
|
}else{
|
||||||
|
src.copyTo(tmp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} else{
|
||||||
|
Mat tmp(info.height, info.width, CV_8UC2, pixels);
|
||||||
|
if(src.type() == CV_8UC1){
|
||||||
|
cvtColor(src, tmp, CV_GRAY2BGR565);
|
||||||
|
} else if(src.type() == CV_8UC3){
|
||||||
|
cvtColor(src, tmp, CV_RGB2BGR565);
|
||||||
|
} else if(src.type() == CV_8UC4){
|
||||||
|
cvtColor(src, tmp, CV_RGBA2BGR565);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
AndroidBitmap_unlockPixels(env, bitmap);
|
||||||
|
return bitmap;
|
||||||
|
} catch(cv::Exception e){
|
||||||
|
AndroidBitmap_unlockPixels(env, bitmap);
|
||||||
|
jclass je = env->FindClass("org/opencv/core/CvException");
|
||||||
|
if(!je) je = env->FindClass("java/lang/Exception");
|
||||||
|
env->ThrowNew(je, e.what());
|
||||||
|
return bitmap;
|
||||||
|
} catch (...){
|
||||||
|
AndroidBitmap_unlockPixels(env, bitmap);
|
||||||
|
jclass je = env->FindClass("java/lang/Exception");
|
||||||
|
env->ThrowNew(je, "Unknown exception in JNI code {nMatToBitmap}");
|
||||||
|
return bitmap;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
std::string jstring2str(JNIEnv* env, jstring jstr)
|
std::string jstring2str(JNIEnv* env, jstring jstr)
|
||||||
{
|
{
|
||||||
@@ -36,7 +103,8 @@ Java_pr_platerecognization_PlateRecognition_InitPlateRecognizer(
|
|||||||
jstring detector_filename,
|
jstring detector_filename,
|
||||||
jstring finemapping_prototxt, jstring finemapping_caffemodel,
|
jstring finemapping_prototxt, jstring finemapping_caffemodel,
|
||||||
jstring segmentation_prototxt, jstring segmentation_caffemodel,
|
jstring segmentation_prototxt, jstring segmentation_caffemodel,
|
||||||
jstring charRecognization_proto, jstring charRecognization_caffemodel) {
|
jstring charRecognization_proto, jstring charRecognization_caffemodel,
|
||||||
|
jstring segmentationfree_proto, jstring segmentationfree_caffemodel) {
|
||||||
|
|
||||||
std::string detector_path = jstring2str(env, detector_filename);
|
std::string detector_path = jstring2str(env, detector_filename);
|
||||||
std::string finemapping_prototxt_path = jstring2str(env, finemapping_prototxt);
|
std::string finemapping_prototxt_path = jstring2str(env, finemapping_prototxt);
|
||||||
@@ -45,12 +113,15 @@ Java_pr_platerecognization_PlateRecognition_InitPlateRecognizer(
|
|||||||
std::string segmentation_caffemodel_path = jstring2str(env, segmentation_caffemodel);
|
std::string segmentation_caffemodel_path = jstring2str(env, segmentation_caffemodel);
|
||||||
std::string charRecognization_proto_path = jstring2str(env, charRecognization_proto);
|
std::string charRecognization_proto_path = jstring2str(env, charRecognization_proto);
|
||||||
std::string charRecognization_caffemodel_path = jstring2str(env, charRecognization_caffemodel);
|
std::string charRecognization_caffemodel_path = jstring2str(env, charRecognization_caffemodel);
|
||||||
|
std::string segmentationfree_proto_path = jstring2str(env, segmentationfree_proto);
|
||||||
|
std::string segmentationfree_caffemodel_path = jstring2str(env, segmentationfree_caffemodel);
|
||||||
|
|
||||||
|
|
||||||
pr::PipelinePR *PR = new pr::PipelinePR(detector_path,
|
pr::PipelinePR *PR = new pr::PipelinePR(detector_path,
|
||||||
finemapping_prototxt_path, finemapping_caffemodel_path,
|
finemapping_prototxt_path, finemapping_caffemodel_path,
|
||||||
segmentation_prototxt_path, segmentation_caffemodel_path,
|
segmentation_prototxt_path, segmentation_caffemodel_path,
|
||||||
charRecognization_proto_path, charRecognization_caffemodel_path);
|
charRecognization_proto_path, charRecognization_caffemodel_path,
|
||||||
|
segmentationfree_proto_path, segmentationfree_caffemodel_path);
|
||||||
|
|
||||||
return (jlong) PR;
|
return (jlong) PR;
|
||||||
}
|
}
|
||||||
@@ -63,25 +134,79 @@ Java_pr_platerecognization_PlateRecognition_SimpleRecognization(
|
|||||||
pr::PipelinePR *PR = (pr::PipelinePR *) object_pr;
|
pr::PipelinePR *PR = (pr::PipelinePR *) object_pr;
|
||||||
cv::Mat &mRgb = *(cv::Mat *) matPtr;
|
cv::Mat &mRgb = *(cv::Mat *) matPtr;
|
||||||
cv::Mat rgb;
|
cv::Mat rgb;
|
||||||
// cv::cvtColor(mRgb,rgb,cv::COLOR_RGBA2GRAY);
|
|
||||||
cv::cvtColor(mRgb,rgb,cv::COLOR_RGBA2BGR);
|
cv::cvtColor(mRgb,rgb,cv::COLOR_RGBA2BGR);
|
||||||
|
|
||||||
// cv::imwrite("/sdcard/demo.jpg",rgb);
|
|
||||||
|
|
||||||
//1表示SEGMENTATION_BASED_METHOD在方法里有说明
|
//1表示SEGMENTATION_BASED_METHOD在方法里有说明
|
||||||
std::vector<pr::PlateInfo> list_res= PR->RunPiplineAsImage(rgb,1);
|
std::vector<pr::PlateInfo> list_res= PR->RunPiplineAsImage(rgb,pr::SEGMENTATION_FREE_METHOD);
|
||||||
// std::vector<pr::PlateInfo> list_res= PR->RunPiplineAsImage(rgb,1);
|
// std::vector<pr::PlateInfo> list_res= PR->RunPiplineAsImage(rgb,1);
|
||||||
std::string concat_results;
|
std::string concat_results;
|
||||||
for(auto one:list_res)
|
for(auto one:list_res)
|
||||||
{
|
{
|
||||||
|
//可信度
|
||||||
if (one.confidence>0.7)
|
if (one.confidence>0.7)
|
||||||
concat_results+=one.getPlateName()+",";
|
concat_results+=one.getPlateName()+",";
|
||||||
}
|
}
|
||||||
|
|
||||||
concat_results = concat_results.substr(0,concat_results.size()-1);
|
concat_results = concat_results.substr(0,concat_results.size()-1);
|
||||||
|
|
||||||
return env->NewStringUTF(concat_results.c_str());
|
return env->NewStringUTF(concat_results.c_str());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车牌号的详细信息
|
||||||
|
* @param env
|
||||||
|
* @param obj
|
||||||
|
* @param matPtr
|
||||||
|
* @param object_pr
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
JNIEXPORT jobject JNICALL
|
||||||
|
Java_pr_platerecognization_PlateRecognition_PlateInfoRecognization(
|
||||||
|
JNIEnv *env, jobject obj,
|
||||||
|
jlong matPtr, jlong object_pr) {
|
||||||
|
jclass plateInfo_class = env -> FindClass("pr/platerecognization/PlateInfo");
|
||||||
|
jmethodID mid = env->GetMethodID(plateInfo_class,"<init>","()V");
|
||||||
|
jobject plateInfoObj = env->NewObject(plateInfo_class,mid);
|
||||||
|
|
||||||
|
pr::PipelinePR *PR = (pr::PipelinePR *) object_pr;
|
||||||
|
cv::Mat &mRgb = *(cv::Mat *) matPtr;
|
||||||
|
cv::Mat rgb;
|
||||||
|
cv::cvtColor(mRgb,rgb,cv::COLOR_RGBA2BGR);
|
||||||
|
|
||||||
|
//1表示SEGMENTATION_BASED_METHOD在方法里有说明
|
||||||
|
std::vector<pr::PlateInfo> list_res= PR->RunPiplineAsImage(rgb,pr::SEGMENTATION_FREE_METHOD);
|
||||||
|
std::string concat_results;
|
||||||
|
pr::PlateInfo plateInfo;
|
||||||
|
for(auto one:list_res)
|
||||||
|
{
|
||||||
|
//可信度
|
||||||
|
if (one.confidence>0.7) {
|
||||||
|
plateInfo = one;
|
||||||
|
//车牌号
|
||||||
|
jfieldID fid_plate_name = env->GetFieldID(plateInfo_class,"plateName","Ljava/lang/String;");
|
||||||
|
env->SetObjectField(plateInfoObj,fid_plate_name,env->NewStringUTF(plateInfo.getPlateName().c_str()));
|
||||||
|
|
||||||
|
//识别区域
|
||||||
|
Mat src = plateInfo.getPlateImage();
|
||||||
|
|
||||||
|
jclass java_bitmap_class = (jclass)env->FindClass("android/graphics/Bitmap$Config");
|
||||||
|
jmethodID bitmap_mid = env->GetStaticMethodID(java_bitmap_class,
|
||||||
|
"nativeToConfig", "(I)Landroid/graphics/Bitmap$Config;");
|
||||||
|
jobject bitmap_config = env->CallStaticObjectMethod(java_bitmap_class, bitmap_mid, 5);
|
||||||
|
|
||||||
|
jfieldID fid_bitmap = env->GetFieldID(plateInfo_class, "bitmap","Landroid/graphics/Bitmap;");
|
||||||
|
jobject _bitmap = mat_to_bitmap(env, src, false, bitmap_config);
|
||||||
|
env->SetObjectField(plateInfoObj,fid_bitmap, _bitmap);
|
||||||
|
return plateInfoObj;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return plateInfoObj;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
JNIEXPORT void JNICALL
|
JNIEXPORT void JNICALL
|
||||||
Java_pr_platerecognization_PlateRecognition_ReleasePlateRecognizer(
|
Java_pr_platerecognization_PlateRecognition_ReleasePlateRecognizer(
|
||||||
JNIEnv *env, jobject obj,
|
JNIEnv *env, jobject obj,
|
||||||
|
|||||||
Vendored
Regular → Executable
Vendored
Regular → Executable
Vendored
Regular → Executable
Vendored
Regular → Executable
Vendored
Regular → Executable
Vendored
Regular → Executable
Vendored
Regular → Executable
Vendored
Regular → Executable
Vendored
Regular → Executable
Vendored
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
+126
@@ -0,0 +1,126 @@
|
|||||||
|
//
|
||||||
|
// Created by 庾金科 on 20/09/2017.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef SWIFTPR_PLATEINFO_H
|
||||||
|
#define SWIFTPR_PLATEINFO_H
|
||||||
|
#include <opencv2/opencv.hpp>
|
||||||
|
namespace pr {
|
||||||
|
|
||||||
|
typedef std::vector<cv::Mat> Character;
|
||||||
|
|
||||||
|
enum PlateColor { BLUE, YELLOW, WHITE, GREEN, BLACK,UNKNOWN};
|
||||||
|
enum CharType {CHINESE,LETTER,LETTER_NUMS,INVALID};
|
||||||
|
|
||||||
|
|
||||||
|
class PlateInfo {
|
||||||
|
public:
|
||||||
|
std::vector<std::pair<CharType,cv::Mat>> plateChars;
|
||||||
|
std::vector<std::pair<CharType,cv::Mat>> plateCoding;
|
||||||
|
float confidence = 0;
|
||||||
|
PlateInfo(const cv::Mat &plateData, std::string plateName, cv::Rect plateRect, PlateColor plateType) {
|
||||||
|
licensePlate = plateData;
|
||||||
|
name = plateName;
|
||||||
|
ROI = plateRect;
|
||||||
|
Type = plateType;
|
||||||
|
}
|
||||||
|
PlateInfo(const cv::Mat &plateData, cv::Rect plateRect, PlateColor plateType) {
|
||||||
|
licensePlate = plateData;
|
||||||
|
ROI = plateRect;
|
||||||
|
Type = plateType;
|
||||||
|
}
|
||||||
|
PlateInfo(const cv::Mat &plateData, cv::Rect plateRect) {
|
||||||
|
licensePlate = plateData;
|
||||||
|
ROI = plateRect;
|
||||||
|
}
|
||||||
|
PlateInfo() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
cv::Mat getPlateImage() {
|
||||||
|
return licensePlate;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setPlateImage(cv::Mat plateImage){
|
||||||
|
licensePlate = plateImage;
|
||||||
|
}
|
||||||
|
|
||||||
|
cv::Rect getPlateRect() {
|
||||||
|
return ROI;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setPlateRect(cv::Rect plateRect) {
|
||||||
|
ROI = plateRect;
|
||||||
|
}
|
||||||
|
cv::String getPlateName() {
|
||||||
|
return name;
|
||||||
|
|
||||||
|
}
|
||||||
|
void setPlateName(cv::String plateName) {
|
||||||
|
name = plateName;
|
||||||
|
}
|
||||||
|
int getPlateType() {
|
||||||
|
return Type;
|
||||||
|
}
|
||||||
|
|
||||||
|
void appendPlateChar(const std::pair<CharType,cv::Mat> &plateChar)
|
||||||
|
{
|
||||||
|
plateChars.push_back(plateChar);
|
||||||
|
}
|
||||||
|
|
||||||
|
void appendPlateCoding(const std::pair<CharType,cv::Mat> &charProb){
|
||||||
|
plateCoding.push_back(charProb);
|
||||||
|
}
|
||||||
|
|
||||||
|
// cv::Mat getPlateChars(int id) {
|
||||||
|
// if(id<PlateChars.size())
|
||||||
|
// return PlateChars[id];
|
||||||
|
// }
|
||||||
|
std::string decodePlateNormal(std::vector<std::string> mappingTable) {
|
||||||
|
std::string decode;
|
||||||
|
for(auto plate:plateCoding) {
|
||||||
|
float *prob = (float *)plate.second.data;
|
||||||
|
if(plate.first == CHINESE) {
|
||||||
|
|
||||||
|
decode += mappingTable[std::max_element(prob,prob+31) - prob];
|
||||||
|
confidence+=*std::max_element(prob,prob+31);
|
||||||
|
|
||||||
|
|
||||||
|
// std::cout<<*std::max_element(prob,prob+31)<<std::endl;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else if(plate.first == LETTER) {
|
||||||
|
decode += mappingTable[std::max_element(prob+41,prob+65)- prob];
|
||||||
|
confidence+=*std::max_element(prob+41,prob+65);
|
||||||
|
}
|
||||||
|
|
||||||
|
else if(plate.first == LETTER_NUMS) {
|
||||||
|
decode += mappingTable[std::max_element(prob+31,prob+65)- prob];
|
||||||
|
confidence+=*std::max_element(prob+31,prob+65);
|
||||||
|
// std::cout<<*std::max_element(prob+31,prob+65)<<std::endl;
|
||||||
|
|
||||||
|
}
|
||||||
|
else if(plate.first == INVALID)
|
||||||
|
{
|
||||||
|
decode+='*';
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
name = decode;
|
||||||
|
|
||||||
|
confidence/=7;
|
||||||
|
|
||||||
|
return decode;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
cv::Mat licensePlate;
|
||||||
|
cv::Rect ROI;
|
||||||
|
std::string name ;
|
||||||
|
PlateColor Type;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif //SWIFTPR_PLATEINFO_H
|
||||||
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user