Ejemplo n.º 1
0
static void saveParam(ARParam *param)
{
    char   *name = NULL, *cwd = NULL;
    size_t len;
    int    nameOK;

    arMalloc(name, char, MAXPATHLEN);
    arMalloc(cwd, char, MAXPATHLEN);
    if (!getcwd(cwd, MAXPATHLEN))
        ARLOGe("Unable to read current working directory.\n");

    nameOK = 0;
    ARLOG("Filename[%s]: ", SAVE_FILENAME);
    if (fgets(name, MAXPATHLEN, stdin) != NULL)
    {
        // Trim whitespace from end of name.
        len = strlen(name);

        while (len > 0 && (name[len - 1] == '\r' || name[len - 1] == '\n' || name[len - 1] == '\t' || name[len - 1] == ' '))
        {
            len--;
            name[len] = '\0';
        }

        if (len > 0)
        {
            nameOK = 1;
            if (arParamSave(name, 1, param) < 0)
            {
                ARLOG("Parameter write error!!\n");
            }
            else
            {
                ARLOG("Saved parameter file '%s/%s'.\n", cwd, name);
            }
        }
    }

    // Try and save with a default name.
    if (!nameOK)
    {
        if (arParamSave(SAVE_FILENAME, 1, param) < 0)
        {
            ARLOG("Parameter write error!!\n");
        }
        else
        {
            ARLOG("Saved parameter file '%s/%s'.\n", cwd, SAVE_FILENAME);
        }
    }

    free(name);
    free(cwd);
}
Ejemplo n.º 2
0
Archivo: main.c Proyecto: SNce/ARMaze
static void     save_param(void)
{
    char     name[256];
    ARParam  param;
    int      i, j;

    param.xsize = xsize;
    param.ysize = ysize;
    for( i = 0; i < 4; i++ ) param.dist_factor[i] = dist_factor[i];
    for( j = 0; j < 3; j++ ) {
        for( i = 0; i < 4; i++ ) {
            param.mat[j][i] = mat[j][i];
        }
    }
    arParamDisp( &param );

    printf("Fielname: ");
    scanf( "%s", name );
    arParamSave( name, 1, &param );

    return;
}
Ejemplo n.º 3
0
static void     save_param(void)
{
    ARParam  param;
    int      i, j;

    param.xsize = xsize;
    param.ysize = ysize;
    for( i = 0; i < AR_DIST_FACTOR_NUM_MAX; i++ ) param.dist_factor[i] = dist_factor[i];
    for( j = 0; j < 3; j++ ) {
        for( i = 0; i < 4; i++ ) {
            param.mat[j][i] = mat[j][i];
        }
    }
	param.dist_function_version = dist_function_version;
    arParamDisp( &param );

    if( save_filename[0] == '\0' ) {
        printf("Filename: ");
        scanf( "%s", save_filename );
    }
    arParamSave( save_filename, 1, &param );

    return;
}