I was doing a project related to machine learning and came across the OpenCV library for image and video processing and researched about it.
We are using OpenCV with jupyter. So, to start with OpenCV we have to first install jupyter.
The Jupyter Notebook is an open-source web application that allows you to create and share documents that contain live code, equations, visualizations, and narrative text. Uses include data cleaning and transformation, numerical simulation, statistical modeling, data visualization, machine learning, and much more.
Why are we using jupyter ?
We are using jupyter because for machine learning algorithms we need faster processing. Jupyter helps to process the algorithms faster.
The Jupyter Notebook is an open-source web application that we can use to create and share documents that contain live code, equations, visualizations, and text.
For download and installation of jupyter refer to this video,
Now, after completing the installation of jupyter, to install OpenCV go to command prompt and then type the following command:
pip install opencv-python
OpenCV is a cross-platform library using which we can develop real-time computer vision applications. It mainly focuses on image processing, video capture, and analysis including features like face detection and object detection.
There are some of the functions mentioned:
imread: It is used to read an image
imshow: It is used to display an image in a window.
cvtColor : It is used to convert an image from one color space to another.
resize : Image resizing refers to the scaling of images.
transpose : It rotate the image 90 degrees Counter clockwise.
After the library is downloaded open jupyter notebook and create a new file for checking if it is successfully installed and write the following command:
To run the command in jupyter we need to use
The output should be like this:
Now, we will start with the capturing of video from camera
In the above figure
- we have imported the library.
- Then define a variable as video to get the video capture object for the camera.
- Setting up an infinite while loop and use the
read()method to read the frames using the above-created object.
- Then use
cv2.imshow()method to show the frames in the video.
- If press ‘q’ then it will close the window after the loop breaks it will release the object and destroy all the windows if any is open.
After running the code the web camera will get started and it captures the video.
Great you have successfully completed.
Thank you for keeping up with me till the last word.