Posts

Showing posts from April, 2023

Object Tracking In Motion

Drive Link:   https://drive.google.com/drive/folders/1USa7N0JCIeGGhZhkKP18-QuziOzh8riX?usp=share_link Code for Single object Tracking: import cv2 import imutils TrDict = { 'csrt' : cv2 .TrackerCSRT_create,           'kcf' : cv2 .TrackerKCF_create,           'boosting' : cv2 .TrackerBoosting_create,           'mil' : cv2 .TrackerMIL_create,           'tld' : cv2 .TrackerTLD_create,           'medianflow' : cv2 .TrackerMedianFlow_create,           'mosse' : cv2 .TrackerMOSSE_create} tracker = TrDict [ 'csrt' ]() #tracker = cv2.TrackerCSRT_create() v = cv2.VideoCapture(r'mot.mp4') ret , frame = v .read() #frame = imutils .resize( frame , width = 600 ) cv2 .imshow( 'Frame' , frame ) bb = cv2 .selectROI( 'Frame' , frame ) tracker .init( frame , bb ) while True :     ret , frame = v .read()     if not ret :         break     # frame = imutils .resize( frame , width = 600 )     ( success , bo

E material for reference for TA 2 Exam

 Link: E material for reference for TA 2 Exam

YOLO - You Look Only Once

Drive Link =  https://drive.google.com/drive/u/0/folders/1USa7N0JCIeGGhZhkKP18-QuziOzh8riX   Code:  import cv2 import matplotlib.pyplot as plt import numpy as np import cvlib as cv # pip install cvlib from cvlib.object_detection import draw_bbox im = cv2.imread( r 'p2.jpeg' ) plt.imshow(im[:,:,::- 1 ]) bbox , conf = cv.detect_face(im) bbox conf labels = [] for i in range ( len (conf)):     labels.append( 'person' ) im2 = draw_bbox(im,bbox,labels,conf) plt.imshow(im2[:,:,::- 1 ]) im = cv2.imread( r 'a.jpg' ) bbox , labels, conf = cv.detect_common_objects(im) im2 = draw_bbox(im,bbox,labels,conf) plt.imshow(im2[:,:,::- 1 ]) labels

Assignment 5: Hough transform Line and Circle

Image Link:  https://drive.google.com/drive/folders/1USa7N0JCIeGGhZhkKP18-QuziOzh8riX?usp=share_link Code Line:  import cv2 import numpy as np img = cv2.imread('sudoku.png') gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) edges = cv2.Canny(gray, 50, 150, apertureSize=3) lines = cv2.HoughLines(edges, 1, np.pi / 180, 200) for line in lines:     rho,theta = line[0]     a = np.cos(theta)     b = np.sin(theta)     x0 = a * rho     y0 = b * rho     # x1 stores the rounded off value of (r * cos(theta) - 1000 * sin(theta))     x1 = int(x0 + 1000 * (-b))     # y1 stores the rounded off value of (r * sin(theta)+ 1000 * cos(theta))     y1 = int(y0 + 1000 * (a))     # x2 stores the rounded off value of (r * cos(theta)+ 1000 * sin(theta))     x2 = int(x0 - 1000 * (-b))     # y2 stores the rounded off value of (r * sin(theta)- 1000 * cos(theta))     y2 = int(y0 - 1000 * (a))     cv2.line(img, (x1, y1), (x2, y2), (0, 0, 255), 2) cv2.imshow('image', img) k = cv2.waitKey(0) cv2.destroyAllW