cv in python

To work with computer vision in Python, we can use the OpenCV library. OpenCV (Open Source Computer Vision Library) is a library of programming functions mainly aimed at real-time computer vision. It has C++, C, Python, Java, and MATLAB interfaces and supports Windows, Linux, Android, and macOS.

Here's an example of how to read an image, convert it to grayscale, and display it using OpenCV in Python:

main.py
import cv2

# Read image in color mode
img = cv2.imread('image.jpg', cv2.IMREAD_COLOR)

# Convert image to grayscale
gray_img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

# Display images
cv2.imshow('Color image', img)
cv2.imshow('Grayscale image', gray_img)

# Wait for keyboard event
cv2.waitKey(0)

# Destroy all windows
cv2.destroyAllWindows()
344 chars
18 lines

This is just a simple example, but OpenCV in Python can be used for a wide variety of tasks, such as object detection and tracking, facial recognition, and more.

gistlibby LogSnag