Object detection in python by using OpenCv and Numpy -
Object Detection is a new vision technique using camera. It give us ability to identify objects in a cam video and also in an image.
with this kind of technique we identify the object on the basis of color, shape and size etc. And it is also use for count the object in an image or videos.
Object detection is also user for tracking an object current location.
Code for basic object detection on the basis of color-
import numpy as np
import cv2
def nothing(x):
print(x)
#user for live cam object detection
cap = cv2.VideoCapture(0)
cv2.namedWindow('Tracking')
cv2.createTrackbar('LH', 'Tracking', 0, 255, nothing)
cv2.createTrackbar('LS', 'Tracking', 0, 255, nothing)
cv2.createTrackbar('LV', 'Tracking', 0, 255, nothing)
cv2.createTrackbar('UH', 'Tracking', 255, 255, nothing)
cv2.createTrackbar('US', 'Tracking', 255, 255, nothing)
cv2.createTrackbar('UV', 'Tracking', 255, 255, nothing)
while True:
#If you want to apply on the the image then use this
#frame= cv2.imread('smarties.png')
_, frame = cap.read()
hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)
l_h = cv2.getTrackbarPos('LH', 'Tracking')
l_S = cv2.getTrackbarPos('LS', 'Tracking')
l_V = cv2.getTrackbarPos('LV', 'Tracking')
U_h = cv2.getTrackbarPos('UH', 'Tracking')
U_S = cv2.getTrackbarPos('US', 'Tracking')
U_V = cv2.getTrackbarPos('UV', 'Tracking')
l_b = np.array([l_h, l_S, l_V])
u_b = np.array([U_h, U_S, U_V])
mask = cv2.inRange(hsv, l_b, u_b)
res = cv2.bitwise_and(frame, frame, mask=mask)
cv2.imshow('frame', frame)
cv2.imshow('mask', mask)
cv2.imshow('res', res)
key = cv2.waitKey(1)
if key == 27:
break
cap.release()
cv2.destroyAllWindows()
Output-
I am tracking blue color objects-
vstpatch.net
ReplyDeletePDF Annotator Crack
Snapchat For PC Crack
FIFA Crack
Drip Fx VST Crack
Plugin Alliance Bundle Crack
Wow, amazing block structure! How long
Have you written a blog before? Working on a blog seems easy.
The overview of your website is pretty good, not to mention what it does.
In the content!