COLOR DETECTION

by praneep55 in Circuits > Arduino

283 Views, 0 Favorites, 0 Comments

COLOR DETECTION

IMG_20220324_100646.jpg
workflow (1).png
workflow.png

Color sensors detect the color of a surface. The sensors cast light (red, green, and blue LEDs) on the objects to be tested, calculate the chromaticity coordinates from the reflected radiation and compare them with previously stored reference colors. If the color values are within the set tolerance range, a switching output is activated.

  • Identify and store up to four colors. No need to reprogram the sensor for changeovers, reducing downtime.
  • High resolution colors can be matched exactly for better process reliability
  • Maintains the extreme precision of the light spot, enabling a consistent object detection
  • A bar graph display provides information about the color quality and detection reliability, ensuring simple process monitoringBroad spectrum of color tolerances enables more flexible use
  • Fast response times at high speeds for reliable detection
  • Detection reliability is not affected by varying temperatures

Color detection sensors are used in various industries including food and beverage, automotive and manufacturing. These sensors are widely used in consumer electronics for backlight control and display calibration

At present, there are two basic types sensor based on the principle of all kinds of color identification: RGB color sensor (red, blue) mainly detects tristimulus values; Chromatic aberration sensor detects the chromatic aberration of the object to be tested and the standard color.

Components Required

workflow.png
optocoupler-4-channel-5v-relay-module.jpeg
WhatsApp Image 2022-03-24 at 12.08.52 PM.jpeg
  1. Node MCU
  2. Relay Board
  3. Jumper Wires(female to female)
  4. Node MCU Cable

Step2:Circuit Diagram

The Circuit diagram of the IOT

Color detection circuit is shown below:

The circuit is very simple as we are only connecting the Relay board to Node Mcu

Connect to Relay board GND to Node MCU GND

Connect to Relay board VCC to Node MCU VCC

Connect IN1 IN2 IN3 IN4 PINS of Relay Board to D0 D1 D2 D3 of Node MCU

We are using python code to Detect the color in this project

A colour sensor is a type of "photoelectric sensor" which emits light from a transmitter, and then detects the light reflected back from the detection object with a receiver.

Step3:Arduino Code

int st=0;
// the setup routine runs once when you press reset:

void setup() {

// initialize serial communication at 9600 bits per second:

Serial.begin(9600);

pinMode(16,OUTPUT);

}

// the loop routine runs over and over again forever:

void loop() {

char a=Serial.read();

if(a=='1')

{

digitalWrite(16,0);

delay(100);}

else if(a=='2')

{

digitalWrite(16,1);

delay(100);

}

}

Step4:Operating Procedure

Step 1: Input: Capture video through webcam.

Step 2: Read the video stream in image frames

Step 3: Convert the imageFrame in BGR(RG color space represented as three matrices of red, green and with integer values from 0 to 255) to HSV(hue-saturation-value) color space. Hue describes a color in terms of saturation, represents the amount of gray color in that color and value describes the brightness or intensity of the color. This can be represented as three matrices in the range of 0-179, 0-255 and respectively.

Step 4: Define the range of each color and create the corresponding mask.

Step 5: Morphological Transform: Dilation, to remove noises from the images.

Step 6: bitwise_and between the image frame and mask is performed to specificaly detect that particular color and discrad others.

Step 7: Create contour for the individual colors to display the detected colored region distinguishly.

Step 8: Output: Detection of the colors in real-time.

Step5:output

color detection using python real time project

Downloads