From 0af660549849bbe33dfeda66fa7fee650a904fbc Mon Sep 17 00:00:00 2001 From: Dev Singh Kanyal <77870205+dev-singh-kanyal@users.noreply.github.com> Date: Sun, 26 Feb 2023 01:50:45 +0530 Subject: [PATCH 1/3] Added error handling for video capture in OpenCV code ret is a boolean variable returned by the cap.read() function. This function reads the next frame from the video file or camera, and returns True if a frame is successfully read and False if it fails to read a frame. Therefore, the if not ret condition checks if the frame was successfully read. If the frame was not read (i.e. ret is False), it breaks out of the while loop using the break statement. This is necessary because if there are no more frames to read from the video file, the loop should exit gracefully. --- docs/intro/intro.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/intro/intro.rst b/docs/intro/intro.rst index 26a6d26..7d6b7d6 100644 --- a/docs/intro/intro.rst +++ b/docs/intro/intro.rst @@ -95,6 +95,8 @@ and then loop back. The loop finishes when **q** is pressed:: while True: # Capture frame-by-frame ret, frame = cap.read() + if not ret: + break # Our operations on the frame come here gray = cv.cvtColor(frame, cv.COLOR_BGR2GRAY) @@ -344,4 +346,4 @@ Mouse callback:: cb(evt, x, y, flags, param) cv.createTrackbar('name', 'win', 0, max, cb) - cv.getTrackbarPos('name', 'win') \ No newline at end of file + cv.getTrackbarPos('name', 'win') From 2572052277f3a662cd00431690c5289053b91551 Mon Sep 17 00:00:00 2001 From: Dev Singh Kanyal <77870205+dev-singh-kanyal@users.noreply.github.com> Date: Sun, 26 Feb 2023 01:54:19 +0530 Subject: [PATCH 2/3] Add check for successful video frame capture ret is a boolean variable returned by the cap.read() function. This function reads the next frame from the video file or camera, and returns True if a frame is successfully read and False if it fails to read a frame. Therefore, the if not ret condition checks if the frame was successfully read. If the frame was not read (i.e. ret is False), it breaks out of the while loop using the break statement. This is necessary because if there are no more frames to read from the video file, the loop should exit gracefully. --- docs/intro/intro2.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/intro/intro2.py b/docs/intro/intro2.py index df242c7..6adb8ec 100644 --- a/docs/intro/intro2.py +++ b/docs/intro/intro2.py @@ -6,6 +6,8 @@ while True: # Capture frame-by-frame ret, frame = cap.read() + if not ret: + break # Our operations on the frame come here gray = cv.cvtColor(frame, cv.COLOR_BGR2GRAY) @@ -17,4 +19,4 @@ # When everything done, release the capture cap.release() -cv.destroyAllWindows() \ No newline at end of file +cv.destroyAllWindows() From a838e37104b902e07cc487e5a64ab3299061c691 Mon Sep 17 00:00:00 2001 From: Dev Singh Kanyal <77870205+dev-singh-kanyal@users.noreply.github.com> Date: Sat, 4 Nov 2023 18:34:30 +0530 Subject: [PATCH 3/3] docs: Update README to indicate repository is archived MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit README updated to reflect repository’s archived status. --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0c31e71..5325753 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # opencv-tutorial +**Please note: This repository is now archived and will no longer be updated or maintained.** + This is an introduction to object-oriented Programming (OOP) to OpenCV. -Check-out the online documentation: https://opencv-tutorial.readthedocs.io \ No newline at end of file +Check-out the online documentation: https://opencv-tutorial.readthedocs.io