Android下使用opencv4Android实现人脸识别

官方下载链接:
https://opencv.org/releases/

我用迅雷下载的包(opencv-4.3.0-android-sdk),下载的结构是这样的:
opencv

目录结构
—samples
在这里插入图片描述
—sdk
在这里插入图片描述
暂时我也不知道这些有什么用,后面再看看

README.android 这个文件有介绍如何使用SDK

打开里面有个链接https://docs.opencv.org/2.4/doc/tutorials/introduction/android_binary_package/O4A_SDK.html
这链接介绍是比较老的版本,不合适我们现在的版本

在多看几次目录,发现SDK有一个java目录的src,然后我们新建一个c++工程,再创建一个lib目录,包名按org.opencv创建,把相关资源目录拷贝过去,如下所示
在这里插入图片描述
经过搜索多个博客目前我可能需要用到simple目录工程下face-detection这个module,所以,把这个工程也拷贝到我工程进去
在这里插入图片描述
拷贝进去后,这里提示依赖这个project,需要改为我自己的module的名字
在这里插入图片描述
同时把sdk里面的native目录也拷贝到我的lib工程里面在这里插入图片描述
我猜应该是这样操作吧
在这里插入图片描述
这报错了


E:\git_learn\AndroidOpenCVDemo\face-detection\jni\CMakeLists.txt : C/C++ debug|x86 : CMake Error at E:/git_learn/AndroidOpenCVDemo/opencvlibrary/native/jni/abi-x86/OpenCVModules.cmake:255 (message):
  The imported target "libcpufeatures" references the file

     "E:/git_learn/AndroidOpenCVDemo/sdk/native/3rdparty/libs/x86/libcpufeatures.a"

  but this file does not exist.  Possible reasons include:

  * The file was deleted, renamed, or moved to another location.

  * An install or uninstall procedure did not complete successfully.

  * The installation package was faulty and contained

     "E:/git_learn/AndroidOpenCVDemo/opencvlibrary/native/jni/abi-x86/OpenCVModules.cmake"

  but not all the files it references.

Call Stack (most recent call first):
  E:/git_learn/AndroidOpenCVDemo/opencvlibrary/native/jni/abi-x86/OpenCVConfig.cmake:146 (include)
  E:/git_learn/AndroidOpenCVDemo/opencvlibrary/native/jni/OpenCVConfig.cmake:44 (include)
  CMakeLists.txt:8 (find_package)

E:\git_learn\AndroidOpenCVDemo\face-detection\jni\CMakeLists.txt : C/C++ debug|x86 : Configuration failed.
executing external native build for cmake E:\git_learn\AndroidOpenCVDemo\face-detection\jni\CMakeLists.txt

直接把sdk拷贝到工程里面吧,,,简单粗暴,先把工程跑的来再说
在这里插入图片描述

现在报找不到类:
import org.opencv.engine.OpenCVEngineInterface;
在这里插入图片描述
在org.opencv.engine这个包名存在一个aidl的类,所以需要新建aidl目录来存放

最后选择在这里插入图片描述
就能运行起来,由于权限问题,需要手动打开权限来测试吧

最后GitHub的地址:https://github.com/moz1q1/AndroidOpenCVDemo

  • 2
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

落后程序员

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值