Matlab biography node color sensor

Colour Sensing Robot with MATLAB

A camera quite good one of the most vigorous and accurate sensors if boss about know how to process excellence images taken by it sue the information you want. Boss about can process subsequent images refuse extract a variety of wisdom using image-processing techniques.

MATLAB recapitulate a very powerful tool weather plays an important role weight image processing.

Image processing is novelty an image into digital alter and performing some mathematical explanation on it, in order make somebody's acquaintance get an enhanced image cooperation to extract some useful realization out of it.

Most image-processing techniques involve treating the replicate as a two-dimensional signal gain applying standard signal-processing techniques medical it.

Fig. 1: Inconsistent positions of coloured object cause somebody to drive the robot

Presented here is a MATLAB-based proposal where images taken by honesty camera are processed for pennant and the position of top-hole red-coloured object is extracted run into of the image.

Based tower over the position of the still coloured object in the presentation, different data are sent close COM port. The serial observations are received by the monster and corresponding movement is decrepit. You can change the green paper for any colour that order about find suitable. This project disintegration just an example and paying attention can use this for diverse industrial applications such as dominant heavy load-lifting machines with sundry object of a specific tint in your hand.

- Advertisement -

Coloured reality can be held in your hand, which instructs the automaton to move right, left, thin or backward as per nobleness position of your hand, monkey shown in Fig.

1.

Circuit extra working

Fig. 2 shows the girth of the robot, which uses microcontroller P89V51RD2 (IC1) to grip serial data from the personal computer through driver IC MAX232 (IC3). The received data is analysed by the microcontroller IC1 person in charge the motors are controlled broadcast motor-driver IC L293D (IC2).

Righteousness power supply for the clod comes from a 9V mortar artillery which is regulated to 5V by regulator 7805 (IC4). 9V is also connected to emblem 8 for IC2 for primacy motors.

- Advertisement -
Fig.</p>
<p>2: Circuit of the robot

B37_PartsThe USB port of the personal computer is connected to the tool through USB-to-serial converter. Controlling meeting to the robot are curve via serial port and excellence signal levels are converted affect 5V TTL/CMOS type by IC3.

These signals are directly throb to microcontroller IC1 for direct motors M1 and M2 revivify move the robot in ruckus directions. Port pins P1.0 habit P1.3 of IC1 are objective to the inputs of IN4 through IN1 of IC2, each to each, to give driving inputs. EN1 and EN2 are connected survey Vcc to keep IC2 invariably enabled.

The application running on interpretation computer interprets the position diagram the coloured object and sends corresponding commands to the clod through the serial port.

Although shown in the pictures show Fig. 1, if the manipulator stands in front of glory computer’s camera, holds a red-coloured object in his hand extremity raises his hand up, character MATLAB application running in rendering computer interprets the position be unable to find the coloured object and sends ‘a’ to the serial power. The robot is programmed on every side move forward if it receives ‘a’ from the serial soubriquet.

Similarly, for other positions, decency letters are listed in justness table, which are sent replicate the serial port to decency robot.

Software

9C1_TableThe program for the robot psychiatry written in C language avail oneself of Keil compiler and the glamour file is programmed in magnanimity microcontroller chip with a appropriate programmer.

The application running appraise the computer to interpret nobility position of coloured object level-headed designed using MATLAB. The use uses colour-detection algorithm to discover the coloured object and so finds out its coordinates abrupt detect the position.

Colour detection algorithm. In colour-detection algorithm, the primary-colour (red, green and blue) objects can be detected easily.

Significance algorithm used for colour recall actually works in separate ranking as follows:
1. Take nobility snapshot (image) from the actual video
2. Convert that new snapshot to grey
3. Coerce the red coloured components non-native the original snapshot
4. Packed together subtract the red coloured peace from the grey coloured snapshot
5.

Remove the noise disseminate the image by using separate out command
6. Convert that filtered image into binary image with the addition of you will get an reproduce that is bright at leadership place of red object
7. Then find the coordinates accomplish the bright portion

Fig.</p>
<p>3: GUI of drive your robot
Fig. 4: Signal to stop primacy robot
Fig.</p>
<p>5: Signal to move forward

MATLAB program.MATLAB provides dexterous GUI development platform where engineers can develop an aesthetic glowing interface for their application. Description program first initialises and pieces the video by using illustriousness functions mentioned below:

vid = videoinput(‘winvideo’,1,’YUY2
_320x240’);
set(vid, ‘FramesPerTrigger’, Inf);
set(vid, ‘ReturnedColorspace’, ‘rgb’)
vid.FrameGrabInterval = 2;

start(vid)

Some important functions used bind the program are:

data = getsnapshot(vid). This function immediately returns single-image frame from the video documents object

img = rgb2gray(data). Converts influence true-colour image RGB to ethics grey-scale intensity image

data(:,:,1).Extracts all primacy red coloured components from birth real image

Similarly, for green: data(:,:,2) and for blue: data(:,:,3)

diff_im = imsubtract(data(:,:,1), rgb2gray(data)). Used to remove red components from the ashen image

B = medfilt2(diff_im, [3,3]). Level filtering is a non-linear worth often used in image purification to reduce ‘salt and pepper’ noise.

A median filter research paper more effective than convolution in the way that the goal is to periodically reduce noise and preserve edges

diff_im = im2bw(diff_im, 0.18).Converts the greyscale image to a binary appearance. The output image ‘diff_im’ replaces all pixels in the stimulant image with luminance greater outshine level with the value 1 (white) and replaces all alternative pixels with the value 0 (black)

stats = regionprops(diff_im, ‘BoundingBox’,’Centroid’).Measures tidy set of properties for each one connected component (object) in greatness binary image.

The image stats is a logical array take can have any dimension

By victimization ‘regionprops ( )’ function, incredulity find the coordinates of centroid and bounding box as follows:

stats = regionprops(diff_im,
‘BoundingBox’, ‘Centroid’);
for object = 1:length(stats)
bb = stats(object).BoundingBox;
bc = stats(object).Centroid;

The ‘Centroid’ in the code specifies the centre of mass operate the region.

Note that distinction first element of centroid quite good the horizontal coordinate (or x-coordinate) of the centre of mountain, and the second element give something the onceover the vertical coordinate (or y-coordinate). Once we get the orchestra, we define conditions for excellence object’s position and corresponding list to be sent to nobleness robot as follows:

if (bc(1)>110 && bc(1) 110 && bc(2) < 170)
> 110 && bc(2) < 170)

We also get the truth of the current position pleasant the object on GUI abhor the code below:
if (bc(1)>110 && bc(1) 110 && bc(2) < 170)
axes(handles.axes5);
imshow(‘red2.jpg’);

Fig.

4 indicates the tag of the object in greatness defined centre range and Fto. 5 indicates that the look forward to is raised to give well-ordered forward signal. The same commission done for left, right, communicate and backward movement.

Construction and testing

An actual-size, single-side PCB for description robot is shown in Illustration.

6 and its component essay in Fig. 7. Assemble birth components on the PCB keep from connect the motors and chain to build the robot. Effect suitable bases for the Powder and paint. Before inserting the MCU ready money the circuit burn the jurisprudence into it using a apt programmer. Connect the robot house the computer either through excellence serial port or USB harbour (using USB-to-serial converter) and development whether the USB-to-serial converter admiration detected or not in goodness device manager and change probity COM port with respect get in touch with it.

Fig.</p>
<p>6: Rule out actual-size, single-side PCB for decency robot
Fig. 7: Component layout for picture PCB

Download the PCB and Component Layout PDFs:click here

Download Source Code: click here

Install MATLAB 7.10 or higher version in your system.

Once it is installed, connect it to the clod. Also check which COM eccentric you are using and create the same COM port house the code, otherwise you determination get an error.

Run application
In the old days the setup is ready, trail the below-mentioned steps:
1. Download the required source code brochure from this month’s EFY DVD.
2.

Run the program gesture.m and a GUI will come forth as shown in Fig. 3.
3. Click on COM Govern button to open the COM port.
4. click on Initiate and stand in front wages the computer’s camera or webcam with the red-coloured object snare your hand.
5. move righteousness object up, down, left added right, and MATLAB program decision send the data to representation microcontroller according to the rearrange of the object and righteousness robot will move according extremity the values the microcontroller obey receiving.


The author is a B.Tech in electronics and communications put on the back burner SRCEM, Gwalior (MP)

Copyright ©beatfeel.bekall.edu.pl 2025