Build tutorial codes together with other samples
These codes should be included into regular builds.
This commit is contained in:
@@ -28,7 +28,7 @@ RNG rng(12345);
|
||||
/**
|
||||
* @function main
|
||||
*/
|
||||
int main( int argc, const char** argv )
|
||||
int main( void )
|
||||
{
|
||||
CvCapture* capture;
|
||||
Mat frame;
|
||||
@@ -41,7 +41,7 @@ int main( int argc, const char** argv )
|
||||
capture = cvCaptureFromCAM( -1 );
|
||||
if( capture )
|
||||
{
|
||||
while( true )
|
||||
for(;;)
|
||||
{
|
||||
frame = cvQueryFrame( capture );
|
||||
|
||||
@@ -72,10 +72,10 @@ void detectAndDisplay( Mat frame )
|
||||
//-- Detect faces
|
||||
face_cascade.detectMultiScale( frame_gray, faces, 1.1, 2, 0|CV_HAAR_SCALE_IMAGE, Size(30, 30) );
|
||||
|
||||
for( int i = 0; i < faces.size(); i++ )
|
||||
for( size_t i = 0; i < faces.size(); i++ )
|
||||
{
|
||||
Point center( faces[i].x + faces[i].width*0.5, faces[i].y + faces[i].height*0.5 );
|
||||
ellipse( frame, center, Size( faces[i].width*0.5, faces[i].height*0.5), 0, 0, 360, Scalar( 255, 0, 255 ), 2, 8, 0 );
|
||||
Point center( faces[i].x + faces[i].width/2, faces[i].y + faces[i].height/2 );
|
||||
ellipse( frame, center, Size( faces[i].width/2, faces[i].height/2), 0, 0, 360, Scalar( 255, 0, 255 ), 2, 8, 0 );
|
||||
|
||||
Mat faceROI = frame_gray( faces[i] );
|
||||
std::vector<Rect> eyes;
|
||||
@@ -83,11 +83,11 @@ void detectAndDisplay( Mat frame )
|
||||
//-- In each face, detect eyes
|
||||
eyes_cascade.detectMultiScale( faceROI, eyes, 1.1, 2, 0 |CV_HAAR_SCALE_IMAGE, Size(30, 30) );
|
||||
|
||||
for( int j = 0; j < eyes.size(); j++ )
|
||||
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 eye_center( faces[i].x + eyes[j].x + eyes[j].width/2, faces[i].y + eyes[j].y + eyes[j].height/2 );
|
||||
int radius = cvRound( (eyes[j].width + eyes[j].height)*0.25 );
|
||||
circle( frame, center, radius, Scalar( 255, 0, 0 ), 3, 8, 0 );
|
||||
circle( frame, eye_center, radius, Scalar( 255, 0, 0 ), 3, 8, 0 );
|
||||
}
|
||||
}
|
||||
//-- Show what you got
|
||||
|
@@ -28,7 +28,7 @@ RNG rng(12345);
|
||||
/**
|
||||
* @function main
|
||||
*/
|
||||
int main( int argc, const char** argv )
|
||||
int main( void )
|
||||
{
|
||||
CvCapture* capture;
|
||||
Mat frame;
|
||||
@@ -41,7 +41,7 @@ int main( int argc, const char** argv )
|
||||
capture = cvCaptureFromCAM( -1 );
|
||||
if( capture )
|
||||
{
|
||||
while( true )
|
||||
for(;;)
|
||||
{
|
||||
frame = cvQueryFrame( capture );
|
||||
|
||||
@@ -73,7 +73,7 @@ void detectAndDisplay( Mat frame )
|
||||
//-- Detect faces
|
||||
face_cascade.detectMultiScale( frame_gray, faces, 1.1, 2, 0, Size(80, 80) );
|
||||
|
||||
for( int i = 0; i < faces.size(); i++ )
|
||||
for( size_t i = 0; i < faces.size(); i++ )
|
||||
{
|
||||
Mat faceROI = frame_gray( faces[i] );
|
||||
std::vector<Rect> eyes;
|
||||
@@ -83,14 +83,14 @@ void detectAndDisplay( Mat frame )
|
||||
if( eyes.size() == 2)
|
||||
{
|
||||
//-- Draw the face
|
||||
Point center( faces[i].x + faces[i].width*0.5, faces[i].y + faces[i].height*0.5 );
|
||||
ellipse( frame, center, Size( faces[i].width*0.5, faces[i].height*0.5), 0, 0, 360, Scalar( 255, 0, 0 ), 2, 8, 0 );
|
||||
Point center( faces[i].x + faces[i].width/2, faces[i].y + faces[i].height/2 );
|
||||
ellipse( frame, center, Size( faces[i].width/2, faces[i].height/2), 0, 0, 360, Scalar( 255, 0, 0 ), 2, 8, 0 );
|
||||
|
||||
for( int j = 0; j < eyes.size(); j++ )
|
||||
for( size_t j = 0; j < eyes.size(); j++ )
|
||||
{ //-- Draw the eyes
|
||||
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 eye_center( faces[i].x + eyes[j].x + eyes[j].width/2, faces[i].y + eyes[j].y + eyes[j].height/2 );
|
||||
int radius = cvRound( (eyes[j].width + eyes[j].height)*0.25 );
|
||||
circle( frame, center, radius, Scalar( 255, 0, 255 ), 3, 8, 0 );
|
||||
circle( frame, eye_center, radius, Scalar( 255, 0, 255 ), 3, 8, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user