7 #include "PlusConfigure.h" 10 #include "vtksys/CommandLineArguments.hxx" 13 int main(
int argc,
char** argv)
15 bool printHelp(
false);
16 std::string inputConfigFileName;
18 std::string fieldValue;
20 vtksys::CommandLineArguments args;
21 args.Initialize(argc, argv);
23 int verboseLevel = vtkPlusLogger::LOG_LEVEL_UNDEFINED;
25 args.AddArgument(
"--help", vtksys::CommandLineArguments::NO_ARGUMENT, &printHelp,
"Print this help.");
26 args.AddArgument(
"--config-file", vtksys::CommandLineArguments::EQUAL_ARGUMENT, &inputConfigFileName,
"Config file to test with.");
27 args.AddArgument(
"--device-id", vtksys::CommandLineArguments::EQUAL_ARGUMENT, &deviceId,
"Id of the text recognizer device.");
28 args.AddArgument(
"--field-value", vtksys::CommandLineArguments::EQUAL_ARGUMENT, &fieldValue,
"Value of the first field.");
29 args.AddArgument(
"--verbose", vtksys::CommandLineArguments::EQUAL_ARGUMENT, &verboseLevel,
"Verbose level (1=error only, 2=warning, 3=info, 4=debug, 5=trace)");
33 std::cerr <<
"Problem parsing arguments" << std::endl;
34 std::cout <<
"\n\nvtkPlusVirtualTextRecognizerTest help:" << args.GetHelp() << std::endl;
42 std::cout <<
"\n\nvtkPlusVirtualTextRecognizerTest help:" << args.GetHelp() << std::endl;
46 if (!vtksys::SystemTools::FileExists(inputConfigFileName))
48 LOG_ERROR(
"Invalid config file sent to test.");
52 vtkSmartPointer<vtkXMLDataElement> configRootElement = vtkSmartPointer<vtkXMLDataElement>::New();
55 LOG_ERROR(
"Unable to read configuration from file " << inputConfigFileName.c_str());
61 vtkSmartPointer<vtkPlusDataCollector> dataCollector = vtkSmartPointer<vtkPlusDataCollector>::New();
63 if (dataCollector->ReadConfiguration(configRootElement) !=
PLUS_SUCCESS)
65 LOG_ERROR(
"Configuration incorrect for vtkPlusVirtualTextRecognizerTest.");
70 if (dataCollector->GetDevice(device, deviceId) !=
PLUS_SUCCESS)
72 LOG_ERROR(
"Unable to retrieve recognizer device by Id: " << deviceId);
77 if (textRecognizer == NULL)
79 LOG_ERROR(
"Unable to retrieve recognizer device by Id: " << deviceId);
82 std::stringstream tessDataPathSS;
88 LOG_ERROR(
"Failed to connect to devices!");
94 LOG_ERROR(
"Failed to start data collection!");
108 if ((*it)->LatestParameterValue != fieldValue)
110 LOG_ERROR(
"Direct: Parameter \"" << (*it)->ParameterName <<
"\" value=\"" << (*it)->LatestParameterValue <<
"\" does not match expected value=\"" << fieldValue <<
"\"");
114 igsioTrackedFrame frame;
117 if (frame.GetFrameField((*it)->ParameterName).empty() || !igsioCommon::IsEqualInsensitive(frame.GetFrameField((*it)->ParameterName), fieldValue))
119 LOG_ERROR(
"Tracked Frame: Parameter \"" << (*it)->ParameterName <<
"\" value=\"" << (*it)->LatestParameterValue <<
"\" does not match expected value=\"" << fieldValue <<
"\"");
123 LOG_INFO(
"Exit successfully");
Abstract interface for tracker and video devices.
int main(int argc, char **argv)
std::string GetImagePath(const std::string &subPath)
virtual void SetMissingInputGracePeriodSec(double)
static vtkPlusConfig * GetInstance()
ChannelContainerConstIterator GetOutputChannelsStart() const
static vtkIGSIOLogger * Instance()
FieldList::iterator FieldListIterator
std::map< vtkPlusChannel *, FieldList > ChannelFieldListMap
void SetDeviceSetConfigurationData(vtkXMLDataElement *deviceSetConfigurationData)
static PlusStatus ReadDeviceSetConfigurationFromFile(vtkXMLDataElement *config, const char *filename)
static vtkPlusVirtualTextRecognizer * SafeDownCast(vtkObject *o)