- Feb 20, 2013: In response to a question by student Hala Abuhasna if you wish to use the .NET Serial class, use the naming convention "\\\\.\\COMn" and replace n with a number > 9 to define your com port for COM ports above 9 such as COM10, COM11, etc.
- Mar 23, 2012: Featured on Adafruit's Blog
- Mar 23, 2012: Featured on Interactive Design
- Dec 13, 2011: Featured on Floss For Science
This guide will also be maintained on my blog http://techbitar.blogspot.com/2012/04/face-detection-and-tracking-with.html
INTRODUCTION
In this project I have assembled a face detection and tracking system. You can see the video of the final project here:
Basically, the webcam sends video frames to OpenCV running on a Windows PC. If OpenCV detects a face it will track it and calculate its center's X,Y coordinates. The coordinates are then passed on to the Arduino via a serial USB connection. The Arduino controls the movement of the webcam with the help of two pan/tilt servos to follow the detected face.
OpenCV (Open Source Computer Vision Library: http://opencv.willowgarage.com/wiki/) is an open-source library that includes several hundreds of real-time computer vision algorithms. The OpenCV 2.x library is a C++ API.
This is an integration project between hardware and software tools. The image processing C++ code samples are provided with the openCV library and all I did was to modify the sample code for this project. I removed some of the unnecessary code and added serial communications to it so it can send X,Y values to Arduino.
CREDIT
This project would not have been possible without the team who developed OpenCV. I also benefited from Ryan Owens' tutorial (http://www.sparkfun.com/tutorials/304) which is based on Processing, OpenFrameworks, and an earlier version of OpenCV. I tried to install Processing and OpenFrameworks with no luck. So Instead, I opted for Microsoft Visual C++ 2010 Express and the latest version of OpenCV which is 2.3.1 without any middleware or wrappers.
TOOLS
Software Required
Arduino IDE 1.0 for Windows
OpenCV 2.3.1 SuperPack For Windows
Microsoft Visual C++ 2010 Express SP1
Serial C++ Library for Win32 (by Thierry Schneider)
Code Required
- OpenCV C++ (attached) techbitarFaceDetection.cpp (based on OpenCV's example facedetect.cpp)
- Arduino's (attached) cam_servo.ino (based on Ryan Owens' example SerialServoControl.pde)
Hardware Required
- PC preferably running Windows 7 SP1. The faster CPU the better.
- Arduino Uno or compatible + power source.
- Standard servos X 2.
- Webcam w/UBS interface.
- Breadboard.
- Jumper wires.
- Hobby wire to tie pan/tilt servos and webcam together.
Remove these ads by
Signing UpStep 1: Installation and integration issues
http://sourceforge.net/projects/opencvlibrary/files/opencv-win/2.3.1/
2) Download and install Microsoft Visual C++ 2010 Express
http://www.microsoft.com/visualstudio/en-us/products/2010-editions/visual-cpp-express
The OpenCV installation documentation explains how to make Visual C++ aware of the OpenCV support files (include, bin, etc). This is not a one-click job. Careful attention must be given to how Visual C++ must be configured to recognize OpenCV files.
The OpenCV team tested version 2.3.1 and Visual C++ 2010 on Windows 7 SP1. If you are using a different configuration, be prepared for a few hiccups.









































Visit Our Store »
Go Pro Today »




I have tried for countless hours today to get this to work but to no success. I can't get the visual/openCV part to work. I think I have narrowed it down to:
1) Not ever using visual studio or openCV before
2) Not being able to "run" visual studio
I would be extremely grateful for the instructions from the arduino code to the point of using the visual basic program.
Thanks!
I'm getting following error in Visual Studio 2010
Error 2 error C2664: 'CreateFileW' : cannot convert parameter 1 from 'char [10]' to 'LPCWSTR
CreateFileW function is in WinBase.h(c:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Include\WinBase.h)
please help...
I used :
-Microsoft Windows 7 Ultimate SP1 32-Bit
-Microsoft Visual Studio 2008 Professional
-OpenCV2.3
-Tetraedre Serial Library(Tserial.h and Tserial.cpp)
-Arduino UNO R3
-Pan tilt mechanism
-Web Cam
errors ;
1>main.obj : error LNK2019: unresolved external symbol "public: void __thiscall Tserial::disconnect(void)" (?disconnect@Tserial@@QAEXXZ) referenced in function "int __cdecl _main(int,char const * *)" (?_main@@YAHHPAPBD@Z)
1>main.obj : error LNK2019: unresolved external symbol "public: int __thiscall Tserial::connect(char *,int,enum serial_parity)" (?connect@Tserial@@QAEHPADHW4serial_parity@@@Z) referenced in function "int __cdecl _main(int,char const * *)" (?_main@@YAHHPAPBD@Z)
1>main.obj : error LNK2019: unresolved external symbol "public: __thiscall Tserial::Tserial(void)" (??0Tserial@@QAE@XZ) referenced in function "int __cdecl _main(int,char const * *)" (?_main@@YAHHPAPBD@Z)
1>main.obj : error LNK2019: unresolved external symbol "public: __thiscall Tserial::~Tserial(void)" (??1Tserial@@QAE@XZ) referenced in function "public: void * __thiscall Tserial::`scalar deleting destructor'(unsigned int)" (??_GTserial@@QAEPAXI@Z)
1>main.obj : error LNK2019: unresolved external symbol "public: void __thiscall Tserial::sendChar(char)" (?sendChar@Tserial@@QAEXD@Z) referenced in function "void __cdecl detectAndDisplay(class cv::Mat)" (?detectAndDisplay@@YAXVMat@cv@@@Z)
I'm going crazy, Why I get this errors? Please give me an answer..
Thanks, Good works.
I do not understand the error.
Help me please. :)
Settings made of OpenCV: http://siddhantahuja.wordpress.com/2011/07/18/getting-started-with-opencv-2-3-in-microsoft-visual-studio-2010-in-windows-7-64-bit/
Program error:
1>------ Operación Generar iniciada: proyecto: camara_prueba_no1, configuración: Debug x64 ------
1>Compilación iniciada a las 01/12/2012 07:58:24 p. m..
1>InitializeBuildStatus:
1> Aplicando tarea Touch a "x64\Debug\camara_prueba_no1.unsuccessfulbuild".
1>ClCompile:
1> Todas las salidas están actualizadas.
1> camara_prueba_no1.cpp
1>camara_prueba_no1.cpp(95): warning C4244: 'argumento' : conversión de 'double' a 'int'; posible pérdida de datos
1>camara_prueba_no1.cpp(95): warning C4244: 'argumento' : conversión de 'double' a 'int'; posible pérdida de datos
1>camara_prueba_no1.cpp(96): warning C4244: 'argumento' : conversión de 'double' a 'int'; posible pérdida de datos
1>camara_prueba_no1.cpp(96): warning C4244: 'argumento' : conversión de 'double' a 'int'; posible pérdida de datos
1>ManifestResourceCompile:
1> Todas las salidas están actualizadas.
1>camara_prueba_no1.obj : error LNK2019: símbolo externo "public: void __cdecl Tserial::disconnect(void)" (?disconnect@Tserial@@QEAAXXZ) sin resolver al que se hace referencia en la función main
1>camara_prueba_no1.obj : error LNK2019: símbolo externo "public: bool __cdecl cv::CascadeClassifier::load(class std::basic_string,class std::allocator > const &)" (?load@CascadeClassifier@cv@@QEAA_NAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) sin resolver al que se hace referencia en la función main
1>camara_prueba_no1.obj : error LNK2019: símbolo externo "public: int __cdecl Tserial::connect(char *,int,enum serial_parity)" (?connect@Tserial@@QEAAHPEADHW4serial_parity@@@Z) sin resolver al que se hace referencia en la función main
1>camara_prueba_no1.obj : error LNK2019: símbolo externo "public: __cdecl Tserial::Tserial(void)" (??0Tserial@@QEAA@XZ) sin resolver al que se hace referencia en la función main
1>camara_prueba_no1.obj : error LNK2019: símbolo externo "public: __cdecl Tserial::~Tserial(void)" (??1Tserial@@QEAA@XZ) sin resolver al que se hace referencia en la función "public: void * __cdecl Tserial::`scalar deleting destructor'(unsigned int)" (??_GTserial@@QEAAPEAXI@Z)
1>camara_prueba_no1.obj : error LNK2019: símbolo externo "public: void __cdecl Tserial::sendChar(char)" (?sendChar@Tserial@@QEAAXD@Z) sin resolver al que se hace referencia en la función "void __cdecl detectAndDisplay(class cv::Mat)" (?detectAndDisplay@@YAXVMat@cv@@@Z)
1>camara_prueba_no1.obj : error LNK2019: símbolo externo "public: virtual void __cdecl cv::CascadeClassifier::detectMultiScale(class cv::Mat const &,class std::vector,class std::allocator > > &,double,int,int,class cv::Size_,class cv::Size_)" (?detectMultiScale@CascadeClassifier@cv@@UEAAXAEBVMat@2@AEAV?$vector@V?$Rect_@H@cv@@V?$allocator@V?$Rect_@H@cv@@@std@@@std@@NHHV?$Size_@H@2@2@Z) sin resolver al que se hace referencia en la función "void __cdecl detectAndDisplay(class cv::Mat)" (?detectAndDisplay@@YAXVMat@cv@@@Z)
1>camara_prueba_no1.obj : error LNK2019: símbolo externo "public: __cdecl cv::CascadeClassifier::CascadeClassifier(void)" (??0CascadeClassifier@cv@@QEAA@XZ) sin resolver al que se hace referencia en la función "void __cdecl `dynamic initializer for 'face_cascade''(void)" (??__Eface_cascade@@YAXXZ)
1>camara_prueba_no1.obj : error LNK2019: símbolo externo "public: virtual __cdecl cv::CascadeClassifier::~CascadeClassifier(void)" (??1CascadeClassifier@cv@@UEAA@XZ) sin resolver al que se hace referencia en la función "void __cdecl `dynamic atexit destructor for 'face_cascade''(void)" (??__Fface_cascade@@YAXXZ)
1>C:\Users\marti_000\documents\visual studio 2010\Projects\camara_prueba_no1\x64\Debug\camara_prueba_no1.exe : fatal error LNK1120: 9 externos sin resolver
1>
1>ERROR al compilar.
1>
1>Tiempo transcurrido 00:00:03.71
========== Generar: 0 correctos, 1 incorrectos, 0 actualizados, 0 omitidos ==========
Can you please explain me that in your techbitarFaceDetection.cpp file, what is exactly being done with the variables LSB and MSB. Further, what does the following line do:
LSB = faces[i].x & 0xff;
Serial C++ Library for Win32 (by Thierry Schneider)
I can see that the problem is from the serial communication but i am not sure how to solve it. Any help will be appreciated.
can you please tell me how to load these classifiers
i placed \\.\ before my com port number..
Voted!
cya!