How to use "FaceDetectorYN"

Receiving the error FaceDetectorYN was not delcared in the scope.

tried to execute following C++ sample code

using OpenCV 4.5.3

for using OpenCV with extra modules. done the following too

$ cd <opencv_build_directory>
$ cmake -DOPENCV_EXTRA_MODULES_PATH=<opencv_contrib>/modules <opencv_source_directory>
$ make -j5
$ sudo make install

you do not need any contrib modules for this,

but a more recent opencv version (4.5.3 does not have this class)

then, try the sample here

Still receiving following error. Tried new sample code mentioned by you

/home/john/Qt Applications/faceDetection2/main.cpp:74: error: ‘FaceDetectorYN’ was not declared in this scope
…/faceDetection2/main.cpp: In function ‘int main(int, char**)’:
…/faceDetection2/main.cpp:74:9: error: ‘FaceDetectorYN’ was not declared in this scope
Ptr detector = FaceDetectorYN::create(fd_modelPath, “”, Size(320, 320), scoreThreshold, nmsThreshold, topK);

again, 4.5.3 does not have it, update