- VlcPictureToIplImage( p_vout, p_pic);
- //pass the image to the internal opencv filter for processing
- if ((p_vout->p_sys->p_opencv) && (p_vout->p_sys->p_opencv->p_module))
- p_vout->p_sys->p_opencv->pf_video_filter( p_vout->p_sys->p_opencv, &(p_vout->p_sys->hacked_pic));
- }
- else //output = processed video (NONE option not working yet)
- {
- VlcPictureToIplImage( p_vout, p_pic);
- //pass the image to the internal opencv filter for processing
- if ((p_vout->p_sys->p_opencv) && (p_vout->p_sys->p_opencv->p_module))
- p_vout->p_sys->p_opencv->pf_video_filter( p_vout->p_sys->p_opencv, &(p_vout->p_sys->hacked_pic));
- //copy the processed image into the output image
- if ((p_vout->p_sys->p_proc_image) && (p_vout->p_sys->p_proc_image->p_data))
- picture_Copy( p_outpic, p_vout->p_sys->p_proc_image );
+
+ VlcPictureToIplImage( p_filter, p_pic );
+ // Pass the image (as a pointer to the first IplImage*) to the
+ // internal OpenCV filter for processing.
+ p_filter->p_sys->p_opencv->pf_video_filter( p_filter->p_sys->p_opencv, (picture_t*)&(p_filter->p_sys->p_cv_image[0]) );
+
+ if(p_filter->p_sys->i_wrapper_output == PROCESSED) {
+ // Processed video
+ if( (p_filter->p_sys->p_proc_image) &&
+ (p_filter->p_sys->p_proc_image->i_planes > 0) &&
+ (p_filter->p_sys->i_internal_chroma != CINPUT) ) {
+ //p_filter->p_sys->p_proc_image->format.i_chroma = VLC_CODEC_RGB24;
+
+ memset( &fmt_out, 0, sizeof(video_format_t) );
+ fmt_out = p_pic->format;
+ //picture_Release( p_outpic );
+
+ /*
+ * We have to copy out the image from image_Convert(), otherwise
+ * you leak pictures for some reason:
+ * main video output error: pictures leaked, trying to workaround
+ */
+ picture_t* p_outpic_tmp = image_Convert(
+ p_filter->p_sys->p_image,
+ p_filter->p_sys->p_proc_image,
+ &(p_filter->p_sys->p_proc_image->format),
+ &fmt_out );
+
+ picture_CopyPixels( p_outpic, p_outpic_tmp );
+ CopyInfoAndRelease( p_outpic, p_outpic_tmp );
+ } else if( p_filter->p_sys->i_internal_chroma == CINPUT ) {
+ picture_CopyPixels( p_outpic, p_filter->p_sys->p_proc_image );
+ picture_CopyProperties( p_outpic, p_filter->p_sys->p_proc_image );
+ }