Skip to content

Commit

Permalink
This is completed face detection tutorial app in opencv
Browse files Browse the repository at this point in the history
  • Loading branch information
ri3tykity committed Nov 21, 2014
0 parents commit 70198af
Show file tree
Hide file tree
Showing 38 changed files with 250 additions and 0 deletions.
Binary file added Debug/youtube_face_detection.exe
Binary file not shown.
Binary file added Debug/youtube_face_detection.ilk
Binary file not shown.
Binary file added Debug/youtube_face_detection.pdb
Binary file not shown.
Binary file added youtube_face_detection.sdf
Binary file not shown.
20 changes: 20 additions & 0 deletions youtube_face_detection.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "youtube_face_detection", "youtube_face_detection\youtube_face_detection.vcxproj", "{51836426-C125-423B-B980-250CC031E0D0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{51836426-C125-423B-B980-250CC031E0D0}.Debug|Win32.ActiveCfg = Debug|Win32
{51836426-C125-423B-B980-250CC031E0D0}.Debug|Win32.Build.0 = Debug|Win32
{51836426-C125-423B-B980-250CC031E0D0}.Release|Win32.ActiveCfg = Release|Win32
{51836426-C125-423B-B980-250CC031E0D0}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
Binary file added youtube_face_detection.suo
Binary file not shown.
Binary file added youtube_face_detection.v12.suo
Binary file not shown.
Binary file added youtube_face_detection/Debug/CL.read.1.tlog
Binary file not shown.
Binary file added youtube_face_detection/Debug/CL.write.1.tlog
Binary file not shown.
Binary file added youtube_face_detection/Debug/cl.command.1.tlog
Binary file not shown.
1 change: 1 addition & 0 deletions youtube_face_detection/Debug/link-cvtres.read.1.tlog
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
��
1 change: 1 addition & 0 deletions youtube_face_detection/Debug/link-cvtres.write.1.tlog
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
��
1 change: 1 addition & 0 deletions youtube_face_detection/Debug/link.5016-cvtres.read.1.tlog
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
��
1 change: 1 addition & 0 deletions youtube_face_detection/Debug/link.5016-cvtres.write.1.tlog
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
��
1 change: 1 addition & 0 deletions youtube_face_detection/Debug/link.5016.read.1.tlog
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
��
1 change: 1 addition & 0 deletions youtube_face_detection/Debug/link.5016.write.1.tlog
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
��
Binary file added youtube_face_detection/Debug/link.command.1.tlog
Binary file not shown.
Binary file added youtube_face_detection/Debug/link.read.1.tlog
Binary file not shown.
Binary file added youtube_face_detection/Debug/link.write.1.tlog
Binary file not shown.
Binary file added youtube_face_detection/Debug/main.obj
Binary file not shown.
Binary file added youtube_face_detection/Debug/mt.command.1.tlog
Binary file not shown.
Binary file added youtube_face_detection/Debug/mt.read.1.tlog
Binary file not shown.
Binary file added youtube_face_detection/Debug/mt.write.1.tlog
Binary file not shown.
Binary file added youtube_face_detection/Debug/rc.command.1.tlog
Binary file not shown.
Binary file added youtube_face_detection/Debug/rc.read.1.tlog
Binary file not shown.
Binary file added youtube_face_detection/Debug/rc.write.1.tlog
Binary file not shown.
Binary file added youtube_face_detection/Debug/vc100.idb
Binary file not shown.
Binary file added youtube_face_detection/Debug/vc100.pdb
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="asInvoker" uiAccess="false"></requestedExecutionLevel>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level='asInvoker' uiAccess='false' />
</requestedPrivileges>
</security>
</trustInfo>
</assembly>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#v4.0:v100
Debug|Win32|c:\users\krishna\documents\visual studio 2010\Projects\youtube_face_detection\|
31 changes: 31 additions & 0 deletions youtube_face_detection/Debug/youtube_face_detection.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
Build started 05-04-2014 12:26:11.
1>Project "c:\Users\Krishna\documents\visual studio 2010\Projects\youtube_face_detection\youtube_face_detection\youtube_face_detection.vcxproj" on node 2 (build target(s)).
1>InitializeBuildStatus:
Creating "Debug\youtube_face_detection.unsuccessfulbuild" because "AlwaysCreate" was specified.
ClCompile:
c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\CL.exe /c /IC:\Users\Krishna\Downloads\Programs\opencv\build\include /ZI /nologo /W3 /WX- /Od /Oy- /D WIN32 /D _DEBUG /D _CONSOLE /D _UNICODE /D UNICODE /Gm /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Fo"Debug\\" /Fd"Debug\vc100.pdb" /Gd /TP /analyze- /errorReport:prompt main.cpp
main.cpp
1>c:\users\krishna\downloads\programs\opencv\build\include\opencv2\flann\logger.h(66): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
c:\program files (x86)\microsoft visual studio 10.0\vc\include\stdio.h(234) : see declaration of 'fopen'
1>c:\users\krishna\documents\visual studio 2010\projects\youtube_face_detection\youtube_face_detection\main.cpp(39): warning C4018: '<' : signed/unsigned mismatch
1>c:\users\krishna\documents\visual studio 2010\projects\youtube_face_detection\youtube_face_detection\main.cpp(48): warning C4244: 'argument' : conversion from 'double' to 'int', possible loss of data
1>c:\users\krishna\documents\visual studio 2010\projects\youtube_face_detection\youtube_face_detection\main.cpp(48): warning C4244: 'argument' : conversion from 'double' to 'int', possible loss of data
ManifestResourceCompile:
All outputs are up-to-date.
Link:
c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\link.exe /ERRORREPORT:PROMPT /OUT:"c:\users\krishna\documents\visual studio 2010\Projects\youtube_face_detection\Debug\youtube_face_detection.exe" /INCREMENTAL /NOLOGO /LIBPATH:C:\Users\Krishna\Downloads\Programs\opencv\build\x86\vc10\lib opencv_calib3d246d.lib opencv_contrib246d.lib opencv_core246d.lib opencv_features2d246d.lib opencv_highgui246d.lib opencv_imgproc246d.lib opencv_legacy246d.lib opencv_nonfree246d.lib opencv_objdetect246d.lib opencv_photo246d.lib opencv_stitching246d.lib opencv_video246d.lib opencv_videostab246d.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /MANIFEST /ManifestFile:"Debug\youtube_face_detection.exe.intermediate.manifest" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:"c:\users\krishna\documents\visual studio 2010\Projects\youtube_face_detection\Debug\youtube_face_detection.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:"c:\users\krishna\documents\visual studio 2010\Projects\youtube_face_detection\Debug\youtube_face_detection.lib" /MACHINE:X86 Debug\youtube_face_detection.exe.embed.manifest.res
Debug\main.obj
Manifest:
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\bin\mt.exe /nologo /verbose /out:"Debug\youtube_face_detection.exe.embed.manifest" /manifest Debug\youtube_face_detection.exe.intermediate.manifest
All outputs are up-to-date.
LinkEmbedManifest:
All outputs are up-to-date.
youtube_face_detection.vcxproj -> c:\users\krishna\documents\visual studio 2010\Projects\youtube_face_detection\Debug\youtube_face_detection.exe
FinalizeBuildStatus:
Deleting file "Debug\youtube_face_detection.unsuccessfulbuild".
Touching "Debug\youtube_face_detection.lastbuildstate".
1>Done Building Project "c:\Users\Krishna\documents\visual studio 2010\Projects\youtube_face_detection\youtube_face_detection\youtube_face_detection.vcxproj" (build target(s)).

Build succeeded.

Time Elapsed 00:00:02.52
Binary file not shown.
61 changes: 61 additions & 0 deletions youtube_face_detection/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#include<stdio.h>
#include<math.h>
#include<opencv\cv.h>
#include<opencv\highgui.h>
#include<opencv2\objdetect\objdetect.hpp>
#include<opencv2\highgui\highgui.hpp>
#include<opencv2\imgproc\imgproc.hpp>
#include<vector>

using namespace cv;
using namespace std;

int main()
{
CascadeClassifier face_cascade, eye_cascade;
if(!face_cascade.load("c:\\haar\\haarcascade_frontalface_alt2.xml")) {
printf("Error loading cascade file for face");
return 1;
}
if(!eye_cascade.load("c:\\haar\\haarcascade_eye.xml")) {
printf("Error loading cascade file for eye");
return 1;
}
VideoCapture capture(0); //-1, 0, 1 device id
if(!capture.isOpened())
{
printf("error to initialize camera");
return 1;
}
Mat cap_img,gray_img;
vector<Rect> faces, eyes;
while(1)
{
capture >> cap_img;
waitKey(10);
cvtColor(cap_img, gray_img, CV_BGR2GRAY);
cv::equalizeHist(gray_img,gray_img);
face_cascade.detectMultiScale(gray_img, faces, 1.1, 10, CV_HAAR_SCALE_IMAGE | CV_HAAR_DO_CANNY_PRUNING, cvSize(0,0), cvSize(300,300));
for(int i=0; i < faces.size();i++)
{
Point pt1(faces[i].x+faces[i].width, faces[i].y+faces[i].height);
Point pt2(faces[i].x,faces[i].y);
Mat faceROI = gray_img(faces[i]);
eye_cascade.detectMultiScale(faceROI, eyes, 1.1, 2, 0 | CV_HAAR_SCALE_IMAGE, Size(30,30));
for(size_t j=0; j< eyes.size(); j++)
{
//Point center(faces[i].x+eyes[j].x+eyes[j].width*0.5, faces[i].y+eyes[j].y+eyes[j].height*0.5);
Point center( faces[i].x + eyes[j].x + eyes[j].width*0.5, faces[i].y + eyes[j].y + eyes[j].height*0.5 );
int radius = cvRound((eyes[j].width+eyes[j].height)*0.25);
circle(cap_img, center, radius, Scalar(255,0,0), 2, 8, 0);
}
rectangle(cap_img, pt1, pt2, cvScalar(0,255,0), 2, 8, 0);
}
imshow("Result", cap_img);
waitKey(3);
char c = waitKey(3);
if(c == 27)
break;
}
return 0;
}
85 changes: 85 additions & 0 deletions youtube_face_detection/youtube_face_detection.vcxproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{51836426-C125-423B-B980-250CC031E0D0}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>youtube_face_detection</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v120</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v120</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\prop x32.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="main.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
22 changes: 22 additions & 0 deletions youtube_face_detection/youtube_face_detection.vcxproj.filters
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>
3 changes: 3 additions & 0 deletions youtube_face_detection/youtube_face_detection.vcxproj.user
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
</Project>

0 comments on commit 70198af

Please sign in to comment.