Lets start recognizing "eyes" (also "faces") and later on we will recognize anything (training our own "Haar Cascades").
We select and use a CascadeClassifier, for eyes "haarcascade_eye.xml"
There are a few "false" positives that we can fine tune with these values:
cv::Size( 30, 60 ) where 30 is the smallest size allowed ad 60 is the largest value allowed
cv1.prg modified to recognize "eyes"
#include "FiveWin.ch"
#define WINDOW_AUTOSIZE 1
function Main()
聽 聽local hMat := cv_ImRead( "007.jpg" )
聽 聽cv_namedWindow( "window title", WINDOW_AUTOSIZE )
聽 聽cv_ImShow( "window title", hMat )
聽 聽cv_WaitKey()
return nil
#pragma BEGINDUMP
#include <hbapi.h>
#include <opencv.hpp>
#include <opencv2/opencv.hpp>
#include <opencv2/imgproc.hpp>
static cv::Mat mat1;
HB_FUNC( CV_IMREAD )
{
聽 聽cv::CascadeClassifier face_cascade;
聽 聽std::vector<cv::Rect> faces;
聽 聽face_cascade.load( "c:/opencv/sources/data/haarcascades/haarcascade_eye.xml" );
聽 聽mat1 = cv::imread( hb_parc( 1 ) );
聽 聽face_cascade.detectMultiScale( mat1, faces, 1.1, 3, 0, cv::Size( 30, 60 ) ); 聽
聽 聽for( size_t i = 0; i < faces.size(); i++ )
聽 聽 聽 cv::rectangle( mat1, faces[ i ], cv::Scalar( 255, 255, 255 ), 1, 1, 0 );
聽 聽hb_retptr( &mat1 );
}
HB_FUNC( CV_NAMEDWINDOW )
{
聽 聽cv::namedWindow( hb_parc( 1 ), hb_parnl( 2 ) );
}
HB_FUNC( CV_IMSHOW )
{
聽 聽cv::imshow( hb_parc( 1 ), * ( ( cv::Mat * ) hb_parptr( 2 ) ) );
}
HB_FUNC( CV_WAITKEY )
{
聽 聽cv::waitKey( hb_parnl( 1 ) );
}
#pragma ENDDUMP
