Android opencv

news2024/10/7 11:07:34

install cmake

在这里插入图片描述

cpp folder,新建c++项目

在这里插入图片描述

获取 OpenCV4Android SDK O4A_SDK

在这里插入图片描述

  • 下载,并解压
~/Downloads/OpenCV-android-sdk$ tree -d -L 2
.
├── apk
├── samples
│   ├── 15-puzzle
│   ├── camera-calibration
│   ├── color-blob-detection
│   ├── face-detection
│   ├── image-manipulations
│   ├── tutorial-1-camerapreview
│   ├── tutorial-2-mixedprocessing
│   └── tutorial-3-cameracontrol
└── sdk
    ├── etc
    ├── java
    └── native

设置cmakelist等

在这里插入图片描述

这里在windows环境运行

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

  • 尝试编译运行一下
    在这里插入图片描述

  • 参考 在Android Studio工程中配置OpenCV库的并实现OpenCV实例Color Detect
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述

# For more information about using CMake with Android Studio, read the
# documentation: https://d.android.com/studio/projects/add-native-code.html

# Sets the minimum version of CMake required to build the native library.

cmake_minimum_required(VERSION 3.22.1)

# Declares and names the project.

project("myapplication2")

set(pathToOpenCV C:\\OpenCV-android-sdk\\sdk\\native)
include_directories(${pathToOpenCV}/jni/include)

# Creates and names a library, sets it as either STATIC
# or SHARED, and provides the relative paths to its source code.
# You can define multiple libraries, and CMake builds them for you.
# Gradle automatically packages shared libraries with your APK.
add_library( lib_opencv SHARED IMPORTED )
set_target_properties(lib_opencv PROPERTIES IMPORTED_LOCATION C:/User/admin/AndroidStudioProjects/MyApplication2/app/src/main/jniLibs/${ANDROID_ABI}/libopencv_java3.so)

add_library( # Sets the name of the library.
        myapplication2

        # Sets the library as a shared library.
        SHARED

        # Provides a relative path to your source file(s).
        native-lib.cpp)

# Searches for a specified prebuilt library and stores the path as a
# variable. Because CMake includes system libraries in the search path by
# default, you only need to specify the name of the public NDK library
# you want to add. CMake verifies that the library exists before
# completing its build.

find_library( # Sets the name of the path variable.
        log-lib

        # Specifies the name of the NDK library that
        # you want CMake to locate.
        log)

# Specifies libraries CMake should link to your target library. You
# can link multiple libraries, such as libraries you define in this
# build script, prebuilt third-party libraries, or system libraries.

target_link_libraries( # Specifies the target library.
        myapplication2

        # Links the target library to the log library
        # included in the NDK.
        ${log-lib}
        lib_opencv)
# https://blog.csdn.net/weixin_55626853/article/details/123941565
# cmake最低版本号
cmake_minimum_required(VERSION 3.4.1)

# 导入opencv头文件
include_directories(${OPENCV_HEADER_DIR})

# add_library:把一个library添加到工程
add_library(
        native-lib
        SHARED
        native-lib.cpp)

# 添加一个已构建的库,使用IMPORTED
add_library(opencv_java4 SHARED IMPORTED)
set_target_properties(opencv_java4
        PROPERTIES IMPORTED_LOCATION
        "${OPENCV_LIBS_DIR}/${ANDROID_ABI}/libopencv_java4.so")

# 首个参数是target,后面的参数是item;target必须先用add_library()创建过;
target_link_libraries(
        native-lib
        opencv_java4
        jnigraphics
        log )

# For more information about using CMake with Android Studio, read the
# documentation: https://d.android.com/studio/projects/add-native-code.html

# Sets the minimum version of CMake required to build the native library.

cmake_minimum_required(VERSION 3.22.1)

# Declares and names the project.

project("myapplication3")

set(pathToOpenCV C:\\OpenCV-android-sdk\\sdk\\native)
include_directories(${pathToOpenCV}/jni/include)
# Creates and names a library, sets it as either STATIC
# or SHARED, and provides the relative paths to its source code.
# You can define multiple libraries, and CMake builds them for you.
# Gradle automatically packages shared libraries with your APK.
add_library( lib_opencv SHARED IMPORTED )
set_target_properties(lib_opencv PROPERTIES IMPORTED_LOCATION C:/User/admin/AndroidStudioProjects/MyApplication3/app/src/main/jniLibs/${ANDROID_ABI}/libopencv_java3.so)



add_library( # Sets the name of the library.
        myapplication3

        # Sets the library as a shared library.
        SHARED

        # Provides a relative path to your source file(s).
        native-lib.cpp)

# Searches for a specified prebuilt library and stores the path as a
# variable. Because CMake includes system libraries in the search path by
# default, you only need to specify the name of the public NDK library
# you want to add. CMake verifies that the library exists before
# completing its build.

find_library( # Sets the name of the path variable.
        log-lib

        # Specifies the name of the NDK library that
        # you want CMake to locate.
        log)

# Specifies libraries CMake should link to your target library. You
# can link multiple libraries, such as libraries you define in this
# build script, prebuilt third-party libraries, or system libraries.

target_link_libraries( # Specifies the target library.
        myapplication3

        # Links the target library to the log library
        # included in the NDK.
        ${log-lib}
        ${lib_opencv}) # https://blog.csdn.net/gxhea/article/details/115616602
  • https://sriraghublog.wordpress.com/2017/03/11/opencv-in-android-an-introduction-part-1/

  • 简单的尝试: https://github.com/r4ghu/OpenCVAndroid-AnIntroduction
    在这里插入图片描述

errors

error - CMake ‘3.22.1’ found in SDK did not match requested version ‘3.10.2’.

在这里插入图片描述在这里插入图片描述

// https://www.thecodingnotebook.com/2020/04/image-processing-with-opencv-in-android.html
externalNativeBuild {
    cmake {
        path "src/main/cpp/CMakeLists.txt"
        version "3.10.2" # <<-- REMOVE THIS LINE
    }
}

nullpointer

在这里插入图片描述

Hope that helps! The steps below helped me get out of this situation:

File -> Invalidate Caches / Restart -> Invalidate and Restart
Build -> Clean Project

安卓插件中出现异常

CG

  • Importing opencv to android studio
  • 纯java调用的例子

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/425604.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

文件:IO流

1. 什么是IO /O 即输入Input/ 输出Output的缩写&#xff0c;其实就是计算机调度把各个存储中&#xff08;包括内存和外部存储&#xff09;的数据写入写出的过程&#xff1b;java中用“流&#xff08;stream&#xff09;”来抽象表示这么一个写入写出的功能&#xff0c;封装成一…

Vue学习笔记(7. axios异步请求)

1. axios请求方式 方式1&#xff1a;axios({method:"GET",url:"..."}) 方式2&#xff1a;axios({method:"POST",url:"...",data:"..."}) 方式3&#xff1a;axios.get("url...") 方式4&#xff1a;axios.post(…

Python中的35个关键字

✅作者简介&#xff1a;CSDN内容合伙人、阿里云专家博主、51CTO专家博主、新星计划第三季python赛道Top1&#x1f3c6; &#x1f4c3;个人主页&#xff1a;hacker707的csdn博客 &#x1f525;系列专栏&#xff1a;零基础入门篇 &#x1f4ac;个人格言&#xff1a;不断的翻越一座…

【 Spring MVC 核心功能(二) - 获取参数(下)】

文章目录一、使用 RequestBody 接收JSON对象二、使用 RequestPart 上传⽂件三、获取 Cookie四、获取 Header五、存储和获取 Session5.1 存储 Session5.2 获取 Session一、使用 RequestBody 接收JSON对象 有时客户端会通过 post 方式发送 json 格式的请求&#xff0c;那后端就可…

2.3.5双链表

单链表vs双链表 就是既有前驱指针也有后继指针&#xff0c;由line改为double。 双链表的插入怎么实现&#xff1f; s->nextp->next; p->next->priors s->priorp //把p赋给s的前驱指针指向的位置 p->nexts; 如果p刚好是最后一个元素。 p->next->prio…

基于ArcGIS的电子地图矢量化方法

一、电子地图及纸质地图矢量化的目的 地图数据来源有很多&#xff0c;其中栅格数据数字化是地图数据的重要来源。栅格数据的矢量化包括地理配准以及矢量化。矢量化后的地图数据往往可以为我们的空间统计分析提供实验依据&#xff0c;从而探究地理分布的时空差异性。 空间参考&a…

完整指南:如何安装Man手册

Man手册简介 man手册是Unix和类Unix操作系统中的命令行工具&#xff0c;用于提供关于特定命令、函数和文件的帮助文档。它通常包含命令的语法、选项、参数、示例以及其他相关信息。man手册可以通过在终端输入"man"命令&#xff0c;后跟要查看的命令或函数名称来访问…

huggingface transformer模型介绍

总结&#xff1a; 模型提高性能&#xff1a;新的目标函数&#xff0c;mask策略等一系列tricks Transformer 模型系列 自从2017&#xff0c;原始Transformer模型激励了大量新的模型&#xff0c;不止NLP任务&#xff0c;还包括预测蛋白质结构&#xff0c;时间序列预测。 有些模…

灌区流量监测设备-中小灌区节水改造

系统概述 灌区信息化管理系统主要对对灌区的水情、雨情、土壤墒情、气象等信息进行监测&#xff0c;对重点区域进行视频监控&#xff0c;同时对泵站、闸门进行远程控制&#xff0c;实现了信息的测量、统计、分析、控制、调度等功能。为灌区管理部门科学决策提供了依据&#xf…

Python 无监督学习实用指南:6~10

原文&#xff1a;Hands-on unsupervised learning with Python 协议&#xff1a;CC BY-NC-SA 4.0 译者&#xff1a;飞龙 本文来自【ApacheCN 深度学习 译文集】&#xff0c;采用译后编辑&#xff08;MTPE&#xff09;流程来尽可能提升效率。 不要担心自己的形象&#xff0c;只关…

23年5月高项学习笔记12 —— 干系人管理

过程&#xff1a; 1. 识别干系人&#xff1a;定期识别干系人&#xff0c;分析和记录他们的利益&#xff0c;参与度、相互依赖性、影响力和对项目的潜在的影响 输入&#xff1a;立项管理文件、沟通管理计划、干系人参与计划、需求文件、变更日志、问题日志、协议&#xff08;协…

今天给大家介绍一篇基于springboot的医院管理系统的设计与实现

临近学期结束&#xff0c;你还在做java程序网络编程&#xff0c;期末作业&#xff0c;老师的作业要求觉得大了吗?不知道毕业设计该怎么办?网页功能的数量是否太多?没有合适的类型或系统?等等。这里根据疫情当下&#xff0c;你想解决的问题&#xff0c;今天给大家介绍一篇基…

2023/4/10总结

线段树 线段树是一种二叉树&#xff0c;通俗易懂的来说就是对于一个线段&#xff0c;我们会用一个二叉树来表示。线段树是一种工具&#xff0c;她能把对区间&#xff08;线段&#xff09;的修改与维护从0(N)的时间复杂度变成0(logN)。 如图&#xff1a; 如上图&#xff0c;我…

MYSQL SQL语句优化技术技巧

MySQL是一种流行的关系型数据库管理系统&#xff0c;它提供了各种各样的SQL语句优化技术&#xff0c;下面是一些常见的优化技巧&#xff1a; 1. 使用索引 索引可以大大提高查询性能。在MySQL中&#xff0c;可以使用CREATE INDEX语句在列上创建索引。当查询包含WHERE子句并且…

Google SEO 搜索中心

在公司发展还没有那么成熟的时候&#xff0c;也许你的测试网站是外网可以公开访问的&#xff0c;也许你网站中的机密图片在测试环境&#xff08;不小心上到正式环境&#xff09;却被搜索引擎无情抓取&#xff0c;以及有些内部用户才能使用的网址&#xff0c;你并不想被搜索引擎…

明着呼吁暂停,暗着囤积GPU,马斯克暗度陈仓玩得溜

众所周知&#xff0c;此前马斯克纠集了上千名科技工作者对生成式人工智能的深度训练表示了质疑&#xff0c;呼吁暂停继续对深度人工智能的训练&#xff0c;哪怕先暂停六个月。呼吁的尘埃还没有彻底落地&#xff0c;就传出了马斯克已经悄悄地囤积了上万枚GPU&#xff0c;构建自己…

《花雕学AI》15:BingGPT桌面端——尝鲜体验ChatGPT4.0同源技术新Bing的最新成果

引言&#xff1a; 本文将介绍 BingGPT桌面端的开发背景和目的&#xff0c;以及它与新 Bing 的关系和区别。本文还将说明BingGPT桌面端的主要功能和特点&#xff0c;以及如何下载、安装和使用。最后&#xff0c;本文将评价 BingGPT桌面端对于新 Bing 的人工智能聊天功能的推广和…

dolphinscheduler资源中心

资源中心 资源中心介绍 资源中心提供文件管理&#xff0c;UDF管理&#xff0c;任务组管理。 文件管理可以访问要执行的hive的sql文件 UDF管理可以放置fllink执行的自定义udf函数jar包&#xff0c;hive自定义的UDF函数jar包 以上的*.sql,*.jar文件可以理解为资源&#xff0c…

三本小书的前言

所有的事情既是好事也是坏事&#xff0c;人工智能也不例外&#xff1b;所有的事情既是坏事也是好事&#xff0c;人类智慧也不例外。《追问人工智能&#xff1a;从剑桥到北京》前 言一个地方不在大小&#xff0c;关键看有无灵气&#xff0c;剑桥就是这样一个神奇的地方&#xff…

第三章_Redis的十大数据类型

which 10 官网&#xff1a;https://redis.io/docs/data-types/ 一图说明 提前声明 这里说的数据类型是value的数据类型&#xff0c;key的类型都是字符串 十大数据类型分别是 redis字符串&#xff08;String&#xff09; String&#xff08;字符串&#xff09;。 string是…