/**
@function Get4Pixels16Bit
reads four consecutive pixels of the specified row started from given column and writes they to the
two registers out_BG and out_RA. Uses 16 bit per channel
@param in_img is a input image
@param in_row_idx is an index of a row to read pixels
@param in_col_idx ia an index of a column with a first pixel
@param out_BG is a pointer to a 128bit register to store blue and green channels for the pixels four
consecutive pixels in format BBBB GGGG. Order of pixels is [0, 1, 2, 3]
@param out_RA is a pointer to a 128bit register to store red and alpha channels for the pixels four
consecutive pixels in format RRRR AAAA. Order of pixels is [0, 1, 2, 3]
*/
int oldmain(int argc, char** argv) {
    // Command line options parser
    ArgvParser cmd;
        // Description of program
    cmd.setIntroductoryDescription("Machine graphics course, task 2. CMC MSU, 2014.");
        // Add help option
    cmd.setHelpOption("h", "help", "Print this help message");
        // Add other options
    cmd.defineOption("data_set", "File with dataset",
        ArgvParser::OptionRequiresValue | ArgvParser::OptionRequired);
    cmd.defineOption("model", "Path to file to save or load model",
        ArgvParser::OptionRequiresValue | ArgvParser::OptionRequired);
    cmd.defineOption("predicted_labels", "Path to file to save prediction results",
        ArgvParser::OptionRequiresValue);
    cmd.defineOption("train", "Train classifier");
    cmd.defineOption("predict", "Predict dataset");
    cmd.defineOption("sse", "Use SSE");

        // Add options aliases
    cmd.defineOptionAlternative("data_set", "d");
    cmd.defineOptionAlternative("model", "m");
    cmd.defineOptionAlternative("predicted_labels", "l");
    cmd.defineOptionAlternative("train", "t");
    cmd.defineOptionAlternative("predict", "p");
    cmd.defineOptionAlternative("sse", "s");
        // Parse options
    int result = cmd.parse(argc, argv);

        // Check for errors or help option
    if (result) {
        cout << cmd.parseErrorDescription(result) << endl;
        return result;
    }

        // Get values
    string data_file = cmd.optionValue("data_set");
    string model_file = cmd.optionValue("model");
    bool train = cmd.foundOption("train");
    bool predict = cmd.foundOption("predict");
    bool sse_on = cmd.foundOption("sse");
        // If we need to train classifier
    if (train)
        TrainClassifier(data_file, model_file, sse_on);
        // If we need to predict data
    if (predict) {
            // You must declare file to save images
        if (!cmd.foundOption("predicted_labels")) {
            cerr << "Error! Option --predicted_labels not found!" << endl;
            return 1;
        }
            // File to save predictions
        string prediction_file = cmd.optionValue("predicted_labels");
            // Predict data
        PredictData(data_file, model_file, prediction_file, sse_on);
    }
    return 0;
}
Пример #2
0
int main(int argc, char** argv) {
    ArgvParser cmd;
    cmd.setIntroductoryDescription("Machine graphics course, program for testing task 2. CMC MSU, 2013.");
    cmd.setHelpOption("h", "help", "Print this help message");
    cmd.defineOption("gt_labels", "File with ground truth labels",
        ArgvParser::OptionRequiresValue | ArgvParser::OptionRequired);
    cmd.defineOption("predicted_labels", "File with predicted labels",
        ArgvParser::OptionRequiresValue | ArgvParser::OptionRequired);

    cmd.defineOptionAlternative("gt_labels", "g");
    cmd.defineOptionAlternative("predicted_labels", "p");

    int result = cmd.parse(argc, argv);
    if (result) {
        cout << cmd.parseErrorDescription(result) << endl;
        return result;
    }

    TLabels gt_labels, predicted_labels;
    LoadLabels(cmd.optionValue("gt_labels"), &gt_labels);
    LoadLabels(cmd.optionValue("predicted_labels"), &predicted_labels);

    TestLabels(gt_labels, predicted_labels);
}
Пример #3
0
/* Parse command line arguments */
void parse_options(int argc, 		/* in */ 
				   char *argv[])	/* in */ 
{
	// Parser object:
	ArgvParser cmd;

  	// Init:
  	cmd.setIntroductoryDescription("cuGraph Command Line Options:");

	// Help option:
  	cmd.setHelpOption("h", "help", "Print this help page.");

	// Other options:
  	cmd.defineOption("vertix"	, "Graph size in term of vertix, default: 10000"		, ArgvParser::OptionRequiresValue);
  	cmd.defineOption("edge"		, "Maximum number of egdes in graph, default: vertix^2"	, ArgvParser::OptionRequiresValue);
  	cmd.defineOption("prob"		, "Probability to choose an edge, default: 0.5"			, ArgvParser::OptionRequiresValue);
  	cmd.defineOption("type"		, "Type of the generator, default: PER"					, ArgvParser::OptionRequiresValue);
  	cmd.defineOption("file"		, "Destination file, default: output/graph1.mtx"		, ArgvParser::OptionRequiresValue);
  	
  	// Options alternatives:
  	cmd.defineOptionAlternative("vertix","v");
  	cmd.defineOptionAlternative("edge"	,"e");
  	cmd.defineOptionAlternative("prob"	,"p");
  	cmd.defineOptionAlternative("type"	,"t");
  	cmd.defineOptionAlternative("file"	,"f");

  	// Parse command line:
  	int option = cmd.parse(argc, argv);
  	if (option != ArgvParser::NoParserError) {
    	cout << cmd.parseErrorDescription(option);
    	exit(1);
  	}

  	/* Query the parsing options */
  	
  	// Vertix:
  	if (cmd.foundOption("vertix")) {
    	vertix = std::stoi(cmd.optionValue("vertix"), NULL);
  	} else { // Default value:
  		vertix = 10000;
  	}
  	
  	// Edge:
  	if (cmd.foundOption("edge")) {
    	edge = std::stoi(cmd.optionValue("edge"), NULL);
  	} else { // Default value:
  		edge = vertix * vertix;
  	}
  	
  	// Prob:
  	if (cmd.foundOption("prob")) {
    	prob = std::stoi(cmd.optionValue("prob"), NULL);
  	} else { // Default value:
  		prob = 0.5;
  	}
  	
  	// Type:
  	if (cmd.foundOption("type")) {
    	type = cmd.optionValue("type");
  	} else { // Default value:
  		type = "PER";
  	}
  	
  	// File:
  	if (cmd.foundOption("file")) {
    	file = cmd.optionValue("file");
  	} else { // Default value:
  		file = "graph1.mtx";
  	}

	// Display Configuration Settings:
	cout << endl;
	cout << "Number of Vertix is set to " << vertix << endl;
	cout << "Number of Edges is set to " << edge << endl;
	cout << "Prob is set to " << prob << endl;
	cout << "Type is set to " << type << endl;
	cout << "File is set to " << file << endl;
	cout << endl;
}