FANDOM


< Code

Code of 'TutorialC3' Edit

// main.cpp of TutorialC3
/*
(* ***** BEGIN LICENSE BLOCK *****
 * Copyright (C) 2004 Durand Emmanuel
 * Copyright (C) 2004 Burgel Eric
 *
 * This library 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 library 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * Contact :
 *   filters@edurand.com
 *   filters@burgel.com
 * Site :
 *   http://filters.sourceforge.net/
 *
 * ***** END LICENSE BLOCK ***** *)
*/

/*
 edurand (filters@edurand.com)
*/

extern "C" {
  #include "wrapper_filtersDll.h"
}


#include <stdio.h>
#include <windows.h>
#include <winbase.h>

void testVideo(void)
{
    // we create the [filtersPlugin_Video]
    __int32 filtersPlugin_Video = filters_createFilter( "filtersPlugin_Video" );
    // for debug only, we would like to see it's window, to see the video
    filters_setParameterBoolean( filtersPlugin_Video, "showViewer", filters_true );
    filters_setParameterInteger( filtersPlugin_Video, "win_x", 0 );
    filters_setParameterInteger( filtersPlugin_Video, "win_y", 0 );
    // we set the file name of the video to load
    filters_setParameterString( filtersPlugin_Video, "fileName", "C:/DEV2/Images/pieces200608/320/OK_320_1.avi" );
    // we ask to load it
    filters_runCommand( filtersPlugin_Video, "LOAD" );
    // and to play it
    printf( "\nplay the video" );
    filters_runCommand( filtersPlugin_Video, "PLAY" );
    
    // now we will capture images of the playing video, and apply a [filterContrastExplorer] on each captured image
    __int32 filterContrastExplorer = filters_createFilter( "filterContrastExplorer" );
    PFBitmap32 fImageContrast = NULL;
    
    // we will use [filtersPlugin_Viewer] to show the image contrast of the image capture
    __int32 filtersPlugin_Viewer = filters_createFilter( "filtersPlugin_Viewer" );
    filters_setParameterBoolean( filtersPlugin_Viewer, "showViewer", filters_true );
    filters_setParameterInteger( filtersPlugin_Viewer, "win_x", 0 );
    filters_setParameterInteger( filtersPlugin_Viewer, "win_y", 200 );
    
    // we capture n images
    int n = 20;
    for( int i=0; i<n; i++ ){
        // we sleep 1s between each capture
        Sleep(500);
        // we capture a image from the video
        printf( "\ncapture image %d", i+1 );
        filters_run( filtersPlugin_Video );
        PFBitmap32 fImageCapture = filters_getOutputImage( filtersPlugin_Video, "outImage" );
        // we can save it
        helper_saveImage( fImageCapture, "C:/DEV/FiltersTutorial/Bin/tutorialC3_capture.bmp" );
        // we apply the contrast filter on it
        printf( "\napply contrast on captured image" );
        if( fImageContrast!=NULL ){
            image_freeImage( fImageContrast );
        }
        fImageContrast = image_createImageLike( fImageCapture );
        filters_setParameterImage( filterContrastExplorer, "inImage", fImageCapture );
        filters_setParameterImage( filterContrastExplorer, "outImage", fImageContrast );
        filters_setParameterInteger( filterContrastExplorer, "precision", 1 );
        filters_setParameterString( filterContrastExplorer, "mode", "NORMAL" );
        filters_run( filterContrastExplorer );
        // we show it in the viewer
        filters_setParameterImage( filtersPlugin_Viewer, "inImage", fImageContrast );
        filters_run( filtersPlugin_Viewer );
        // we can save it too
        helper_saveImage( fImageContrast, "C:/DEV/FiltersTutorial/Bin/tutorialC3_contrast.bmp" );
    }    
        
    printf( "\nstop the video" );
    filters_runCommand( filtersPlugin_Video, "STOP" );
    
    
	printf("\n(press [ENTER] to close)\n");
	getchar();
    
    filters_deleteFilter( filterContrastExplorer );
    filters_deleteFilter( filtersPlugin_Viewer );
    filters_deleteFilter( filtersPlugin_Video );
    image_freeImage( fImageContrast );
}

int main()
 {
	printf("TutorialC3 : Test Filters Plugins\n");

	// initialize Filters
	//   -> to test 'setProperty' function,
	//    we don't have setted the working directory in the Eclipse project,
	//    so Filters will start with a working directory = the source directory
	//    then Filters can't find Filters Plugins, unitl we provide it the right directory
	filters_setProperty( "PLUGINS_DIRECTORY", "C:/DEV/FiltersTutorial/Bin" );
	filters_initialize();
	printf("\nFilters version = [%s] \n", filters_getVersion() );

/*	PFBitmap32 fImageTest = image_createImageTest( 512, 512 );
	__int32 filtersPlugin_Viewer = filters_createFilter( "filtersPlugin_Viewer" );
	filters_setParameterImage( filtersPlugin_Viewer, "inImage", fImageTest );
	filters_setParameterBoolean( filtersPlugin_Viewer, "showViewer", filters_true );
	filters_setParameterInteger( filtersPlugin_Viewer, "win_x", 0 );
	filters_setParameterInteger( filtersPlugin_Viewer, "win_y", 200 );
	filters_run( filtersPlugin_Viewer );
	filters_deleteFilter( filtersPlugin_Viewer );
*/

	testVideo();	

	printf("\n(press [ENTER] to close)\n");
	getchar();
	
	
	// dispose Filters
	filters_unInitialize();

	printf("\n------------------------------\n");
	printf("contact : filters@edurand.com\n");

	return 0;
} 

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.