最早之前接触人工智能是从一篇博客开始的,这篇博客作者记录了自己仿照一本教程开发的一套车牌识别系统开始,进而引申到人工智能领域的机器学习和深度学习。本文借鉴作者的这套系统,分析其实现,调试并更新其网络模型,并落地到android手机的具体应用上,记录引申到的相关领域的学习笔记:
1. C/C++
2. JAVA
3. Android开发
4. 算法相关
5. 人工智能/机器学习/深度学习
6. 相关工具使用
7. 学习资料
visutal studio code:
1.快捷键:
part1:从android上移植开始;
下载了android版本的车牌识别系统:.....
安装android studio,并配置了sdk和ndk;过程不是很顺利,记录一下:
1. 加载已有android 工程后,编译,出现错误:
无论编译还是清除,都是这个错误,查找了很多资料,结果都没用,后来自己研究发现报错原因:app的build.gradle文件,报错的时候提示:
Caused by: net.rubygrapefruit.platform.NativeException: Could not start 'D:\android-studio\android-ndk-r11c-windows-x86_64\android-ndk-r11c/ndk-build'
原来是找不到ndk-build, 打开工程的ndk路径下发现是有这个文件的,但是这个脚本把ndk-build当作了文件夹,所以给他加上后缀就ok了:ndk-build.cmd,再次执行clean,成功~~~
下面编译apk,又有错误:
Annotation processors must be explicitly declared now. The following dependencies on the compile classpath are found to contain annotation processor. Please add them to the annotationProcessor configuration.
- butterknife-7.0.1.jar (com.jakewharton:butterknife:7.0.1)
Alternatively, set android.defaultConfig.javaCompileOptions.annotationProcessorOptions.includeCompileClasspath = true to continue with previous behavior. Note that this option is deprecated and will be removed in the future.
See https://developer.android.com/r/tools/annotation-processor-error-message.html for more details.
依赖库报错,于是修改
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.jakewharton:butterknife:7.0.1'
annotationProcessor 'com.jakewharton:butterknife:7.0.1'
compile 'cn.pedant.sweetalert:library:1.3'
}
再次编译,成功编译出apk;
现在开始调试apk...
1. svmFile 始终为null,原因是执行
mediaStorageDir.mkdirs()
创建文件夹storage/emulated/0/Documents/PlateRcognizer失败,需要添加动态权限:
在AndroidManifest.xml中申请权限:
才baseActivaty中申请权限:
private static final int REQUEST_EXTERNAL_STORAGE = 1;
private static String[] PERMISSIONS_STORAGE = {
Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.WRITE_EXTERNAL_STORAGE
};
if (checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
// We don't have permission so prompt the user
requestPermissions(
PERMISSIONS_STORAGE,
REQUEST_EXTERNAL_STORAGE
);
}
2. err:打开摄像头失败:Failed to connect to camera service
解决:android 6.0以后版本需要添加动态权限:
在AndroidManifest.xml中申请权限:
使用之前动态申请权限:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (checkSelfPermission(Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
requestPermissions(new String[] {Manifest.permission.CAMERA}, 1);
}
}
3. 遇到 gradle:版本问题
androidstudio导入项目后,报错:Could not find com.android.tools.build:gradle:3.1.0
项目根目录的 build.gradle文件中添加其他可供下载的仓库:google()、 jcenter()、mavenCentral()
修改build.gradle:
buildscript {
repositories {
google()
jcenter()
}
=============================
完事具备,东风也来了.....
靠,我的nokia 平板是android 5.1的,经过上述修改过的版本是基于最新的android 10的sdk和build tool 制作的apk,居然无法运行;无奈,将android studio的sdk和build tools降低到源码匹配的23版本, 一切搞定;
替换成老版本,sdk用Android6.0 API23; ndk 用r11, build报错:
ERROR: Failed to resolve: com.android.support:appcompat-v7:23.4.0
Add Google Maven repository and sync project
Show in Project Structure dialog
Affected Modules: app
在platerecognizer的build.gradle 的依赖加上:
allprojects {
repositories {
jcenter()
maven {url "https://maven.google.com"}
}
}
重新编译,成功;
折腾一圈结果还是用人家的老版本, 我TM只学会了怎么配置和使用android studio......