0

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~

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.

asked Apr 19, 2024 at 7:57
3
  • Seems like a bug, but not in your code. Have you checked the according bugtracker? Commented Apr 19, 2024 at 9:24
  • What version of OpenCV is this? CV_WRAP_FILE_PATH was introduced in January 2024 and the last release was in December. Are you mixing the 4.9.0 OpenCV release with header files pulled from git or what? Commented Apr 19, 2024 at 9:46
  • Soga,my openCV version is 4.7.0 ,I use this macro definition " CV_WRAP_FILE_PATH" because I noticed that in someone else's project, the objdetect.hpp file was included. However, when I include this file in my project, even without adding any code, I get errors. Commented Apr 22, 2024 at 6:17

0

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.