module ‘cv2’ has no ‘videocapture’ member python


Here is what the above code is Doing:
1. We are importing the cv2 module.
2. We are reading the image using the imread() function. The first argument is the path to the image. The second argument is a flag which specifies the way image should be read.
3. cv2.IMREAD_COLOR : Loads a color image. Any transparency of image will be neglected. It is the default flag.
4. cv2.IMREAD_GRAYSCALE : Loads image in grayscale mode
5. cv2.IMREAD_UNCHANGED : Loads image as such including alpha channel
Note Instead of these three flags, you can simply pass integers 1, 0 or -1 respectively.

4. We are displaying the image using the imshow() function. The first argument is the window name which is a string. The second argument is our image. You can create as many windows as you wish, but with different window names.
5. Then we wait for a keystroke using the waitKey() function. The argument is a time in milliseconds. The function waits for specified milliseconds for any keyboard event. If you press any key in that time, the program continues. If 0 is passed, it waits indefinitely for a key stroke. It can also be set to detect specific key strokes like, if key a is pressed etc which we will discuss below.
6. Finally, we are destroying all the windows that are created. If you want to destroy any specific window, use the function cv2.destroyWindow() where you pass the exact window name as the argument.