Error: ‘CV_WRAP_FILE_PATH’ has not been declared

when I add #include “opencv2/objdetect.hpp” , there is a wrong :“/usr/include/opencv2/objdetect/face.hpp:85:47: error: ‘CV_WRAP_FILE_PATH’ has not been declared
85 | CV_WRAP static Ptr create(CV_WRAP_FILE_PATH const String& model,
| ^~~~~~~~~~~~~~~~~
/usr/include/opencv2/objdetect/face.hpp:85:77: error: expected ‘,’ or ‘…’ before ‘&’ token
85 | CV_WRAP static Ptr create(CV_WRAP_FILE_PATH const String& model,
| ^
In file included from /usr/include/opencv2/objdetect.hpp:869,
from /home/zero/openCV/chip_phytium/with_opencv/include/cv_zone.h:5,
from /home/zero/openCV/chip_phytium/with_opencv/src/cv_zone_chapter2_3_4.cpp:1:
/usr/include/opencv2/objdetect/face.hpp:157:49: error: ‘CV_WRAP_FILE_PATH’ has not been declared
157 | CV_WRAP static Ptr create(CV_WRAP_FILE_PATH const String& model, CV_WRAP_FILE_PATH const String& config, int backend_id = 0, int target_id = 0);
| ^~~~~~~~~~~~~~~~~
/usr/include/opencv2/objdetect/face.hpp:157:79: error: expected ‘,’ or ‘…’ before ‘&’ token
157 | CV_WRAP static Ptr create(CV_WRAP_FILE_PATH const String& model, CV_WRAP_FILE_PATH const String& config, int backend_id = 0, int target_id = 0);
| ^”

so i check the file “cvdef.h” don`t find the definition ,it only have
#define CV_WRAP
#define CV_WRAP_AS(synonym)
#define CV_WRAP_MAPPABLE(mappable)
#define CV_WRAP_PHANTOM(phantom_header)
#define CV_WRAP_DEFAULT(val)

my codes as follows:

// main.cpp
#include <opencv2/core/core.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/opencv.hpp>
#include “opencv2/objdetect.hpp”

void cv_zone_face_detection()
{
string path = “…/peripheral/cv_zone/Resources/test.png”;
Mat img = imread(path);

// CascadeClassifier face_cascade;
// face_cascade.load("../peripheral/cv_zone/Resources/haarcascade_frontalface_default.xml");

// if (face_cascade.empty()) {
//     cout << "Cascade file not loaded" << endl;
// }

imshow("Image", img);
waitKey(0);

}

my CMakeLists.txt as follows:
// CMakeLists.txt
cmake_minimum_required(VERSION 3.16.3)
Project(opencv_SDK_phytium)
option(RUNNING_OPENCV “Build with OpenCV” ON)
if(DEFINED RUNNING_OPENCV)
if(RUNNING_OPENCV)
message(“Build with OpenCV”)
find_package(OpenCV REQUIRED)
# opencv 官方库文件
include_directories(${OpenCV_INCLUDE_DIRS})
# 自定义文件
include_directories(with_opencv/include)
aux_source_directory (with_opencv/src SRC_LIST)
else()
message(“Build without OpenCV”)
ADD_DEFINITIONS(-DCLOSE_OPENCV)
endif()
endif()

set(CMAKE_THREAD_LIBS_INIT “-lpthread”)
SET(CMAKE_CXX_FLAGS “${CMAKE_CXX_FLAGS} -pthread”)
set(CMAKE_HAVE_THREADS_LIBRARY 1)
set(CMAKE_USE_WIN32_THREADS_INIT 0)
set(CMAKE_USE_PTHREADS_INIT 1)
set(THREADS_PREFER_PTHREAD_FLAG ON)

include_directories(include)
aux_source_directory (src SRC_LIST)
add_executable(vedio_opencv main.cpp {SRC_LIST}) if(RUNNING_OPENCV) target_link_libraries(vedio_opencv {OpenCV_LIBS})

endif()

I would appreciate it if you helped me~
[/quote]

my CMakeLists.txt as follows:

CMakeLists.txt

cmake_minimum_required(VERSION 3.16.3)
Project(opencv_SDK_phytium)
option(RUNNING_OPENCV “Build with OpenCV” ON)
if(DEFINED RUNNING_OPENCV)
if(RUNNING_OPENCV)
message(“Build with OpenCV”)
find_package(OpenCV REQUIRED)
# opencv 官方库文件
include_directories(${OpenCV_INCLUDE_DIRS})
# 自定义文件
include_directories(with_opencv/include)
aux_source_directory (with_opencv/src SRC_LIST)
else()
message(“Build without OpenCV”)
ADD_DEFINITIONS(-DCLOSE_OPENCV)
endif()
endif()

set(CMAKE_THREAD_LIBS_INIT “-lpthread”)
SET(CMAKE_CXX_FLAGS “${CMAKE_CXX_FLAGS} -pthread”)
set(CMAKE_HAVE_THREADS_LIBRARY 1)
set(CMAKE_USE_WIN32_THREADS_INIT 0)
set(CMAKE_USE_PTHREADS_INIT 1)
set(THREADS_PREFER_PTHREAD_FLAG ON)

include_directories(include)
aux_source_directory (src SRC_LIST)
add_executable(vedio_opencv main.cpp ${SRC_LIST})

if(RUNNING_OPENCV)
target_link_libraries(vedio_opencv ${OpenCV_LIBS})
endif()

I would appreciate it if you helped me~

Something is wrong in your clone repo :

may be git pull is necessary and rebuid opencv

It was created in python: accept path-like objects wherever file names are expected by tailsu · Pull Request #24773 · opencv/opencv · GitHub

Can I just replace this file? I noticed that it is generated by dnn.cpp. Wouldn’t this have the same effect?

Can I just replace this file? I noticed that it is generated by dnn.cpp. Wouldn’t this have the same effect?

Of course you can replace but why this file is not up to date? May be some files are depreceated too and can introduce error in your code.

I’m not quite sure why this issue has occurred. When I installed OpenCV, I remember not including some Java modules because it seemed that this macro definition was related to them. I’m wondering if this might be the cause. Is there any way to automatically generate this definition?

Additionally, this macro definition is used within the class CV_EXPORTS_W_SIMPLE Net , and it is located in the /opencv2/dnn/dnn.cpp file.