#include <highgui.h>
-#include <vlc/vlc.h>
-#include <vlc_decoder.h>
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <vlc_common.h>
+#include <vlc_plugin.h>
#include <vlc_filter.h>
#include "filter_common.h"
#include <vlc_image.h>
/*****************************************************************************
* Module descriptor
*****************************************************************************/
-vlc_module_begin();
- set_description( _("OpenCV face detection example filter") );
- set_shortname( _( "OpenCV example" ));
- set_capability( "opencv example", 1 );
- add_shortcut( "opencv_example" );
+vlc_module_begin ()
+ set_description( N_("OpenCV face detection example filter") )
+ set_shortname( N_( "OpenCV example" ))
+ set_capability( "opencv example", 1 )
+ add_shortcut( "opencv_example" )
- set_category( CAT_VIDEO );
- set_subcategory( SUBCAT_VIDEO_VFILTER2 );
- set_callbacks( OpenFilter, CloseFilter );
+ set_category( CAT_VIDEO )
+ set_subcategory( SUBCAT_VIDEO_VFILTER2 )
+ set_callbacks( OpenFilter, CloseFilter )
add_string( "opencv-haarcascade-file", "c:\\haarcascade_frontalface_alt.xml", NULL,
N_("Haar cascade filename"),
- N_("Name of XML file containing Haar cascade description"), VLC_FALSE);
-vlc_module_end();
+ N_("Name of XML file containing Haar cascade description"), false);
+vlc_module_end ()
/*****************************************************************************
* OpenFilter: probe the filter and return score
if( ( p_filter->p_sys = p_sys =
(filter_sys_t *)malloc(sizeof(filter_sys_t)) ) == NULL )
{
- msg_Err( p_filter, "out of memory" );
- return VLC_EGENERIC;
+ return VLC_ENOMEM;
}
//init the video_filter_event_info_t struct
//create the VIDEO_FILTER_EVENT_VARIABLE
vlc_value_t val;
if (var_Create( p_filter->p_libvlc, VIDEO_FILTER_EVENT_VARIABLE, VLC_VAR_ADDRESS | VLC_VAR_DOINHERIT ) != VLC_SUCCESS)
- msg_Err( p_filter, "Could not create %s\n", VIDEO_FILTER_EVENT_VARIABLE);
+ msg_Err( p_filter, "Could not create %s", VIDEO_FILTER_EVENT_VARIABLE);
val.p_address = &(p_sys->event_info);
if (var_Set( p_filter->p_libvlc, VIDEO_FILTER_EVENT_VARIABLE, val )!=VLC_SUCCESS)
- msg_Err( p_filter, "Could not set %s\n", VIDEO_FILTER_EVENT_VARIABLE);
+ 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);
+ free( filename );
return VLC_SUCCESS;
}
CvRect* r;
if (faces && (faces->total > 0))
{
- //msg_Dbg( p_filter, "Found %d face(s)\n", faces->total );
+ //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);
if( NULL == ( p_filter->p_sys->event_info.p_region =
(video_filter_region_info_t *)malloc(faces->total*sizeof(video_filter_region_info_t))))
{
- msg_Err( p_filter, "out of memory" );
return NULL;
}
memset(p_filter->p_sys->event_info.p_region, 0, faces->total*sizeof(video_filter_region_info_t));
}
if (faces && (faces->total > 0)) //raise the video filter event
- var_Change( p_filter->p_libvlc, VIDEO_FILTER_EVENT_VARIABLE, VLC_VAR_TRIGGER_CALLBACKS, NULL, NULL );
+ var_TriggerCallback( p_filter->p_libvlc, VIDEO_FILTER_EVENT_VARIABLE );
}
else
msg_Err( p_filter, "No cascade - is opencv-haarcascade-file valid?" );