Professional Documents
Culture Documents
AleezaAnjum (20 CS 101) CV Ass3
AleezaAnjum (20 CS 101) CV Ass3
3
SUBMITTED TO: DR. SYED ADNAN
SUBMITTED BY: ALEEZA ANJUM
REG NO: 20-CS-101
SECTION: ALPHA
CODE:
import cv2
import numpy as np
if __name__ == '__main__':
cap = cv2.VideoCapture(0)
scaling_factor = 0.9
prev_frame = get_frame(cap)
cur_frame = get_frame(cap)
next_frame = get_frame(cap)
# Iterate until the user presses the ESC key
while True:
frame_difference = frame_diff(prev_frame, cur_frame, next_frame)
# frame_difference = cv2.dilate(src, kernel)
_, frame_th = cv2.threshold(frame_difference, 0, 255,
cv2.THRESH_TRIANGLE)
# frame_th = cv2.dilate(frame_th, kernel)
cv2.imshow("Object Movement", frame_difference)
cv2.imshow("Obje", frame_th)
OUTPUT:
Movement of hand is detected here
3- Then
The resultant matrix after the above calculations will have the shape of 16x8x9.
6- Once histogram computation is over for all blocks, 4 blocks from the 9 point histogram
matrix are clubbed together to form a new block (2x2). This clubbing is done in an
overlapping manner with a stride of 8 pixels.
8- This normalization is done to reduce the effect of changes in contrast between images of
the same object. From each block. A 36 point feature vector is collected. In the horizontal
direction there are 7 blocks and in the vertical direction there are 15 blocks. So the total
length of HOG features will be:
7 x 15 x 36 = 3780.
HOG features of the selected image are obtained.