title
OpenCV Python Tutorial For Beginners 3 - How to Read, Write, Show Images in OpenCV

description
In this video on OpenCV Python Tutorial For Beginners, I am going to show How to Read, Write, Show Images in OpenCV. we will se how to use cv2.imread('lena.jpg', -1) to read and image, cv2.imshow('image', img) to show an image in a window, cv2.waitKey(0) to wait for a key event, cv2.destroyAllWindows() to destroy all windows, cv2.imwrite('lena_copy.png', img) to write images to file. OpenCV github page https://github.com/opencv/opencv Gist of code I used in this video - http://www.codebind.com/python/opencv-python-tutorial-beginners-read-write-show-images-opencv/ Install PyCharm ( Python IDE ) on Windows 10 + First Project - https://www.youtube.com/watch?v=cHa85et7LK0&list=PLS1QulWo1RIYt4e0WnBp-ZjCNq8X0FX0J&index=9&t=0s Read an image cv2.imread() Second argument is a flag which specifies the way image should be read. flag integer value description cv2.IMREAD_COLOR 1 Loads a color image. cv2.IMREAD_GRAYSCALE 0 Loads image in grayscale mode cv2.IMREAD_UNCHANGED -1 Loads image as such including alpha channel pip is a package management system used to install and manage software packages written in Python. OpenCV is an image processing library created by Intel and later supported by Willow Garage and now maintained by Itseez. opencv is available on Mac, Windows, Linux. Works in C, C++, and Python. it is Open Source and free. opencv is easy to use and install. Starting with an overview of what the course will be covering, we move on to discussing morphological operations and practically learn how they work on images. We will then learn contrast enhancement using equalization and contrast limiting. Finally we will learn 3 methods to subtract the background from the video and implement them using OpenCV. At the end of this course, you will have a firm grasp of Computer Vision techniques using OpenCV libraries. This course will be your gateway to the world of data science. Feel the real power of Python and programming! The course offers you a unique approach of learning how to code by solving real world problems. #ProgrammingKnowledge #ComputerVision #OpenCV ★★★Top Online Courses From ProgrammingKnowledge ★★★ Python Programming Course ➡️ http://bit.ly/2vsuMaS ⚫️ http://bit.ly/2GOaeQB Java Programming Course ➡️ http://bit.ly/2GEfQMf ⚫️ http://bit.ly/2Vvjy4a Bash Shell Scripting Course ➡️ http://bit.ly/2DBVF0C ⚫️ http://bit.ly/2UM06vF Linux Command Line Tutorials ➡️ http://bit.ly/2IXuil0 ⚫️ http://bit.ly/2IXukt8 C Programming Course ➡️ http://bit.ly/2GQCiD1 ⚫️ http://bit.ly/2ZGN6ej C++ Programming Course ➡️ http://bit.ly/2V4oEVJ ⚫️ http://bit.ly/2XMvqMs PHP Programming Course ➡️ http://bit.ly/2XP71WH ⚫️ http://bit.ly/2vs3od6 Android Development Course ➡️ http://bit.ly/2UHih5H ⚫️ http://bit.ly/2IMhVci C# Programming Course ➡️ http://bit.ly/2Vr7HEl ⚫️ http://bit.ly/2W6RXTU JavaFx Programming Course ➡️ http://bit.ly/2XMvZWA ⚫️ http://bit.ly/2V2CoAi NodeJs Programming Course ➡️ http://bit.ly/2GPg7gA ⚫️ http://bit.ly/2GQYTQ2 Jenkins Course For Developers and DevOps ➡️ http://bit.ly/2Wd4l4W ⚫️ http://bit.ly/2J1B1ug Scala Programming Tutorial Course ➡️ http://bit.ly/2PysyA4 ⚫️ http://bit.ly/2PCaVj2 Bootstrap Responsive Web Design Tutorial ➡️ http://bit.ly/2DFQ2yC ⚫️ http://bit.ly/2VoJWwH MongoDB Tutorial Course ➡️ http://bit.ly/2LaCJfP ⚫️ http://bit.ly/2WaI7Ap QT C++ GUI Tutorial For Beginners ➡️ http://bit.ly/2vwqHSZ ★★★ Online Courses to learn ★★★ Get 2 FREE Months of Unlimited Classes from skillshare - https://skillshare.eqcm.net/r1KEj Data Science - http://bit.ly/2lD9h5L | http://bit.ly/2lI8wIl Machine Learning - http://bit.ly/2WGGQpb | http://bit.ly/2GghLXX Artificial Intelligence - http://bit.ly/2lYqaYx | http://bit.ly/2NmaPya MERN Stack E-Degree Program - http://bit.ly/2kx2NFe | http://bit.ly/2lWj4no DevOps E-degree - http://bit.ly/2k1PwUQ | http://bit.ly/2k8Ypfy Data Analytics with R - http://bit.ly/2lBKqz8 | http://bit.ly/2lAjos3 AWS Certification Training - http://bit.ly/2kmLtTu | http://bit.ly/2lAkQL1 Projects in Java - http://bit.ly/2kzn25d | http://bit.ly/2lBMffs Machine Learning With TensorFlow - http://bit.ly/2m1z3AF | http://bit.ly/2lBMhnA Angular 8 - Complete Essential Guide - http://bit.ly/2lYvYRP Kotlin Android Development Masterclass - http://bit.ly/2GcblsI Learn iOS Programming Building Advance Projects - http://bit.ly/2kyX7ue ★★★ Follow ★★★ My Website - http://www.codebind.com DISCLAIMER: This video and description contains affiliate links, which means that if you click on one of the product links, I’ll receive a small commission. This help support the channel and allows us to continue to make videos like this. Thank you for the support!

detail
{'title': 'OpenCV Python Tutorial For Beginners 3 - How to Read, Write, Show Images in OpenCV', 'heatmap': [{'end': 60.655, 'start': 35.675, 'weight': 0.776}, {'end': 276.166, 'start': 234.96, 'weight': 0.721}, {'end': 308.361, 'start': 276.926, 'weight': 0.719}], 'summary': 'Learn how to install opencv for python using pycharm ide, read and write images with cv2, access sample images from opencv repository, handle python file operations, display images using cv2.imshow method, and control image window with wait key method for a specified duration.', 'chapters': [{'end': 153.436, 'segs': [{'end': 26.946, 'src': 'embed', 'start': 0.851, 'weight': 2, 'content': [{'end': 5.834, 'text': 'hey guys, welcome to the next video on opencv tutorial for beginners using python.', 'start': 0.851, 'duration': 4.983}, {'end': 10.316, 'text': 'in the last video we have seen how we can install opencv for python.', 'start': 5.834, 'duration': 4.482}, {'end': 13.878, 'text': 'now, from this video, we will actually start writing some code.', 'start': 10.316, 'duration': 3.562}, {'end': 19.782, 'text': 'now, moving forward, i will be using pycharm ide to demonstrate how opencv works,', 'start': 13.878, 'duration': 5.904}, {'end': 26.946, 'text': 'but you are free to use any ide or any other editor in order to use opencv.', 'start': 19.782, 'duration': 7.164}], 'summary': 'Opencv tutorial for beginners using python, transitioning to writing code with pycharm ide.', 'duration': 26.095, 'max_score': 0.851, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/TGQcDaZ56ao/pics/TGQcDaZ56ao851.jpg'}, {'end': 60.655, 'src': 'heatmap', 'start': 35.675, 'weight': 0.776, 'content': [{'end': 46.781, 'text': 'So if you are using OpenCV you just need to create a project inside OpenCV and then you just need to click on file and then go to the settings.', 'start': 35.675, 'duration': 11.106}, {'end': 57.672, 'text': 'Now once this settings window opens, you just need to go to the project and then it will say after colon your project name.', 'start': 47.822, 'duration': 9.85}, {'end': 60.655, 'text': 'So my project name is OpenCV examples.', 'start': 57.692, 'duration': 2.963}], 'summary': "Using opencv: create project, set project name as 'opencv examples'", 'duration': 24.98, 'max_score': 35.675, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/TGQcDaZ56ao/pics/TGQcDaZ56ao35675.jpg'}, {'end': 129.866, 'src': 'embed', 'start': 85.939, 'weight': 0, 'content': [{'end': 99.425, 'text': 'So to install OpenCV Python package on PyCharm, you just need to click on this plus button here and then you just need to type OpenCV hyphen Python.', 'start': 85.939, 'duration': 13.486}, {'end': 106.949, 'text': 'Now the first result you can see here is OpenCV hyphen Python and the version which is available right now is 4.0.', 'start': 99.685, 'duration': 7.264}, {'end': 108.269, 'text': '0.21 which is the latest version.', 'start': 106.949, 'duration': 1.32}, {'end': 119.838, 'text': 'so, to install this package for your pycharm ide, you just need to click on install package button and then, after some time,', 'start': 112.071, 'duration': 7.767}, {'end': 126.583, 'text': 'you will see this message which says package opencv hyphen python installed successfully in the green bar.', 'start': 119.838, 'duration': 6.745}, {'end': 129.866, 'text': 'that means opencv package is installed successfully.', 'start': 126.583, 'duration': 3.283}], 'summary': 'To install opencv python package on pycharm, click and install opencv-python version 4.0.21 successfully.', 'duration': 43.927, 'max_score': 85.939, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/TGQcDaZ56ao/pics/TGQcDaZ56ao85939.jpg'}], 'start': 0.851, 'title': 'Opencv installation for python using pycharm ide', 'summary': 'Covers the installation of opencv for python using pycharm ide, and includes adding the opencv python package through the ide and verifying the installation.', 'chapters': [{'end': 153.436, 'start': 0.851, 'title': 'Opencv tutorial for beginners', 'summary': 'Covers the installation of opencv for python using pycharm ide, which includes the process of adding the opencv python package through the ide and verifying the installation.', 'duration': 152.585, 'highlights': ["The process of installing the OpenCV Python package on PyCharm IDE involves navigating to the project settings, accessing the project interpreter, and adding the package by typing 'OpenCV-Python', with the latest version available being 4.0.0.21.", 'Upon successful installation, a confirmation message is displayed, indicating that the OpenCV package has been installed successfully, and the cv2 package can be imported into the Python script.', 'The tutorial demonstrates the use of PyCharm IDE for working with OpenCV, while also allowing the flexibility for users to utilize other IDEs or editors for OpenCV.', 'The video emphasizes the freedom to use any IDE or editor for OpenCV, while specifically showcasing the process within PyCharm IDE.']}], 'duration': 152.585, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/TGQcDaZ56ao/pics/TGQcDaZ56ao851.jpg', 'highlights': ['The process of installing OpenCV Python package on PyCharm involves navigating to project settings and adding the package (OpenCV-Python 4.0.0.21)', 'Upon successful installation, a confirmation message is displayed, indicating successful installation of OpenCV package', 'The tutorial demonstrates the use of PyCharm IDE for working with OpenCV', 'The video emphasizes the freedom to use any IDE or editor for OpenCV']}, {'end': 415.825, 'segs': [{'end': 234.96, 'src': 'embed', 'start': 208.559, 'weight': 0, 'content': [{'end': 219.288, 'text': 'So here you will find many sample images and videos and other files which you can use in your project for the learning purpose.', 'start': 208.559, 'duration': 10.729}, {'end': 225.493, 'text': 'So you can use these images in order to develop your example.', 'start': 219.888, 'duration': 5.605}, {'end': 233.539, 'text': 'So what I generally do is I just go to this repository, which is under the URL github.com.', 'start': 226.113, 'duration': 7.426}, {'end': 234.96, 'text': 'forward slash opencv.', 'start': 233.539, 'duration': 1.421}], 'summary': 'Access sample images, videos, and files from github.com/opencv for learning and project development.', 'duration': 26.401, 'max_score': 208.559, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/TGQcDaZ56ao/pics/TGQcDaZ56ao208559.jpg'}, {'end': 319.868, 'src': 'heatmap', 'start': 276.926, 'weight': 3, 'content': [{'end': 283.489, 'text': 'now, to start with, we will be using this image, which is lena.jpg.', 'start': 276.926, 'duration': 6.563}, {'end': 296.095, 'text': "so i'm going to just copy this image for now and then i'm going to go to my pycharm ide and then i'm going to just paste this image inside my project.", 'start': 283.489, 'duration': 12.606}, {'end': 302.198, 'text': 'so this jpg image will be directly available inside my project folder.', 'start': 296.095, 'duration': 6.103}, {'end': 308.361, 'text': "Now let's see how we can read images using the CV2 module.", 'start': 303.178, 'duration': 5.183}, {'end': 319.868, 'text': 'So you just need to use CV2 and there is a method called imRead which enables you to read the images.', 'start': 309.042, 'duration': 10.826}], 'summary': 'Using cv2 module, read lena.jpg in project folder.', 'duration': 84.908, 'max_score': 276.926, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/TGQcDaZ56ao/pics/TGQcDaZ56ao276926.jpg'}, {'end': 415.825, 'src': 'embed', 'start': 354.591, 'weight': 2, 'content': [{'end': 363.817, 'text': 'So the first flag is cv2.imread underscore color or you can give the integer value of it, which is one.', 'start': 354.591, 'duration': 9.226}, {'end': 372.023, 'text': "And whenever you give this flag as the second argument of imread function, it's going to load the colored image.", 'start': 364.438, 'duration': 7.585}, {'end': 381.891, 'text': 'if you give this flag, which is cv2 dot, iam read underscore grayscale, or if you give this integer value, which is zero,', 'start': 372.583, 'duration': 9.308}, {'end': 386.555, 'text': "it's going to load your image in grayscale mode.", 'start': 381.891, 'duration': 4.664}, {'end': 396.503, 'text': 'and the third flag is iam read, underscore, unchanged, or the value minus one, which is going to load your image as it is,', 'start': 386.555, 'duration': 9.948}, {'end': 398.386, 'text': 'including the alpha channel.', 'start': 396.503, 'duration': 1.883}, {'end': 406.715, 'text': 'So for now, we are going to just give here zero flag, which means we want to load our image in grayscale.', 'start': 398.626, 'duration': 8.089}, {'end': 410.88, 'text': "So now let's run the code and let's see what happens until this point.", 'start': 406.815, 'duration': 4.065}, {'end': 415.825, 'text': 'So you can see our code runs fine without giving any error.', 'start': 411.681, 'duration': 4.144}], 'summary': 'Using cv2.imread with flags loads images as colored, grayscale, or unchanged, without errors.', 'duration': 61.234, 'max_score': 354.591, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/TGQcDaZ56ao/pics/TGQcDaZ56ao354591.jpg'}], 'start': 153.436, 'title': 'Reading and writing images with cv2 and opencv', 'summary': 'Covers reading and writing images using the cv2 package, accessing sample images from opencv repository, using the imread method, and reading images using opencv with various loading options. it provides guidance on project development and ensures error-free code execution.', 'chapters': [{'end': 262.499, 'start': 153.436, 'title': 'Reading and writing images using cv2 package', 'summary': 'Discusses how to read and write images using the cv2 package, and provides guidance on accessing sample images from the opencv repository on github for project development.', 'duration': 109.063, 'highlights': ["Accessing sample images from the OpenCV repository on GitHub by navigating to the URL github.com/OpenCV and choosing the 'OpenCV' repository, which contains images in the samples folder.", 'Downloading or cloning the OpenCV repository to access a variety of sample images, videos, and files for project development.', "Demonstrating the process of accessing sample images and videos from the 'data' folder within the OpenCV repository for educational purposes."]}, {'end': 319.868, 'start': 262.499, 'title': 'Reading images with cv2', 'summary': 'Explains reading images using the cv2 module, with a focus on using the imread method to read images, including the process of accessing the images from the samples and data folders and copying them to the project folder.', 'duration': 57.369, 'highlights': ['The process involves accessing images from the samples and data folders in the repository, particularly using the image lena.jpg for demonstration.', 'Copying the selected image to the project folder for direct availability within the project.', 'Demonstrating the use of the CV2 module and its imRead method for reading images.']}, {'end': 415.825, 'start': 319.989, 'title': 'Reading images using opencv', 'summary': 'Explains how to read an image using opencv by providing the image name and a flag, with options to load the image in color, grayscale, or unchanged mode. the code runs without errors.', 'duration': 95.836, 'highlights': ['The chapter provides guidance on using the cv2.imread function to read images in OpenCV, specifying the image name and a flag as arguments.', 'It explains the three flags available for the second argument: cv2.IMREAD_COLOR (or 1) for loading colored images, cv2.IMREAD_GRAYSCALE (or 0) for loading images in grayscale, and cv2.IMREAD_UNCHANGED (or -1) for loading the image as is, including the alpha channel.', 'The code is demonstrated to run without errors after specifying the image name and flag to load the image in grayscale mode.']}], 'duration': 262.389, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/TGQcDaZ56ao/pics/TGQcDaZ56ao153436.jpg', 'highlights': ["Accessing sample images from the OpenCV repository on GitHub by navigating to the URL github.com/OpenCV and choosing the 'OpenCV' repository, which contains images in the samples folder.", 'Downloading or cloning the OpenCV repository to access a variety of sample images, videos, and files for project development.', 'The chapter provides guidance on using the cv2.imread function to read images in OpenCV, specifying the image name and a flag as arguments.', 'The process involves accessing images from the samples and data folders in the repository, particularly using the image lena.jpg for demonstration.', "Demonstrating the process of accessing sample images and videos from the 'data' folder within the OpenCV repository for educational purposes.", 'Demonstrating the use of the CV2 module and its imRead method for reading images.', 'Copying the selected image to the project folder for direct availability within the project.', 'It explains the three flags available for the second argument: cv2.IMREAD_COLOR (or 1) for loading colored images, cv2.IMREAD_GRAYSCALE (or 0) for loading images in grayscale, and cv2.IMREAD_UNCHANGED (or -1) for loading the image as is, including the alpha channel.', 'The code is demonstrated to run without errors after specifying the image name and flag to load the image in grayscale mode.']}, {'end': 645.247, 'segs': [{'end': 451.216, 'src': 'embed', 'start': 415.845, 'weight': 0, 'content': [{'end': 424.973, 'text': 'Now let me give any random name here as the file name and once again run this code,', 'start': 415.845, 'duration': 9.128}, {'end': 430.018, 'text': 'and once again you will see that there is no exception which is thrown here.', 'start': 424.973, 'duration': 5.045}, {'end': 440.367, 'text': 'So even if you give the wrong file path or file name here, this function is not going to give you any error.', 'start': 430.558, 'duration': 9.809}, {'end': 451.216, 'text': "Now in case of wrong path or wrong file name, let's say I'm going to just assign this value to a new variable which is img.", 'start': 440.747, 'duration': 10.469}], 'summary': 'The code successfully handles wrong file paths or names without throwing an exception.', 'duration': 35.371, 'max_score': 415.845, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/TGQcDaZ56ao/pics/TGQcDaZ56ao415845.jpg'}, {'end': 541.469, 'src': 'embed', 'start': 508.85, 'weight': 3, 'content': [{'end': 512.152, 'text': 'and the result you can see in the form of this matrix.', 'start': 508.85, 'duration': 3.302}, {'end': 515.015, 'text': 'so until now we have just read the image.', 'start': 512.152, 'duration': 2.863}, {'end': 518.256, 'text': 'Now we want to display our image.', 'start': 515.655, 'duration': 2.601}, {'end': 528.643, 'text': 'So in order to display our image what we can do is we can use a cv2.iamshow method.', 'start': 518.817, 'duration': 9.826}, {'end': 534.527, 'text': 'So just write imshow here which is going to show your image.', 'start': 529.003, 'duration': 5.524}, {'end': 541.469, 'text': 'So the first argument here will be the name of your window in which your image will open.', 'start': 534.727, 'duration': 6.742}], 'summary': 'The result is shown as a matrix. using cv2.imshow to display the image.', 'duration': 32.619, 'max_score': 508.85, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/TGQcDaZ56ao/pics/TGQcDaZ56ao508850.jpg'}, {'end': 645.247, 'src': 'embed', 'start': 587.493, 'weight': 1, 'content': [{'end': 600.168, 'text': 'so this cv2.waitkey is the keyboard binding function and the argument which it takes is the number of milliseconds for which you want to show your image window.', 'start': 587.493, 'duration': 12.675}, {'end': 609.671, 'text': "so let's give 5000 value here, which means we want to show the image for 5 seconds and at last, what we are going to do is,", 'start': 600.729, 'duration': 8.942}, {'end': 615.472, 'text': 'after we have done seeing our image, we will destroy the window which we have created.', 'start': 609.671, 'duration': 5.801}, {'end': 621.254, 'text': 'so you can just give this method cv2 destroy all windows.', 'start': 615.472, 'duration': 5.782}, {'end': 627.235, 'text': 'so destroy all windows simply destroys all the windows which we have created.', 'start': 621.254, 'duration': 5.981}, {'end': 639.203, 'text': 'there is one more method, which is destroyWindow, and this method you can use to destroy a particular window which we will see little bit later.', 'start': 627.475, 'duration': 11.728}, {'end': 645.247, 'text': 'but for now we will just use this method, which says destroyAllWindows.', 'start': 639.203, 'duration': 6.044}], 'summary': 'Using cv2.waitkey to display image for 5 seconds, then destroy window.', 'duration': 57.754, 'max_score': 587.493, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/TGQcDaZ56ao/pics/TGQcDaZ56ao587493.jpg'}], 'start': 415.845, 'title': 'Python file handling and opencv image display', 'summary': 'Covers python file handling, including reading image files and handling incorrect file paths or names. it also explains displaying images using the cv2.iamshow method and using opencv functions to display images, wait for a specified duration, and destroy windows.', 'chapters': [{'end': 508.85, 'start': 415.845, 'title': 'File handling in python', 'summary': 'Explains a python code that demonstrates file handling by reading an image file, showing how the code handles wrong file paths or file names, and clarifying the result when the correct file name is given.', 'duration': 93.005, 'highlights': ['The code demonstrates file handling in Python by reading an image file and handling wrong file paths or names, resulting in no exceptions being thrown.', "When a wrong file path or name is given, the code assigns the value 'none' to a variable 'img' and prints it using the print method, indicating that an error has occurred.", "Upon providing the correct file name, the code successfully reads all the pixels from the image file and assigns them to the variable 'img', resulting in a matrix being displayed."]}, {'end': 565.316, 'start': 508.85, 'title': 'Displaying image using cv2.iamshow method', 'summary': 'Introduces the process of displaying an image using the cv2.iamshow method, specifying the window name and image variable as arguments.', 'duration': 56.466, 'highlights': ['The chapter introduces the process of displaying an image using the cv2.iamshow method, specifying the window name and image variable as arguments.', 'The result of the process is depicted in the form of a matrix.']}, {'end': 645.247, 'start': 565.316, 'title': 'Opencv image display and window destruction', 'summary': 'Demonstrates using cv2.waitkey to display an image for 5 seconds and then destroy the window, followed by using cv2.destroyallwindows to remove all created windows.', 'duration': 79.931, 'highlights': ['cv2.waitKey function takes the argument of milliseconds to display the image window, in this case, set to 5000 for a 5-second display.', 'cv2.destroyAllWindows method removes all the created windows at once, providing efficient window destruction.', 'The process involves showing an image using cv2.waitKey for 5 seconds and then using cv2.destroyAllWindows to remove the window.']}], 'duration': 229.402, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/TGQcDaZ56ao/pics/TGQcDaZ56ao415845.jpg', 'highlights': ['The code demonstrates file handling in Python by reading an image file and handling wrong file paths or names, resulting in no exceptions being thrown.', 'cv2.destroyAllWindows method removes all the created windows at once, providing efficient window destruction.', 'cv2.waitKey function takes the argument of milliseconds to display the image window, in this case, set to 5000 for a 5-second display.', 'The chapter introduces the process of displaying an image using the cv2.iamshow method, specifying the window name and image variable as arguments.']}, {'end': 1047.457, 'segs': [{'end': 773.518, 'src': 'embed', 'start': 645.247, 'weight': 0, 'content': [{'end': 648.61, 'text': "so now let's run our code and let's see what happens.", 'start': 645.247, 'duration': 3.363}, {'end': 659.015, 'text': 'so now, this time you can see our image is loaded for five seconds and our image is loaded in grayscale mode.', 'start': 648.61, 'duration': 10.405}, {'end': 665.278, 'text': "now, if you give here zero as the argument of wait key method, then let's see what happens.", 'start': 659.015, 'duration': 6.263}, {'end': 674.902, 'text': "so i'm going to run my code and now you will observe that your window will not disappear after five second or any number of seconds.", 'start': 665.278, 'duration': 9.624}, {'end': 685.987, 'text': "it's going to wait for the closing of this window, which we can close from this close button, And you can see it's loaded in the grayscale mode.", 'start': 674.902, 'duration': 11.085}, {'end': 688.548, 'text': "I'm going to close this window.", 'start': 686.327, 'duration': 2.221}, {'end': 698.873, 'text': 'And here, as an argument of I am read image, the second argument I want to give here right now is 1, which means the colored image.', 'start': 689.008, 'duration': 9.865}, {'end': 700.353, 'text': "And let's run the code.", 'start': 699.193, 'duration': 1.16}, {'end': 705.936, 'text': 'And you can see this image is loaded in the colored mode now.', 'start': 700.853, 'duration': 5.083}, {'end': 711.117, 'text': "Let's also check the minus one argument, which is unchanged.", 'start': 706.616, 'duration': 4.501}, {'end': 717.299, 'text': "So it's going to just load the image as it is with alpha channels.", 'start': 711.497, 'duration': 5.802}, {'end': 720.019, 'text': 'So let me just close this image once again.', 'start': 717.579, 'duration': 2.44}, {'end': 727.201, 'text': 'So now we have understood how we can read an image using IAM read function.', 'start': 720.819, 'duration': 6.382}, {'end': 736.323, 'text': "So let's see how we can write an image to a file using a function called IAMWrite.", 'start': 728.061, 'duration': 8.262}, {'end': 751.967, 'text': 'So we are going to just use CV2 once again and then there is a method called IAMWrite which you can use to write an image in the form of file.', 'start': 737.043, 'duration': 14.924}, {'end': 757.17, 'text': 'so the first argument here will be the image name, whatever you want to give here.', 'start': 751.967, 'duration': 5.203}, {'end': 766.755, 'text': "so here let's say we want to give the name to our image as Lena underscore copy dot PNG.", 'start': 757.17, 'duration': 9.585}, {'end': 773.518, 'text': 'so the image will be saved as the file name Lena underscore copy dot PNG file.', 'start': 766.755, 'duration': 6.763}], 'summary': 'Demonstrated loading and displaying images in grayscale, colored, and unchanged modes, then writing an image using cv2.', 'duration': 128.271, 'max_score': 645.247, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/TGQcDaZ56ao/pics/TGQcDaZ56ao645247.jpg'}, {'end': 887.933, 'src': 'embed', 'start': 856.615, 'weight': 4, 'content': [{'end': 863.678, 'text': 'then only we want to destroy all the windows without saving it into a new file.', 'start': 856.615, 'duration': 7.063}, {'end': 871.142, 'text': 'otherwise, if somebody presses the s key, then we are going to save this file with the new name.', 'start': 863.678, 'duration': 7.464}, {'end': 874.023, 'text': "let's say lena, copy dot png file.", 'start': 871.142, 'duration': 2.881}, {'end': 878.866, 'text': "so I'm going to just capture the output of my weight key.", 'start': 874.683, 'duration': 4.183}, {'end': 881.228, 'text': 'so just create a new variable.', 'start': 878.866, 'duration': 2.362}, {'end': 882.409, 'text': "let's say K.", 'start': 881.228, 'duration': 1.181}, {'end': 887.933, 'text': 'so now, when we press any key, this key will be captured in this variable.', 'start': 882.409, 'duration': 5.524}], 'summary': 'Capturing and saving key presses to new file, capturing output of weight key.', 'duration': 31.318, 'max_score': 856.615, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/TGQcDaZ56ao/pics/TGQcDaZ56ao856615.jpg'}, {'end': 1029.009, 'src': 'embed', 'start': 1000.533, 'weight': 6, 'content': [{'end': 1011.183, 'text': 'that means this time this condition is fulfilled and this image is created, and after that all the windows are destroyed.', 'start': 1000.533, 'duration': 10.65}, {'end': 1013.364, 'text': 'So this code is working fine for me.', 'start': 1011.403, 'duration': 1.961}, {'end': 1025.127, 'text': "But in the documentation it's also written that if you are using a 64 bit machine, it's better to use this notation with your wait key method,", 'start': 1013.764, 'duration': 11.363}, {'end': 1029.009, 'text': 'which is wait key, and this mask here.', 'start': 1025.127, 'duration': 3.882}], 'summary': 'The code is working fine, recommended for 64-bit machine.', 'duration': 28.476, 'max_score': 1000.533, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/TGQcDaZ56ao/pics/TGQcDaZ56ao1000533.jpg'}], 'start': 645.247, 'title': 'Image loading and display', 'summary': 'Demonstrates loading and displaying images in grayscale and colored mode using opencv, and showcases the use of wait key method to control window closing and display duration.', 'chapters': [{'end': 705.936, 'start': 645.247, 'title': 'Image loading and display', 'summary': 'Demonstrates loading and displaying images in grayscale and colored mode using opencv, showcasing the use of wait key method to control window closing and display duration.', 'duration': 60.689, 'highlights': ['The wait key method can be used to control the duration of image display, with an argument of 0 causing the window to remain open until manually closed, as demonstrated by the code.', 'The chapter showcases loading an image in grayscale mode for a duration of five seconds before displaying it, providing a practical demonstration of image loading and display using OpenCV.', 'The process of loading an image in colored mode is demonstrated by setting the second argument of the imread function to 1, showcasing the versatility of image loading in OpenCV.']}, {'end': 1047.457, 'start': 706.616, 'title': 'Reading and writing images with opencv', 'summary': 'Demonstrates how to read and write images using the iam read and iam write functions in opencv, including saving an image with a specified name, capturing key presses to control window destruction and image saving, and using the wait key method. it also mentions a recommendation for using the wait key method with a mask on 64-bit machines.', 'duration': 340.841, 'highlights': ['Demonstrates reading and writing images using IAM read and IAM write functions in OpenCV', 'Saving an image with a specified name', 'Capturing key presses to control window destruction and image saving', 'Mentioning a recommendation for using the wait key method with a mask on 64-bit machines']}], 'duration': 402.21, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/TGQcDaZ56ao/pics/TGQcDaZ56ao645247.jpg', 'highlights': ['The wait key method can be used to control the duration of image display, with an argument of 0 causing the window to remain open until manually closed, as demonstrated by the code.', 'The process of loading an image in colored mode is demonstrated by setting the second argument of the imread function to 1, showcasing the versatility of image loading in OpenCV.', 'The chapter showcases loading an image in grayscale mode for a duration of five seconds before displaying it, providing a practical demonstration of image loading and display using OpenCV.', 'Demonstrates reading and writing images using IAM read and IAM write functions in OpenCV', 'Capturing key presses to control window destruction and image saving', 'Saving an image with a specified name', 'Mentioning a recommendation for using the wait key method with a mask on 64-bit machines']}], 'highlights': ['Accessing sample images from the OpenCV repository on GitHub', "Demonstrating the process of accessing sample images and videos from the 'data' folder within the OpenCV repository", 'The process of installing OpenCV Python package on PyCharm involves navigating to project settings and adding the package', 'The tutorial demonstrates the use of PyCharm IDE for working with OpenCV', 'The video emphasizes the freedom to use any IDE or editor for OpenCV', 'The chapter provides guidance on using the cv2.imread function to read images in OpenCV', 'The process involves accessing images from the samples and data folders in the repository', 'The code demonstrates file handling in Python by reading an image file and handling wrong file paths or names', 'cv2.destroyAllWindows method removes all the created windows at once', 'cv2.waitKey function takes the argument of milliseconds to display the image window', 'The chapter introduces the process of displaying an image using the cv2.iamshow method', 'The wait key method can be used to control the duration of image display', 'The process of loading an image in colored mode is demonstrated by setting the second argument of the imread function to 1', 'The chapter showcases loading an image in grayscale mode for a duration of five seconds before displaying it', 'Demonstrates reading and writing images using IAM read and IAM write functions in OpenCV', 'Capturing key presses to control window destruction and image saving', 'Mentioning a recommendation for using the wait key method with a mask on 64-bit machines', 'Upon successful installation, a confirmation message is displayed, indicating successful installation of OpenCV package']}