Closed liguobing closed 1 year ago
理论上用最新的OpenCV4就行,当时最新的版本应该是4.5左右,但是官网的预编译包应该是不带FFmpeg的,如果需要视频处理的话,最好是自己编译OpenCV。
关于O0和gnu++11,可能你引了OpenCV的Debug库,也有可能是你的CMakeFiles里写了相应的SET,单纯的OpenCV库应该是不会自己往编译器加参数的。
然后Core的代码最好不要用release的2.5.0版本,用库里最新的。
哈喽,我又来了 T_T
因为我的需求只是处理图片,所以我就没有自己编译 OpenCV
我是直接使用的 Anime4KCPP_Android CMakeList.txt OpenCV 也是直接在 opencv 的 Releases 下载的。
另外我使用了库里最新的 core 替换了 Anime4KCPP_Android 中的 Anime4KCore 中的文件,但是提示 E:/Work_Space/Anime4KCPP_Android/app/src/main/cpp/Anime4KCore/include\AC.hpp:17:10: fatal error: 'ac_export.h' file not found
ac_export.h 这个头文件又是哪里的呢?
主库最新代码的ac_export.h
是core里面的CMakeLists.txt生成的。
另外Anime4KCPP_Android自带的Anime4KCore不可以直接编译吗?我看你将里面的Anime4KCore替换为了2.5.0 Release的。
clone Anime4KCPP_Android ,然后修改 CMakeLists.txt 中到 OpenCV OpenCL EIGEN3 路径之后,rebuild 出错,提示:
D:/WorkSpace/Android_Studio_workspace/Anime4KCPP_Android/app/src/main/cpp/Anime4KCore/src/VideoProcessor.cpp:76:39: error: no member named 'setprecision' in namespace 'std'
D:/WorkSpace/Android_Studio_workspace/Anime4KCPP_Android/app/src/main/cpp/Anime4KCore/src/VideoProcessor.cpp:77:25: error: no member named 'setw' in namespace 'std'
D:/WorkSpace/Android_Studio_workspace/Anime4KCPP_Android/app/src/main/cpp/Anime4KCore/src/VideoProcessor.cpp:78:43: error: no member named 'setw' in namespace 'std'
D:/WorkSpace/Android_Studio_workspace/Anime4KCPP_Android/app/src/main/cpp/Anime4KCore/src/VideoProcessor.cpp:79:46: error: no member named 'setw' in namespace 'std'
D:/WorkSpace/Android_Studio_workspace/Anime4KCPP_Android/app/src/main/cpp/Anime4KCore/src/VideoProcessor.cpp:89:35: error: no member named 'setprecision' in namespace 'std'
D:/WorkSpace/Android_Studio_workspace/Anime4KCPP_Android/app/src/main/cpp/Anime4KCore/src/VideoProcessor.cpp:90:21: error: no member named 'setw' in namespace 'std'
D:/WorkSpace/Android_Studio_workspace/Anime4KCPP_Android/app/src/main/cpp/Anime4KCore/src/VideoProcessor.cpp:91:39: error: no member named 'setw' in namespace 'std'
上面那个提示是 OpenCV 3.X 的,将 OpenCV SDK 换成 4.8.1 之后,错误提示如下:
D:/WorkSpace/Android_Studio_workspace/Anime4KCPP_Android/app/src/main/cpp/Anime4KCore/src/ACCreator.cpp:40:9: error: no member named 'make_unique' in namespace 'std'
D:/WorkSpace/Android_Studio_workspace/Anime4KCPP_Android/app/src/main/cpp/Anime4KCore/include\ACRegister.hpp:83:27: note: expanded from macro 'PROCESSOR_CASE_UP'
D:/WorkSpace/Android_Studio_workspace/Anime4KCPP_Android/app/src/main/cpp/Anime4KCore/include\ACRegister.hpp:33:20: note: expanded from macro 'PROCESSORS'
D:/WorkSpace/Android_Studio_workspace/Anime4KCPP_Android/app/src/main/cpp/Anime4KCore/include\ACRegister.hpp:62:77: note: expanded from macro '\
D:/WorkSpace/Android_Studio_workspace/Anime4KCPP_Android/app/src/main/cpp/Anime4KCore/src/ACCreator.cpp:40:9: error: expected '(' for function-style cast or type construction
D:/WorkSpace/Android_Studio_workspace/Anime4KCPP_Android/app/src/main/cpp/Anime4KCore/include\ACRegister.hpp:83:27: note: expanded from macro 'PROCESSOR_CASE_UP'
D:/WorkSpace/Android_Studio_workspace/Anime4KCPP_Android/app/src/main/cpp/Anime4KCore/include\ACRegister.hpp:33:20: note: expanded from macro 'PROCESSORS'
D:/WorkSpace/Android_Studio_workspace/Anime4KCPP_Android/app/src/main/cpp/Anime4KCore/include\ACRegister.hpp:62:93: note: expanded from macro '\
D:/WorkSpace/Android_Studio_workspace/Anime4KCPP_Android/app/src/main/cpp/Anime4KCore/src/ACCreator.cpp:40:9: error: no member named 'make_unique' in namespace 'std'
D:/WorkSpace/Android_Studio_workspace/Anime4KCPP_Android/app/src/main/cpp/Anime4KCore/include\ACRegister.hpp:83:27: note: expanded from macro 'PROCESSOR_CASE_UP'
D:/WorkSpace/Android_Studio_workspace/Anime4KCPP_Android/app/src/main/cpp/Anime4KCore/include\ACRegister.hpp:34:36: note: expanded from macro 'PROCESSORS'
D:/WorkSpace/Android_Studio_workspace/Anime4KCPP_Android/app/src/main/cpp/Anime4KCore/include\ACRegister.hpp:62:77: note: expanded from macro '\
D:/WorkSpace/Android_Studio_workspace/Anime4KCPP_Android/app/src/main/cpp/Anime4KCore/src/ACCreator.cpp:40:9: error: expected '(' for function-style cast or type construction
D:/WorkSpace/Android_Studio_workspace/Anime4KCPP_Android/app/src/main/cpp/Anime4KCore/include\ACRegister.hpp:83:27: note: expanded from macro 'PROCESSOR_CASE_UP'
D:/WorkSpace/Android_Studio_workspace/Anime4KCPP_Android/app/src/main/cpp/Anime4KCore/include\ACRegister.hpp:34:36: note: expanded from macro 'PROCESSORS'
D:/WorkSpace/Android_Studio_workspace/Anime4KCPP_Android/app/src/main/cpp/Anime4KCore/include\ACRegister.hpp:62:93: note: expanded from macro '\
D:/WorkSpace/Android_Studio_workspace/Anime4KCPP_Android/app/src/main/cpp/Anime4KCore/src/ACCreator.cpp:40:9: error: no member named 'make_unique' in namespace 'std'
D:/WorkSpace/Android_Studio_workspace/Anime4KCPP_Android/app/src/main/cpp/Anime4KCore/include\ACRegister.hpp:83:27: note: expanded from macro 'PROCESSOR_CASE_UP'
D:/WorkSpace/Android_Studio_workspace/Anime4KCPP_Android/app/src/main/cpp/Anime4KCore/include\ACRegister.hpp:35:32: note: expanded from macro 'PROCESSORS'
D:/WorkSpace/Android_Studio_workspace/Anime4KCPP_Android/app/src/main/cpp/Anime4KCore/include\ACRegister.hpp:4:40: note: expanded from macro '\
<scratch space>:16:1: note: expanded from here
D:/WorkSpace/Android_Studio_workspace/Anime4KCPP_Android/app/src/main/cpp/Anime4KCore/include\ACRegister.hpp:7:39: note: expanded from macro 'REGISTER_PROCESSOR_IF_1'
D:/WorkSpace/Android_Studio_workspace/Anime4KCPP_Android/app/src/main/cpp/Anime4KCore/include\ACRegister.hpp:62:77: note: expanded from macro 'REGISTER_PROCESSOR'
D:/WorkSpace/Android_Studio_workspace/Anime4KCPP_Android/app/src/main/cpp/Anime4KCore/src/ACCreator.cpp:40:9: error: expected '(' for function-style cast or type construction
D:/WorkSpace/Android_Studio_workspace/Anime4KCPP_Android/app/src/main/cpp/Anime4KCore/include\ACRegister.hpp:83:27: note: expanded from macro 'PROCESSOR_CASE_UP'
D:/WorkSpace/Android_Studio_workspace/Anime4KCPP_Android/app/src/main/cpp/Anime4KCore/include\ACRegister.hpp:35:32: note: expanded from macro 'PROCESSORS'
D:/WorkSpace/Android_Studio_workspace/Anime4KCPP_Android/app/src/main/cpp/Anime4KCore/include\ACRegister.hpp:4:40: note: expanded from macro '\
<scratch space>:16:1: note: expanded from here
D:/WorkSpace/Android_Studio_workspace/Anime4KCPP_Android/app/src/main/cpp/Anime4KCore/include\ACRegister.hpp:7:39: note: expanded from macro 'REGISTER_PROCESSOR_IF_1'
D:/WorkSpace/Android_Studio_workspace/Anime4KCPP_Android/app/src/main/cpp/Anime4KCore/include\ACRegister.hpp:62:93: note: expanded from macro 'REGISTER_PROCESSOR'
D:/WorkSpace/Android_Studio_workspace/Anime4KCPP_Android/app/src/main/cpp/Anime4KCore/src/ACCreator.cpp:40:9: error: no member named 'make_unique' in namespace 'std'
D:/WorkSpace/Android_Studio_workspace/Anime4KCPP_Android/app/src/main/cpp/Anime4KCore/include\ACRegister.hpp:83:27: note: expanded from macro 'PROCESSOR_CASE_UP'
D:/WorkSpace/Android_Studio_workspace/Anime4KCPP_Android/app/src/main/cpp/Anime4KCore/include\ACRegister.hpp:36:55: note: expanded from macro 'PROCESSORS'
D:/WorkSpace/Android_Studio_workspace/Anime4KCPP_Android/app/src/main/cpp/Anime4KCore/include\ACRegister.hpp:4:40: note: expanded from macro '\
<scratch space>:19:1: note: expanded from here
D:/WorkSpace/Android_Studio_workspace/Anime4KCPP_Android/app/src/main/cpp/Anime4KCore/include\ACRegister.hpp:7:39: note: expanded from macro 'REGISTER_PROCESSOR_IF_1'
D:/WorkSpace/Android_Studio_workspace/Anime4KCPP_Android/app/src/main/cpp/Anime4KCore/include\ACRegister.hpp:62:77: note: expanded from macro 'REGISTER_PROCESSOR'
因为很久没搞了,一些细节我可能遗忘了,所以我自己试了一下,直接clone Anime4KCPP_Android然后编译,一切正常,未发生上述报错。
我的环境:
编译过程:clone后直接Android Studio打开项目,此时自动下载gradle7.0.2和ndk 21,因为最新AS自带java版本太新的问题会报错提示让升级gradle,自动升级就行,去设置好CMake里依赖的路径之后可以直接编译,不需要额外操作。
上面提到的OpenCL头文件问题,我用的的头文件是编译OpenCL SDK项目后生成的,理论上就是OpenCL-Headers和OpenCL-CLHPP里的头文件,应该可以直接从这两个项目下载放在一起就行,不需要先编译一遍SDK。
对比,我觉得您的问题可能在于opencl,在此提供一份我使用的opencl库供测试: opencl.zip
顺便测试了一下把ndk升级到比较新的25版本也可以正常编译。
不知道该用什么语言来形容了,白天整整折腾了一天,就差重装电脑了,按照您到步骤一步一步操作,却始终还是出错
晚上回家继续折腾,莫名其妙到好了,回想之前到操作,应该是又升级了一次 gradle
现在的 gradle 及插件版本分别是 7.5/7.4.2
最后祝您备考成功,好运连连!
后经过google查询,有人说可能是 OpenCV 的版本问题,按照 https://github.com/TianZerL/Anime4KCPP/wiki/Building 上的提示,OpenCV 3.0 并没有提供 Android sdk,遂下载了 OpenCV 3.1 重新 rebuild 之后,
-std=gnu++11
错误提示消失了,但 -O0 依旧存在,并且错误提示也发生了变化,所以可能问题是出在 OpenCV 的版本上,所以麻烦请问您编译成功的 OpenCV 是哪个版本呢?整体错误提示如下:
Originally posted by @liguobing in https://github.com/TianZerL/Anime4KCPP/issues/107#issuecomment-1794958540