예제 #1
0
void DynProgProb::setInput (
size_t dimInputProb_, 
const double *inputProb_) // array of input states : d_inputProb_p [0...dimStateProb - 1]
{
    if (dimInputProb_ != getDimInputProb ()) 
    {
        freeInput ();
        initInput (dimInputProb_);
    }

    if (getDimInputProb () > 0) MemUtil::memCpy (d_inputProb_p, inputProb_, sizeof (double) * getDimInputProb ());
}
예제 #2
0
	void TokenStream::setInput(std::istream* in) {
		freeInput();
		this->in = in;
		owner = true;
		ct.type = TokenType::end;
	}
예제 #3
0
	void TokenStream::setInput(std::istream& in) {
		freeInput();
		this->in = ∈
		owner = false;
		ct.type = TokenType::end;
	}
예제 #4
0
int
main( int /* argc */, char* /* * argv */ )
{
   TriclopsContext	triclops;
   TriclopsError       	error;
   TriclopsInput 	triclopsInput;
   char* 		szInputFile 	= "input.ppm";
   char* 		szCalFile 	= "input.cal";
   char* 		szDisparityBase	= "disparity";


   // Get the camera calibration data
   error = triclopsGetDefaultContextFromFile( &triclops, szCalFile );
   _HANDLE_TRICLOPS_ERROR( "triclopsGetDefaultContextFromFile(): "
			   "Can't open calibration file", 
			   error );
   
   // Load images from file
   if ( !ppmReadToTriclopsInput( szInputFile,  &triclopsInput ) )
   {
      printf( "ppmReadToTriclopsInput() failed. Can't read '%s'\n", szInputFile );
      return 1;
   }
   
   doRectifyStereoSave( triclops, &triclopsInput, szDisparityBase, "default" );

   // try doing stereo with a big stereo mask
   triclopsSetStereoMask( triclops, 21 );
   doRectifyStereoSave( triclops, &triclopsInput, szDisparityBase, "bigmask" );

   // try doing stereo with a small stereo mask
   triclopsSetStereoMask( triclops, 5 );
   doRectifyStereoSave( triclops, &triclopsInput, szDisparityBase, "smallmask" );

   // set mask to a neutral value
   triclopsSetStereoMask( triclops, 11 );

   // try doing stereo without any validation
   triclopsSetSurfaceValidation( triclops, 0 );
   triclopsSetUniquenessValidation( triclops, 0 );
   triclopsSetTextureValidation( triclops, 0 );
   doRectifyStereoSave( triclops, &triclopsInput, szDisparityBase, "novalidation" );

   // try doing stereo with only texture and surface
   triclopsSetSurfaceValidation( triclops, 1 );
   triclopsSetTextureValidation( triclops, 1 );
   doRectifyStereoSave( triclops, &triclopsInput, szDisparityBase, "surf-tex-val" );


   // try doing stereo in 2 camera mode with back and forth validation
   triclopsSetCameraConfiguration( triclops, TriCfg_2CAM_HORIZONTAL );
   triclopsSetBackForthValidation( triclops, 1 );
   doRectifyStereoSave( triclops, &triclopsInput, szDisparityBase, "backforth" );

   // try doing stereo in subpixel mode to compare the results of subpixel with
   // whole pixel - try running "convertimage16" example to convert this image to
   // one that is more easily viewed
   triclopsSetSubpixelInterpolation( triclops, 1 );
   doRectifyStereoSave( triclops, &triclopsInput, szDisparityBase, "subpixel" );


   
   // clean up memory allocated in context
   freeInput( &triclopsInput );
   error = triclopsDestroyContext( triclops );
   _HANDLE_TRICLOPS_ERROR( "triclopsDestroyContext()", error );
   
   return 0;
}
예제 #5
0
int
main( int /* argc */, char** /* argv */ )
{
   TriclopsContext     context;
   TriclopsImage       depthImage;
   TriclopsInput       inputData;
   TriclopsError       error;
   
   // get the camera module configuration
   error = triclopsGetDefaultContextFromFile( &context, "config" );
   _HANDLE_TRICLOPS_ERROR( "triclopsGetDefaultContextFromFile()", error );
   if ( error != TriclopsErrorOk )
   {
      printf( "Can't open calibration file 'config'\n" );
      exit( 1 );
   }
   
   // Load images from file
   TriclopsBool bErr = ppmReadToTriclopsInput( "input.ppm", &inputData );
   if( !bErr )
   {
      printf( "ppmReadToTriclopsInput() failed. Can't find input.ppm?\n" );
      exit( 1 );
   }
   
   // set up some stereo parameters:
   // set to 320x240 output images
   error = triclopsSetResolution( context, 240, 320 );
   _HANDLE_TRICLOPS_ERROR( "triclopsSetResolution()", error );
   // set disparity range
   error = triclopsSetDisparity( context, 5, 60 );
   _HANDLE_TRICLOPS_ERROR( "triclopsSetDisparity()", error );
   
   // set the display mapping
   // note: disparity mapping corrupts the disparity values so that making
   // distance measurements is more difficult and less accurate.
   // Do not use it when you intend to actually use disparity values for
   // purposes other than display
   error = triclopsSetDisparityMapping( context, 128, 255 );
   _HANDLE_TRICLOPS_ERROR( "triclopsSetDisparityMapping()", error );
   error = triclopsSetDisparityMappingOn( context, 1 );
   _HANDLE_TRICLOPS_ERROR( "triclopsSetDisparityMappingOn()", error );
   // set the validation mappings to 0 (black)
   error = triclopsSetUniquenessValidationMapping( context, 0 );
   _HANDLE_TRICLOPS_ERROR( "triclopsSetUniquenessValidationMapping()", error );
   error = triclopsSetTextureValidationMapping( context, 0 );
   _HANDLE_TRICLOPS_ERROR( "triclopsSetTextureValidationMapping()", error );
   
   // Preprocessing the images
   error = triclopsPreprocess( context, &inputData );
   _HANDLE_TRICLOPS_ERROR( "triclopsPreprocess()", error );
     
   // stereo processing
   error =  triclopsStereo( context );
   _HANDLE_TRICLOPS_ERROR( "triclopsStereo()", error );
   
   // retrieve the depth image from the context
   error = triclopsGetImage( context, TriImg_DISPARITY, TriCam_REFERENCE, &depthImage );
   _HANDLE_TRICLOPS_ERROR( "triclopsGetImage()", error );
   
   // save the depth image
   error = triclopsSaveImage( &depthImage, "depth.pgm" );
   _HANDLE_TRICLOPS_ERROR( "triclopsSaveImage()", error );
   
   
   // clean up memory allocated in context
   freeInput( &inputData );
   error = triclopsDestroyContext( context );
   
   return 0;
}
예제 #6
0
파일: main.c 프로젝트: Dalan94/Super_Martin
/**
 *\fn int main(int argc, char *argv[])
 * Main
 *\param[in,out] argc argc
 *\param[in,out] argv argv
 */
int main(int argc, char *argv[])
{
    SDL_Surface *screen = NULL;

    int go = 1;
    int ret,ret1, ret2 = 0, ret3, ret4;

    char level_name[MAX_SIZE_FILE_NAME];
    char player_name[MAX_SIZE_FILE_NAME];
    int nb_lvl;
    /*sound*/
    Sound *sound_system;
    sound_system = createSound();

    /*keyboard config*/
    SDLKey kc[NB_KEY-1];

    /*input*/
    Input in;

    SDL_Init(SDL_INIT_VIDEO|SDL_INIT_TIMER|SDL_INIT_JOYSTICK);

    Player *current_player;

    current_player = (Player *)malloc(sizeof(Player));

    /*screen initialization*/
    screen = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, 32, SDL_HWSURFACE | SDL_DOUBLEBUF);

    initInput(&in);

    /*configurations loading */
    loadSoundOptions("configuration/sound.conf",sound_system);


    SDL_WM_SetCaption("Super Martin", NULL); //window name

    SDL_ShowCursor(SDL_DISABLE); //delete the mouse

    while (go) //main loop
    {
        if(titleMenu(screen,&go,sound_system, &in))
        {

            while( (ret3 = menuPlayers(screen, player_name, &go, sound_system, &in)) != -1 && go)
            {
                switch(ret3)
                {
                    case -1:
                        break;
                    case 2  :
                        ret2 = newPlayer(screen, player_name, sound_system, &go);
                        if(ret2 == 1)
                        {
                            current_player->levelMax = 1;
                            current_player->nbCoins = 0;
                            current_player->nbLifes = 3;
                            current_player->nbProjectile = 5;
                            savePlayer("save/.save", player_name, current_player);
                            loadInputOptions("default",kc,&in);
                            saveInputOptions(player_name, kc, &in);
                        }
                        else
                            break;

                    case 1  :
                        loadPlayer("save/.save", player_name, current_player);
                        loadInputOptions(player_name,kc,&in);
                        while(go && (ret1 = mainMenu(screen,&go,sound_system, player_name, &in)) != -1)
                        {
                            switch(ret1)
                            {
                                case -1:
                                    break;
                                case 0:

                                    while( (ret4 = menuLevel(screen,level_name,sound_system, player_name, current_player, &go, &nb_lvl, &in)) != -1 && go)
                                    {
                                        while(play(screen,level_name,sound_system,&go,kc, &in, current_player, player_name, ret4+1, nb_lvl) && go);
                                    }
                                    break;

                                case 1 :
                                    save(screen, "save/.save", player_name, current_player, &go);
                                    loadPlayer("save/.save", player_name, current_player);
                                    break;

                                case 2 :
                                    while((ret = optionMenu(screen,&go,sound_system,kc, &in)) != -1 && go)
                                    {
                                        switch(ret)
                                        {
                                            case -1:
                                                break;
                                            case 0:
                                                soundOptions(screen,&go,sound_system, &in);
                                                break;
                                            case 1:
                                                keyBoardOptions(screen,&go,kc,&in,player_name);
                                                break;
                                            default:;
                                        }
                                    }
                                    break;

                                case 3 :
                                    deletePlayer(screen, "save/players", player_name);
                                    go = 0;
                                    break;

                                default: ;
                            }
                        }
                        go = 1;
                        break;

                    default : ;

                }
            }

        }

        SDL_FillRect(screen,NULL,SDL_MapRGB(screen->format,255,255,255)); //clear screen

        SDL_Flip(screen);
    }


    freeSound(sound_system);
    free((void*)current_player);
    freeInput(&in);
    SDL_Quit();

    return EXIT_SUCCESS;
}