Computer Vision: Colors detection in OpenCV & Python (Assemtica Didactic series)

preview_player
Показать описание
Computer Vision: Colors detection in OpenCV & Python (Assemtica Didactic series)
Рекомендации по теме
Комментарии
Автор

the code but just for red;


import cv2
import numpy as np
import imutils

cap= cv2.VideoCapture(0)
cap.set(3, 640)
cap.set(4, 480)

while True:
_, frame= cap.read()

hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)

lower_red = np.array([0, 50, 120])
upper_red = np.array([10, 255, 255])

mask = cv2.inRange(hsv, lower_red, upper_red)

cnts = cv2.findContours(mask, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
cnts = imutils.grab_contours(cnts)

for c in cnts:
area = cv2.contourArea(c)
if area > 5000:


cv2.drawContours(frame, [c], -1, (0, 255, 0), 3)

M = cv2.moments(c)

cx = int(M["m10"]/ M["m00"])
cy = int(M["m01"]/ M["m00"])

cv2.circle(frame, (cx, cy), 7, (255, 255, 255), -1)

cv2.imshow("result", frame)

k = cv2.waitKey(5)
if k == 27:
break

cap.release()
cv2.destroyAllWindows()

ozlen
Автор

nice work bro! please keep the source code in description plz

urazeem
Автор

Esta tan perro que casi ladra. Gracias!

JM_Tushe
Автор

at 4:34 you mentioned of the lighting condition .. have tried to write this same code but its not perfect as yours after brightening the light it's now

AI_CANISTER
Автор

hello may i ask you question? I'd like to implement the corresponding coding as a Django, is there any way I can do it?

dbsgustlr
Автор

Hi i have an issue could you help? I want to detect black and white colours but they are too sensitive when the webcam is on. Is there any way to reduce its sensitivity? I have changed its lower and upper values many times but it does not work.

LIMYEOWCHYE
Автор

Hello sir is that any way to shown cx and cy with color text on the screen

teknolojikbirisi
Автор

can you tell how do I implement this in my video file instead of camera
?

iHawkXJ
Автор

SIR HOW TO MAKE WHEN THE OBJECTS ARE ROUND

karanrawat
Автор

Please tell me why you wrote aera >5000 !!!!

Wave
Автор

sir getting error likr cv2.error opencv(4, 4.0) what to do tell me sir

srinidhiuttanuru
Автор

I didn't understand why if area1>5000

sixtocorralescastle
Автор

bhai code description me to daldete, itni akkal to har kisi me hoti hai

androidboy
Автор

hello, can you send me the source code ?

robywahyudi.b