i know this question has been asked before but i can’t understand their explanation. i am completely new to coding , help if you can.
here is my file image:
here is my task jason files:
{
"version": "2.0.0",
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: g++ build active file",
"command": "/usr/bin/g++",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}",
"`pkg-config",
"--cflags",
"--libs",
"opencv4`"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "compiler: /usr/bin/g++"
}
]
}
and here is my CMakeLists.txt:
cmake_minimum_required(VERSION 3.10)
project(ObjectDetection)
set(OpenCV_DIR C:/Users/prana/OneDrive/Desktop/last_attempt/opencv)
find_package(OpenCV REQUIRED)
add_executable(${PROJECT_NAME} src/Main.cpp)
target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBS})
2
Answers
Try adding
/build
to changeto
The error:
The error you describe is a result of executing a line of code attempting to access the file
opencv2/opencv.hpp
. Since this extension ishpp
, it is a header file: simply put, header files help different files within the source code all share the same core variables. The error associated with failure to access a header file likely occurs in the preamble of one of theopencv2
source files.In general, when implementing downloaded source code, this is the result of failure to configure the file structure in the expected way (assuming you downloaded everything). Make sure to check that you have both OpenCV_contrib AS WELL AS OpenCV.
Solution:
Make sure that your ‘/build’ path is included.
Since this question is already answered in a very thorough manner (by Faisal_L), for a particular solution I direct you to follow the instructions they laid out below.
https://stackoverflow.com/a/73186585/21977063