macOS camera 'not authorized' error means terminal lacks camera permission
When OpenCV's VideoCapture on macOS prints 'not authorized to capture video (status 0)' and 'camera failed to properly initialize' for every index, the shell is blocked by privacy settings, not by a wrong index. Allow the terminal app (Terminal, iTerm, VS Code, Cursor) under System Settings > Privacy & Security > Camera, then restart that app. Trigger the permission prompt by running a capture once, and ask the user to click Allow.
If the user previously clicked Don't Allow, the prompt won't reappear; reset it with 'tccutil reset Camera <bundle id>' (e.g. com.apple.Terminal, com.googlecode.iterm2) and rerun the capture. Permission is attributed to the responsible GUI app, so a script launched from an IDE or agent host needs that host app allowed, not python.