I left some explanations in code for better understanding.
i used python 3.7 with pycharm.
if you do copy-paste it may give some error because of the structer so better write it yourself.
dont forget to install your libraries by using pip or pycharm interpreter.
everything should be in same folder also taken pictures will save in that folder too.