Reason: the cmakelists.txt file does not specify the DNN module, so the statement
find_package(OpenCV 4 REQUIRED opencv_core opencv_imgproc opencv_highgui opencv_calib3d opencv_videoio opencv_imgcodecs )
To be amended as follows:
find_package(OpenCV 4 REQUIRED)
It can be compiled.