-
-
Save amankharwal/e297bc989cbd97013b02c71fd0c4c56e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cv2.namedWindow('Color Recognition App') | |
cv2.setMouseCallback('Color Recognition App', mouse_click) | |
while(1): | |
cv2.imshow("Color Recognition App",img) | |
if (clicked): | |
#cv2.rectangle(image, startpoint, endpoint, color, thickness)-1 fills entire rectangle | |
cv2.rectangle(img,(20,20), (750,60), (b,g,r), -1) | |
#Creating text string to display( Color name and RGB values ) | |
text = recognize_color(r,g,b) + ' R='+ str(r) + ' G='+ str(g) + ' B='+ str(b) | |
#cv2.putText(img,text,start,font(0-7),fontScale,color,thickness,lineType ) | |
cv2.putText(img, text,(50,50),2,0.8,(255,255,255),2,cv2.LINE_AA) | |
#For very light colours we will display text in black colour | |
if(r+g+b>=600): | |
cv2.putText(img, text,(50,50),2,0.8,(0,0,0),2,cv2.LINE_AA) | |
clicked=False | |
#Break the loop when user hits 'esc' key | |
if cv2.waitKey(20) & 0xFF ==27: | |
break | |
cv2.destroyAllWindows() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment