fatal error: ‘opencv2/opencv.hpp’ file not found in VS Code in M1 MacBook Air

  apple-m1, c++, opencv, visual-studio-code

I downloaded opencv on my Mac using brew install opencv
and this is the path


then I tried the following code in VS Code

#include <iostream>
using namespace std;
#include <opencv2/opencv.hpp>
int main() {
    cout << "!";

but there is a problem:

Executing task: /usr/bin/clang++ -g /Users/zdw/vscode/configure.cpp -o /Users/zdw/vscode/configure.out <

/Users/zdw/vscode/configure.cpp:3:10: fatal error: 'opencv2/opencv.hpp' file not found

I entered pkg-config --cflags --libs opencv in the terminal and it says

Package opencv was not found in the pkg-config search path.
Perhaps you should add the directory containing `opencv.pc'
to the PKG_CONFIG_PATH environment variable
No package 'opencv' found

and now I don’t know what to do.

Source: Windows Questions C++