0% found this document useful (0 votes)
21 views1 page

1.install OpenCV Python

To install OpenCV for Python, run 'python -m pip install opencv-python' in the command prompt. After installation, test it by importing cv2 in the Python shell without errors. A sample program is provided to display an image and its grayscale version using OpenCV, ensuring both the image and code file are in the same directory.

Uploaded by

Mayank Sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views1 page

1.install OpenCV Python

To install OpenCV for Python, run 'python -m pip install opencv-python' in the command prompt. After installation, test it by importing cv2 in the Python shell without errors. A sample program is provided to display an image and its grayscale version using OpenCV, ensuring both the image and code file are in the same directory.

Uploaded by

Mayank Sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Install OpenCV Python

1. Open your command prompt and execute


python -m pip install opencv-python

2. Test your installation

Open your Python Command Line Shell


Execute import cv2 This will import your Open CV package which is shipped as
CV2. If you don't get any errors you are ready to go.

Sample Program - Display an Image Using Open CV

import cv2

img = cv2.imread("logo.png")
gray = cv2.imread('logo.png',cv2.IMREAD_GRAYSCALE)

cv2.imshow('image',img)
cv2.imshow('gray',gray)
#Wait for any key before image disappears
cv2.waitKey(0)
cv2.destroyAllWindows()

Note : Keep both image and code file in same directory.

You might also like