* (performs face identification). Mostly taken from the facedetect.c
* OpenCV sample.
*****************************************************************************
* (performs face identification). Mostly taken from the facedetect.c
* OpenCV sample.
*****************************************************************************
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
/*****************************************************************************
* filter_sys_t : filter descriptor
*****************************************************************************/
/*****************************************************************************
* filter_sys_t : filter descriptor
*****************************************************************************/
- add_string( "opencv-haarcascade-file", "c:\\haarcascade_frontalface_alt.xml", NULL,
+ add_string( "opencv-haarcascade-file", "c:\\haarcascade_frontalface_alt.xml",
N_("Haar cascade filename"),
N_("Name of XML file containing Haar cascade description"), false);
vlc_module_end ()
N_("Haar cascade filename"),
N_("Name of XML file containing Haar cascade description"), false);
vlc_module_end ()
msg_Err( p_filter, "Could not set %s", VIDEO_FILTER_EVENT_VARIABLE);
//OpenCV init specific to this example
msg_Err( p_filter, "Could not set %s", VIDEO_FILTER_EVENT_VARIABLE);
//OpenCV init specific to this example
- char* filename = config_GetPsz( p_filter, "opencv-haarcascade-file" );
- p_filter->p_sys->p_cascade = (CvHaarClassifierCascade*)cvLoad( filename, 0, 0, 0 );
- p_filter->p_sys->p_storage = cvCreateMemStorage(0);
+ char* filename = var_InheritString( p_filter, "opencv-haarcascade-file" );
+ p_sys->p_cascade = (CvHaarClassifierCascade*)cvLoad( filename, 0, 0, 0 );
+ p_sys->p_storage = cvCreateMemStorage(0);
- if( p_filter->p_sys->p_storage )
- cvReleaseMemStorage( &p_filter->p_sys->p_storage );
-
- if (NULL != p_filter->p_sys->event_info.p_region)
- free(p_filter->p_sys->event_info.p_region);
+ if( p_sys->p_storage )
+ cvReleaseMemStorage( &p_sys->p_storage );
/****************************************************************************
* Filter: Check for faces and raises an event when one is found.
/****************************************************************************
* Filter: Check for faces and raises an event when one is found.
****************************************************************************/
static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
{
IplImage** p_img = NULL;
****************************************************************************/
static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
{
IplImage** p_img = NULL;
- faces = cvHaarDetectObjects( p_img[0], p_filter->p_sys->p_cascade,
- p_filter->p_sys->p_storage, 1.15, 5, CV_HAAR_DO_CANNY_PRUNING,
+ CvSeq *faces = cvHaarDetectObjects( p_img[0], p_sys->p_cascade,
+ p_sys->p_storage, 1.15, 5,
+ CV_HAAR_DO_CANNY_PRUNING,
if (faces && (faces->total > 0))
{
//msg_Dbg( p_filter, "Found %d face(s)", faces->total );
if (faces && (faces->total > 0))
{
//msg_Dbg( p_filter, "Found %d face(s)", faces->total );
- if (NULL != p_filter->p_sys->event_info.p_region)
- {
- free(p_filter->p_sys->event_info.p_region);
- p_filter->p_sys->event_info.p_region = NULL;
- }
- if( NULL == ( p_filter->p_sys->event_info.p_region =
- (video_filter_region_info_t *)malloc(faces->total*sizeof(video_filter_region_info_t))))
- {
+ free( p_sys->event_info.p_region );
+ p_sys->event_info.p_region = (video_filter_region_info_t*)
+ calloc( faces->total, sizeof(video_filter_region_info_t));
+ if( !p_sys->event_info.p_region )
- }
- memset(p_filter->p_sys->event_info.p_region, 0, faces->total*sizeof(video_filter_region_info_t));
- p_filter->p_sys->event_info.i_region_size = faces->total;
+ p_sys->event_info.i_region_size = faces->total;
pt1.x = r->x*scale;
pt2.x = (r->x+r->width)*scale;
pt1.y = r->y*scale;
pt2.y = (r->y+r->height)*scale;
cvRectangle( p_img[0], pt1, pt2, CV_RGB(0,0,0), 3, 8, 0 );
pt1.x = r->x*scale;
pt2.x = (r->x+r->width)*scale;
pt1.y = r->y*scale;
pt2.y = (r->y+r->height)*scale;
cvRectangle( p_img[0], pt1, pt2, CV_RGB(0,0,0), 3, 8, 0 );
- *(CvRect*)(&(p_filter->p_sys->event_info.p_region[i])) = *r;
- p_filter->p_sys->event_info.p_region[i].i_id = p_filter->p_sys->i_id++;
- p_filter->p_sys->event_info.p_region[i].p_description = "Face Detected";
+ *(CvRect*)(&(p_sys->event_info.p_region[i])) = *r;
+ p_sys->event_info.p_region[i].i_id = p_sys->i_id++;
+ p_sys->event_info.p_region[i].p_description = "Face Detected";