What cap.read() returns is a boolean (True/False) and image content. If you remove success, the img variable takes that boolean and image data as a tuple. This is why you get an error.

.read() in OpenCV returns 2 things, boolean and data. If there are not 2 variables, a tuple will be assigned to one variable. The boolean is mostly used for error catching. Assigning a tuple to 1 var with 2 data items can sometimes be useful, but in this instance, you should create 2 vars and split the data into 2 variables to make it easier.

If you do not want to assign the bool to a var, you can use _ as the variable name.

Answer from Trooper Z on Stack Overflow
๐ŸŒ
LearnOpenCV
learnopencv.com โ€บ home โ€บ image processing โ€บ reading and writing videos using opencv
Reading and Writing Videos using OpenCV | LearnOpenCV
October 15, 2025 - Learn Reading and Writing Videos using OpenCV. We discuss reading videos from file, image sequence, and webcam using OpenCV and also their syntax and options.
Subscribe
Master Computer Vision, Deep Learning, and AI with expert tutorials, code examples, and guides. Learn OpenCV in Python & C++ โ€” from beginner to advanced.
About
It is my goal to publish material that helps readers grasp Computer Vision and Machine Learning concepts with the help of examples in Python and C++. I hope you find this blog useful, informative, and entertaining. You can subscribe to our email newsletter and receive a free Computer Vision Resource guide. The newsletter will come to you weekly with OpenCV ...
Getting Started with OpenCV
A series of tutorial for getting started in OpenCV - the biggest computer vision library in the world. Learn to build real world application in just a few hours!
Tensorflow & Keras
At Learnopencv.com, we have adopted a mission of spreading awareness and educating a global workforce in Artificial Intelligence. Taking a step further in that direction, we have started creating tutorials for getting started in Deep Learning with Keras. We hope that this will be helpful for ...
๐ŸŒ
OpenCV
docs.opencv.org โ€บ 4.13.0 โ€บ d4 โ€บ da8 โ€บ group__imgcodecs.html
OpenCV: Image file reading and writing
The imread function loads an image from the specified file and returns OpenCV matrix. If the image cannot be read (because of a missing file, improper permissions, or unsupported/invalid format), the function returns an empty matrix.
๐ŸŒ
Medium
medium.com โ€บ analytics-vidhya โ€บ read-image-using-cv2-imread-opencv-python-idiot-developer-4b7401e76c20
Read Image using cv2.imread() โ€” OpenCV Python โ€” Idiot Developer | by Nikhil Tomar | Analytics Vidhya | Medium
January 23, 2024 - To use OpenCV in Python install the following libraries: ... To install the above libraries, use the following command. ... Here, we are going to import all the required libraries. ... To read an image cv2.imread() function is used.
๐ŸŒ
YouTube
youtube.com โ€บ watch
Reading and Writing Videos using OpenCV - YouTube
๐Ÿ“š Blog post Link: https://learnopencv.com/reading-and-writing-videos-using-opencv/๐Ÿ“š Check out our FREE Courses at OpenCV University : https://opencv.org/un
Published: February 12, 2024
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ reading-image-opencv-using-python
Reading an image in OpenCV using Python - GeeksforGeeks
August 12, 2024 - Example #1 (Using OpenCV) : ... # Python code to read image import cv2 # To read image from disk, we use # cv2.imread function, in below method, img = cv2.imread("geeksforgeeks.png", cv2.IMREAD_COLOR) # Creating GUI window to display an image on screen # first Parameter is windows title (should be in string format) # Second Parameter is image array cv2.imshow("image", img) # To hold the window on screen, we use cv2.waitKey method # Once it detected the close input, it will release the control # To the next line # First Parameter is for holding screen for specified milliseconds # It should be positive integer.
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ opencv โ€บ opencv_reading_images.htm
OpenCV - Reading Images
The read() method of the Imgcodecs class is used to read an image using OpenCV.
๐ŸŒ
LearnOpenCV
learnopencv.com โ€บ home โ€บ image processing โ€บ read, display and write an image using opencv
Read, Display and Write an Image using OpenCV - LearnOpenCV
July 31, 2026 - Letโ€™s begin by importing the OpenCV library in Python and C++ (as shown below). ... In C++, use #include (as shown below) to accomplish the same. Also specifying the namespaces for it lets you refer to function names directly. No need to prepend them with the namespace (e.g. instead of cv::imread(), you can just directly use read()).
Find elsewhere
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ reading-image-opencv-using-python
Reading and Displaying Images in Python using OpenCV - GeeksforGeeks
November 11, 2025 - OpenCV provides functions like cv2.imread() and cv2.imshow() that make it easy to load images from files and display them in a window.
๐ŸŒ
MachineLearningMastery
machinelearningmastery.com โ€บ home โ€บ blog โ€บ how to read and display videos using opencv
How to Read and Display Videos Using OpenCV - MachineLearningMastery.com
January 30, 2024 - Digital videos are close relatives of digital images because they are made up of many digital images sequentially displayed in rapid succession to create the effect of moving visual data. The OpenCV library provides several methods to work with videos, such as reading video data from different sources and accessing several of their properties.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ opencv-python-tutorial
OpenCV Tutorial in Python - GeeksforGeeks
OpenCV (Open Source Computer Vision Library) is an open-source computer vision and machine learning library. It allows us to process images and videos, detect objects, faces and even handwriting. This tutorial will guide us through image and video processing from the basics to advanced topics using Python and OpenCV.
Published: July 12, 2025
๐ŸŒ
OpenCV
opencv.org โ€บ home โ€บ news โ€บ reading and writing videos using opencv
Reading and Writing Videos using OpenCV
March 28, 2025 - We are assuming that you have already installed OpenCV on your device. If not please refer the relevant links below: ... VideoCapture() โ€“ This function is used to read video files, capture frames from a webcam, or process video streams frame by frame.
๐ŸŒ
OpenCV
opencv.org โ€บ home โ€บ news โ€บ read, display and write an image using opencv
Read, Display and Write an Image using OpenCV
March 28, 2025 - OpenCV is an open-source computer vision library that provides a robust set of tools for handling images and videos. Among its many functionalities, it offers essential methods to read, display, and write images, making it a crucial library for various image-processing applications.
๐ŸŒ
Towards Data Science
towardsdatascience.com โ€บ home โ€บ data science โ€บ how to read images, video, webcam and screen in opencv - image analysis for beginners
How to read images, video, webcam and screen in OpenCV - image analysis for beginners | Towards Data Science
January 14, 2022 - Next we go about "filming" our screen. We can use this for analyzing the images we see on the screen (we'll get into this later). Lastly we'll start reading images from our webcam and from a video file. First we import OpenCV on line 1 (cv2 is OpenCV's module name in the Python implementation).
๐ŸŒ
LearnOpenCV
learnopencv.com โ€บ home โ€บ read, write and display a video using opencv
Read, Write and Display a video using OpenCV | LearnOpenCV
July 31, 2026 - A tutorial on how to read, write and display a video using OpenCV. OpenCV-Python and OpenCV-C++ Code is provided for practice and understanding.
๐ŸŒ
OpenCV
docs.opencv.org โ€บ 3.4.20 โ€บ d8 โ€บ dfe โ€บ classcv_1_1VideoCapture.html
OpenCV: cv::VideoCapture Class Reference
The method/function combines VideoCapture::grab() and VideoCapture::retrieve() in one call. This is the most convenient method for reading video files or capturing data from decode and returns the just grabbed frame.
๐ŸŒ
TutorialKart
tutorialkart.com โ€บ opencv โ€บ python โ€บ opencv-python-read-display-image
Read and Display an Image using OpenCV in Python
June 29, 2026 - cv2.imshow() is intended for desktop environments where OpenCV can create a GUI window. In headless environments such as many servers, containers, or some online notebooks, the window may not open. In such cases, save the image using cv2.imwrite() or display it with notebook-friendly plotting tools. In the following Python program, we read an image at the location '/home/img/python.png', and then display the image in a separate window.
๐ŸŒ
OpenCV
docs.opencv.org โ€บ 4.13.0 โ€บ db โ€บ deb โ€บ tutorial_display_image.html
OpenCV: Getting Started with Images
As a first step, the OpenCV python library is imported. The proper way to do this is to additionally assign it the name cv, which is used in the following to reference the library. ... Now, let's analyze the main code. As a first step, we read the image "starry_night.jpg" from the OpenCV samples.
๐ŸŒ
Kaggle
kaggle.com โ€บ code โ€บ zeeshanlatif โ€บ reading-and-writing-videos-with-opencv
Reading and Writing Videos with OpenCV
March 16, 2024 - Introduction1. Reading a Video File2. Processing Video Frames3. Writing the Video4.
๐ŸŒ
LearnOpenCV
learnopencv.com โ€บ home โ€บ read an image in opencv ( python, c++ )
Read an Image in OpenCV ( Python, C++ ) | LearnOpenCV
October 23, 2025 - OpenCV C++ and Python examples for reading images (imread). Load color or grayscale JPG, transparent PNG / TIFF, and 16-bit / channel images.