Problem in opencv : generation of selfie training data using webcam

The link to code is -

When I run my code on command prompt, it runs successfully. But, on pressing ‘q’ to stop the implementation of code, it does not stop. It keeps on running. Eventually, I have to close command prompt itself to stop the code.

Please tell the error

hey @abhaygarg2001 ,
it isn’t any error , actually the thing is that python scripts are generally made for automating stuff , hence from command prompt it doesn’t allow any kind of interruption like from a key or something like this as you want to , because it thinks like you have run something which need to be stopped when it is done.
In place of it, what you can do is, after a particular number of images are saved then you can ask the user whether of he or she want to store more or not. Depending on the answer , you can mode forward or stop it there it self.

I hope this would resolve your doubt.

hey @abhaygarg2001 ,

we see that you have re-opened this doubt , is there anything left regarding this doubt ? You can ask here.