Automatic image cropping

Hello everyone!
given my extreme ignorance in the field of programming, and after several attempts to search the web for software that meet my needs, I find myself having to ask for help.
I would like to find a way to take photos via webcam or other acquisition device, crop them and rename them automatically, I mean, the fixed webcam and using a neutral background such as a colored card, placing an object to be photographed in the center (in my case they are books ), I would like to obtain as a result an image created with a frame (cardboard) in percentage or a few px, so that they adapt everything to the size of the photographer without having to “zoom” or move the webcam manually every time I photograph a book different in size from the previous one. to all this I would like it to be possible, less difficult, to associate a barcode type number in order to take the photo and save it by naming it with the barcode
could you help me find a solution?
I’ve used google translate
Thanks !!