0% found this document useful (0 votes)
32 views

Matlab Based Autonomous Ball Searching Robot Using Image Processing

This document describes a MATLAB-based autonomous ball searching robot that uses image processing. The robot's objective is to search for and track a ball of a particular color in a given area. It uses a webcam, microcontroller, motors, and other hardware controlled by MATLAB code. The code captures images, detects the ball using color identification, performs noise reduction, finds the largest object, determines its centroid, and sends commands to the microcontroller to control the robot's movement.

Uploaded by

nikhil3298
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views

Matlab Based Autonomous Ball Searching Robot Using Image Processing

This document describes a MATLAB-based autonomous ball searching robot that uses image processing. The robot's objective is to search for and track a ball of a particular color in a given area. It uses a webcam, microcontroller, motors, and other hardware controlled by MATLAB code. The code captures images, detects the ball using color identification, performs noise reduction, finds the largest object, determines its centroid, and sends commands to the microcontroller to control the robot's movement.

Uploaded by

nikhil3298
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 24

MATLAB BASED AUTONOMOUS

BALL SEARCHING ROBOT USING


IMAGE PROCESSING
OBJECTIVE OF THIS PROJECT
OUR OBJECTIVE IN THIS PROJECT IS TO DESIGN A ROBOT WHICH
WILL SEARCH FOR A BALL OF PARTICULAR COLOUR IN A GIVEN
AREA AND ON SUCCESSFUL DETECTION OF THE BALL ,IT WILL
TRACK THE BALL.HERE THE SEARCHING AND TRACKING OF THE
BALL WILL BE DONE USING IMAGE PROCESSING
Block Diagram

  USB web camera


PC
 
 

 
Serial Port

  LCD Right
MAX 232 Motor

Microcontroller
Motor
Battery Power  
Supply
Driver Left
Motor
HARDWARE
 MAX 232
 MICROCONTROLLER
 L293D
 MOTORS
 LCD
 PASSIVE COMPONENTS
89S51
FEATURES OF 89S51
• 4K Bytes of In-System
Programmable (ISP) Flash Memory
• 4.0V to 5.5V Operating Range
• Fully Static Operation: 0 Hz to 33
MHz
• Three-level Program Memory Lock
• 128 x 8-bit Internal RAM
• 32 Programmable I/O Lines
• Two 16-bit Timer/Counters
• Six Interrupt Sources
• Full Duplex UART Serial Channel
VOLTAGE REGULATOR 7805
 7805 is a three terminal
positive voltage regulator.
 Input, Ground ,Output
 It is used to provide regulated

power supply to the


 It can take a higher, crappy

DC voltage and turn it into a


nice, smooth 5 volts DC.
 Input range is 8 volts to 30

volts
LCD 16x2
 RS(REGISTER SELECTION)
RS=0;COMMAND REGISTER
RS=1;DATA REGISTER
 R/W(READ/WRITE)
R/W=1:MUC WANTS TO READ
R/W=0; MUC WANTS TO
WRITE
 E=USED TO LATCH DATA
PRESENT ON DATA
PINS.HIGH TO LOW SIGNAL
INFORM LCD THAT WE HAVE
PLACED OUR DATA ON
DATA PINSAND ACCEPT IT.
LOGIC TABLE
LOGIC RS232 TTL

1 -3V TO -27V (IDEALLY- +5 V


10V)

0 +3V to +27V (IDEALLY -5 V


+10V)
MAX 232
 Microcontroller and pc both have in-built UART
 PC serial port works on rs-232 and The microcontroller

UART works on the TTL logic.


 Operates From a Single 5-V Power Supply
 Operates Up To 120 Kbit/s
 Two Drivers and Two Receivers
 ±30V Input Levels
 Low Supply Current 8 mA Typical
NULL MODEM CONNECTION
The pins 1, 4, 6 and 7, 8 of RS232 connector are used for
handshaking purpose. However during interfacing of
micro controller we do not need any handshaking as
microcontroller is fast enough to capture data as it comes.
So the handshaking pins are loop backed with each other.
Whenever pc checks for modem (here microcontroller) to
be ready it gets positive acknowledgement and by
loopback connection itself.
This shorting of pins 1, 2, 4 and7, 8 is known as ‘null
modem connection’.
L293D
 The dc motors which we
are going to use for
robotic movement will
require large voltage(12-
30V)
 It is a 16 pin chip.
 The Device is a

monolithic four channel


driver designed to accept
standard TTL logic levels
Microprocessor

DATA DIRECTION IN WHICH P2.0 P2.1 P2.2 P2.3 P2.4 P2.5


RECEIVED ROBOT TO BE MOVED
LF LB LE RB RF RE

1 Forward 1 0 1 0 1 1

2 Backward 0 1 1 1 0 1

3 Right 1 0 1 1 0 1

4 Left 0 1 1 0 1 1

5 stop 0 0 0 0 0 0
Setting SCON and TMOD registers

SCON register

SM0 SM1 SM2 REN TB8 RB8 TI RI

TMOD register

GATE C/T M1 M0 GATE C/T M1 M0


TIMER1 TIMER0
TH1 Registers
Timer1 TH1 registers values for various baud rate with
SMOD=0
Baud Rate TH1(Decimal) TH1(Hex)

9600 -3 FD

4800 -6 FA

2400 -12 F4

1200 -24 E8
In our project we decided to use the serial
mode 1 at baud rate of 9600.For serial
communication we need to program the
timer1 in mode Auto reload mode i.e. mode
2.
Thus we obtained the following value to be
loaded in SCON and TMOD register.
 TMOD=’0010 0000’=0x20
 SCON=’0101 0000’=0x50
 TR=1
Development of MATLAB code
START

INITIALISE VIDEOOBJECT AND PREVIEW

CAPTURE FRAME

OBTAIN BINARY IMAGE

PERFORM VARIOUS MORPHOLOGICAL OPERATIONS FOR NOISE REDUCTION


LABEL THE BW IMAGE TO OBTAIN LARGEST OBJECT

FIND CENTROID OF LARGEST OBJECT

FIND THE LOCATION AND SEND APPROPRIATE CONNAMD


SERIALLY
STEPS FUNCTION/PROPERTIES USED
Initializing video object and obj
preview =videoinput(adaptorname,deviceID,format)
Capture frame ReturnedColorSpace
frame = getsnapshot(obj)
Ball detection by color [d1,d2,d3,...,dn] = size(X)
identification
Noise reduCtion SE= strel('disk', R, N)
IM2 = imclose(IM,SE)
IM2 = imopen(IM,SE)
BW2 = imfill(BW,'holes')
BW2 = bwareaopen(BW,P,conn)
Obtaining the largest [L,num] = bwlabel(BW,n)
object STATS = regionprops(L, properties)
Finding the centroid ind = find(X)
M = mean(A)
Serial communication obj
• Algorithm Finding The Largest Object

[L no_of_connected_objects]= bwlabel(imgray,8);
area_of_largest_object=0;
[L no_of_connected_objects]= bwlabel(imgray,8);
area_of_largest_object=0
X=0
Y=0;
if(no_of_connected_objects~=0
STATS = regionprops(L,'Area');
for i = 1:no_of_connected_objects
if STATS(i).Area > area_of_largest_object;
index_of_largest_object=i;
area_of_largest_object=STATS(i).Area;
end
end
imgray=(L==index_of_largest_object);
[r c] = find(L==index_of_largest_object
X=round(mean(r))
Y=round(mean(c))
Sending command serially
Direction Data send
serially
Forward 1
Right 3
Left 4
Stop 5

ser= serial('COM3','BaudRate',9600,'DataBits',8);
fopen(ser);
fwrite(ser,1,'async');
APPLICATIONS
Industrial robots
Using Robotic arm and modification as per the industrial
requirement and specification it can made most useful for various
operations like pick and place, loading-unloading etc.It can be
used for conveyer tracking.
Various military applications
In military application field, for some unfeasible circumstances
where need of robot or robot based application can be substituted
for humans.
Medical application
It can be used for calculation of RBC’s in blood testing
Miscellaneous
For shape identification, error and abnormality detection
CONCLUSIONS
 Processing speed augments if we increase the size of the
capturing image frame.
 Our robot is subjective to environmental conditions, plus
limitation over power supply
 It is wired due to which it has limited range of mobility.
 It is highly dependent on the processing power of the
computer
 Also dependent on the resolution of the camera used.
Future Scope
 It can be made wireless, hence increasing the mobility
range and maneuvered with the help of wireless media
such as RF module, Bluetooth etc.
 In built system for video analysis
 Robotic arm can be added in the hardware thus increasing
the overall system performance and efficiency
 Shape identification can also be included.
 Processing can be done without computer
REFERENCES
• Muhammad Ali Mazidi, Janice Gillispie Mazidi,8051
Microcontroller and Embedded Systems, Prentice-Hall.
• The documentation and demos provided in the Help section
of MATLAB
• http://www.mathworks.com/MATLABcentral/fileexchange/
• http://www.embedautomation.com/content/i-see-video-
geometric-shape-detection-using-image-processing-
MATLAB
• Chapman, Stephen J., MATLAB Programming for Engineers,
Brooks Cole, 2001.
• http://blogs.mathworks.com/videos/2010/12/10/how-to-
save-and-restore-state-of-a-gui-in-MATLAB/
• http://blinkdagger.com/MATLAB/MATLAB-gui-graphical-
user-interface-tutorial-for-beginners/
• http://blinkdagger.com/MATLAB/how-long-does-it-take-
to-run-your-code/

You might also like