Page 261 - AI Ver 1.0 Class 10
P. 261
Let us first see how we can install it in our computer:
• Open Anaconda prompt and write the following command:
pip install opencv-python
Make sure you download the get-pip.py file and store it in the same directory as python is installed before you
install OpenCV.
Brainy Fact
Stanford’s robot “Stanley” used OpenCV and was declared the winner of the DARPA Grand Challenge in 2005.
This challenge is a prize competition for American autonomous vehicles, funded by the Defense Advanced
Research Projects Agency.
The imread() Function in OpenCV
The imread() function read the image and loads it into the computer’s memory. Syntax of imread() function
is: cv2.imread(path, flag)
Where,
• path is the path of the image to be read. If the file is in the working directory, then write only the name
and the extension of the image otherwise it is a must to specify the complete path.
• flag is the way how our image should be read.
The value can be:
1-(default) It reads image in BGR format where it has bluish appearance.
0-It reads image in Grayscale format.
-1-It reads image in original format.
How to Write a Program in OpenCV
Following are the steps to write a program in Open CV:
Step 1 Importing the required libraries:
• We import cv2 to start with Computer Vision Application.
• We import matplotlib to display our images on the Jupyter Notebook.
• We import numpy to store the pixel values in the NumPy array.
Computer Vision 259

