Computer Vision
Computer Vision
INSTITUTE OF TECHNOLOGY
THOVALAI – 629 302
CCS338
COMPUTER VISION
NAME :
REGISTER NO. :
SEMESTER :
YEAR :
Certified that this record has been submitted for the practical examination held at C.S.I. INSTITUTE
OF TECHNOLOGY, THOVALAI on …………….
INDEX
SI.No Date Programs Page No Signature
1 OpenCV Installation and
working with Python.
3 Pose Estimation
AIM:
To install OpenCV and work with Python,
PROCEDURE:
1.To install OpenCV, we must have Python and PIP installed on your system. To
check if your system already contains Python, go through the following instructions:
Open the Command Prompt or Terminal.
Type the following command: python –version
2. If Python is already installed, it will display the Python version.
If Python is already installed, it will display the Python version.
3.To install OpenCV, go to the command line interface and type the following
command:
pip install opencv-python
7.Finished Installation:
RESULT:
Thus, the installation of OpenCV and working with python is
successfully verified.
Ex.No:02 Image Annotation
Date:
AIM:
To implement image rotation, text insertion, drawing circles,
rectangles, and ellipses in images using OpenCV.
PROCEDURE:
To implement image rotation, text insertion, drawing circles, rectangles, and ellipses
in images using OpenCV,
1.Image Rotation:
Use the cv2.rotate() function to rotate images.
Provide the image and the rotation direction (e.g.,
cv2.ROTATE_90_CLOCKWISE, cv2.ROTATE_90_COUNTERCLOCKWISE) as
parameters.
2.Text Insertion:
Utilize the cv2.putText() function to insert text into images.
Specify the text, position, font, font scale, color, thickness, and line type as
parameters.
3.Drawing Circles:
Use the cv2.circle() function to draw circles on images.
Provide the image, center coordinates, radius, color, thickness, and line type as
parameters.
4.Drawing Rectangles:
Utilize the cv2.rectangle() function to draw rectangles on images.
Specify the image, top-left and bottom-right coordinates of the rectangle, color,
thickness, and line type as parameters.
5.Drawing Ellipses:
Use the cv2.ellipse() function to draw ellipses on images.
Provide the image, center coordinates, axes lengths, angle, start angle, end angle,
color, thickness, and line type as parameters.
CODING:
import cv2
# Read Images
img = cv2.imread('D:\dog.webp')
# Display Image
cv2.imshow('Original Image', img)
cv2.waitKey(0)
OUTPUT:
1.Image Rotation:
2.Text Insertion:
3.Drawing Circles:
4.Drawing Rectangles:
5.Drawing Ellipses:
RESULT:
AIM:
PROCEDURE:
import cv2
import mediapipe as mp
try:
# Resize the frame for portrait video
frame = cv2.resize(frame, (600, 350))
# Convert to RGB
frame_rgb = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
except Exception as e:
print(e)
break
OUTPUT:
RESULT:
PROCEDURE:
CODING:
import cv2 as cv
import matplotlib.pyplot as plt
imgR = cv.imread(r'D:\right.png', 0)
imgL = cv.imread(r'D:\left.png', 0)
stereo = cv.StereoBM_create(numDisparities=16, blockSize=15)
disparity = stereo.compute(imgL, imgR)
plt.imshow(disparity, 'gray')
plt.show()
INPUT:
OUTPUT:
RESULT:
AIM:
To implement Object Detection and Tracking using Gaussian Filter, Camshift
using OpenCV.
PROCEDURE:
CODING:
import cv2
import numpy as np
cap = cv2.VideoCapture(r'D:\video1.mp4')
x, y, width, height = 400, 440, 150, 150
tracker_window = (x, y, width, height)
roi = (y, y + height, x, x + width) # Define roi here
_, frame = cap.read()
hsv_roi = cv2.cvtColor(frame[roi[0]:roi[1], roi[2]:roi[3]], cv2.COLOR_BGR2HSV)
roi_hist = cv2.calcHist([hsv_roi], [0], None, [180], [0, 180])
term_crit = (cv2.TERM_CRITERIA_EPS | cv2.TERM_CRITERIA_COUNT, 15, 2)
while True:
ret, frame = cap.read()
if not ret:
break
cv2.imshow('CamShift', result)
RESULT:
Thus, implementation of object detection and tracking using camshift is
verified successfully.