Introduction: OBJECT DETECTION AND TRACKING USING OPENCV, VISUAL STUDIO C++ 2010 AND ARDUINO
In this project the Webcam sends video frames to the Visual Studio C++ which contains Open CV library running on our computer.
If Visual Studio C++ program detects the image of the object from the webcam then it calculates the co ordinates of X, Y axis and radius of the object.The co ordinates are sent accordingly to the arduino Mega/UNO via Serial communication between the arduino and visual studio c++.
After receiving the co-ordinates the servo motors moves in X and Y direction and follows the object.
Here is the video of it :) Sorry for the dull video i was tired at that time :)
1. Servo Motors x 2
2. Webcam ( any webcam) x 1
3. Arduino Mega/Uno x 1
4. External Power Supply 5V x 1
5. BreadBoard x 1
6. Single Core connecting wires
1. Arduino IDE
2. OpenCV 2.3.1
3. Visual Studio C++ 2010 Express SP1
1. Visual Studio C++ Code (attached)
2. Arduino Program Code (attached)
Step 1: Software Installation
1) Download and install the OpenCV -2.3.1. OpenCV contains all the important files needed for the making of the project.
OpenCV installation can cause some problems, So see this video it would help alot. This video shows proper installation of OpenCV.
2) Download and install the Microsoft VisualStudio C++ 2010 Express.
3) Download and install Arduino IDE
Step 2: Attaching Servo Motors AND WebCam
Construction is rather simple...
First Servo Motors:
Project i have made is temporary so i have fixed the servos with Galvanised Sheets, they are easy to cut and use and can be drilled easily plus they are flexible.
You can use various jigs of different material to attach the servos to make them permanent or temporary as suited by you.
Once you have attached the servo motors now its time to attach the Webcam.
At the horn of the second servo controlling the Y direction as shown in the pic.
Connect the webcam using J-Locks.
It surely isn't the most beautiful looking project but it does the work :P
Step 3: Connections
SERVO MOTOR CONNECTION:
1.Connect Lower Servo motor yellow wire with the PIN No - 9 of the arduino UNO.(controls x axis)
2.Connect Upper Servo motor yellow wire with the PIN No -10 of the arduino UNO(controls y axis)
3.Connect the red wire of the servo motor with 5v coming from arduino UNO as shown in the figure above.
4.Connect the black wire of the servos with the GND(Ground) coming from the arduino UNO as shown in figure above.
WEB CAM CONNECTION:
Connect the webcam with the usb port of the computer.
Connect the arduino UNO with the usb port of the computer.
Before uploading code in you arduino select proper COM Port and Board accordingly.
You must change the C++ code to match the PC's com port and baud rate with Arduino UNO/MEGA. Also, the C++ code must be told which USB port the webcam is using.
Step 4: FINAL STEP :D UPLOADING
Upload the program in arduino UNO
VISUAL STUDIO C++
If everything was done correctly then.
Start the program and 4 screens would open up...
1. First screen would be for selecting the appropriate HSV values so that u can opt for particular object you want to track for.
2.Second screen would show the original image of your webcam.
3.Third screen would show the processed image of your webcam usually a binary image.
4.Fourth screen would show u the x axis, y axis and radius of that image.
Step 5: Sources
Some of the links i followed and helped me alot.
If you need more help feel free to contact me
email ID: email@example.com
I hope u enjoyed my instructable :P
Thank you :D :D
Vairamk made it!