oneblob.cc

 1 const char *help = "\
 2 progname: oneblob.cc\n\
 3 code2html: This program computes features (x and y coordinates, excentricity, angle and surface) from an image using a colorcube.\n\
 4 version: Torch3 vision2.0, 2004-2005\n\
 5 (c) Agnes Just and Sebastien Marcel (marcel@idiap.ch)\n";
 6 
 7 #include "xtprobeImageDiskXFile.h"
 8 #include "ImageRgb.h"
 9 #include "ipOneBlob.h"
10 #include "CmdLine.h"
11 
12 using namespace Torch;
13 
14 int main(int argc, char *argv[])
15 {
16 	char *image_filename;
17 	char *colorcube_filename;
18 
19 	CmdLine cmd;
20 	cmd.setBOption("write log", false);
21 	cmd.info(help);
22 	cmd.addText("\nArguments:");
23 	cmd.addSCmdArg("image", &image_filename, "image filename");
24 	cmd.addSCmdArg("colorcube", &colorcube_filename, "colorcube filename");
25 	cmd.read(argc, argv); 
26 
27 	Allocator *allocator = new Allocator;
28 
29 	Image *image = new(allocator) ImageRgb();
30 
31 	ImageDiskXFile *image_loader = new(allocator) xtprobeImageDiskXFile(image_filename, "r");
32 	image->loadImageXFile(image_loader);
33 	allocator->free(image_loader);
34   
35 	ipCore *ipblob = new(allocator) ipOneBlob(image->width, image->height, colorcube_filename, "rgb");
36 
37 	ipblob->process(image);
38 
39 	real *output = ipblob->getOutput(0);
40 
41 	print("x mean = %g\n", output[0]);
42 	print("y mean = %g\n", output[1]);
43 	print("excentricity = %g\n", output[2]);
44 	print("angle = %g\n", output[3]);
45 	print("surface = %g\n", output[4]);
46 	
47 	delete allocator;
48 	
49 	return 0;
50 }
51 
52