Suggest a solution: the webcam looks at the field where the dice is thrown. It is necessary to recognize which number fell on the dice (number of dots).
I recommend using the openCV library (available in c++ and python).
The algorithm is approximately the following:
1. Thresholding.
2. Search for connected segments.
3. Filtering the found segments according to certain criteria.
4. Counting the remaining segments