Skip to content

Commit ae43b51

Browse files
DeepshikhaDeepshikha
Deepshikha
authored and
Deepshikha
committed
modified the color_detection.py and readme files
1 parent e794ff7 commit ae43b51

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

Color_detection/Color_detection.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import pandas as pd
22
import cv2
33

4-
img_path = 'colorpic.jpg'
5-
csv_path = 'colors.csv'
4+
img_path = './Color_detection/colorpic.jpg'
5+
csv_path = './Color_detection/colors.csv'
66

77
#Reading csv file with pandas and giving names to each column
88
index = ['color', 'color_name', 'hex', 'R', 'G', 'B']

Color_detection/Readme.md

+10-7
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,17 @@
44
In this color detection Python project, we are going to build an application through which you can automatically get the name of the color by clicking on them. So for this, we will have a data file that contains the color name and its values. Then we will calculate the distance from each color and find the shortest one.
55

66
# Steps Used
7-
-Importing required package and load the image.
7+
##-Importing required package and load the image.
8+
Package used - Pandas and cv2 for OpenCV bindings.
9+
##-Reading the CSV file with pandas.
810

9-
-Reading the CSV file with pandas.
10-
11-
-Set a mouse callback event on a window
11+
##-Set a mouse callback event on a window
1212
- First, we created a window in which the input image will display. Then, we set a callback function which will be called when a mouse event happens.
13-
Create the draw_function
13+
###draw_function
1414
- In the function, we check if the event is double-clicked then we calculate and set the r,g,b values along with x,y positions of the mouse.
15-
xCalculate distance to get color name - d = abs(Red — ithRedColor) + (Green — ithGreenColor) + (Blue — ithBlueColor)
16-
Display image on the window
15+
16+
##-Calculate distance to get color name
17+
d = abs(Red — ithRedColor) + (Green — ithGreenColor) + (Blue — ithBlueColor)
18+
19+
##-Display image on the window
1720
- Whenever a double click event occurs, it will update the color name and RGB values on the window.

0 commit comments

Comments
 (0)