To follow the chapter with ease, it is required that you install OpenCV with the deep learning module compiled. If you do not have this module, you will not be able to compile and run the sample codes.
It's very useful to have an NVIDIA GPU with CUDA support. You can enable CUDA on OpenCV to improve the speed of training and detection.
Finally, you can download the code used in this chapter from https://github.com/PacktPublishing/Learn-OpenCV-4-By-Building-Projects-Second-Edition/tree/master/Chapter_12.
Check out the following video to see the Code in Action:
http://bit.ly/2SmbWf7