TyErrorId initialize(AnnotatorContext &ctx) { if(ctx.isParameterDefined("minValueColor")) { ctx.extractValue("minValueColor", minValueColor); } if(ctx.isParameterDefined("minSaturationColor")) { ctx.extractValue("minSaturationColor", minSaturationColor); } if(ctx.isParameterDefined("maxValueBlack")) { ctx.extractValue("maxValueBlack", maxValueBlack); } if(ctx.isParameterDefined("minValueWhite")) { ctx.extractValue("minValueWhite", minValueWhite); } if(ctx.isParameterDefined("histogramCols")) { ctx.extractValue("histogramCols", histogramCols); } if(ctx.isParameterDefined("histogramRows")) { ctx.extractValue("histogramRows", histogramRows); } return UIMA_ERR_NONE; }
TyErrorId initialize(AnnotatorContext &ctx) { outInfo("Initialize"); if(ctx.isParameterDefined("use_transform")) { ctx.extractValue("use_transform", use_transform); } if(ctx.isParameterDefined("voxel_resolution")) { ctx.extractValue("voxel_resolution", voxel_resolution); } if(ctx.isParameterDefined("seed_resolution")) { ctx.extractValue("seed_resolution", seed_resolution); } if(ctx.isParameterDefined("color_importance")) { ctx.extractValue("color_importance", color_importance); } if(ctx.isParameterDefined("spatial_importance")) { ctx.extractValue("spatial_importance", spatial_importance); } if(ctx.isParameterDefined("normal_importance")) { ctx.extractValue("normal_importance", normal_importance); } return UIMA_ERR_NONE; }
/* * Initializes annotator */ TyErrorId initialize(AnnotatorContext &ctx) { outInfo("initialize"); if(ctx.isParameterDefined("keypointDetector")) { ctx.extractValue("keypointDetector", keypointDetector); } else { outError("no keypoint detector provided!"); return UIMA_ERR_ANNOTATOR_MISSING_INIT; } if(ctx.isParameterDefined("featureExtractor")) { ctx.extractValue("featureExtractor", featureExtractor); } else { outError("no feature extractor provided!"); return UIMA_ERR_ANNOTATOR_MISSING_INIT; } outDebug("creating " << keypointDetector << " key points detector..."); detector = cv::FeatureDetector::create(keypointDetector); if(detector.empty()) { outError("creation failed!"); return UIMA_ERR_ANNOTATOR_MISSING_INIT; } #if OUT_LEVEL == OUT_LEVEL_DEBUG printParams(detector); #endif setupAlgorithm(detector); outDebug("creating " << featureExtractor << " feature extractor..."); extractor = cv::DescriptorExtractor::create(featureExtractor); if(extractor.empty()) { outError("creation failed!"); return UIMA_ERR_ANNOTATOR_MISSING_INIT; } #if OUT_LEVEL == OUT_LEVEL_DEBUG printParams(extractor); #endif setupAlgorithm(extractor); if(featureExtractor == "SIFT" || featureExtractor == "SURF") { featureType = "numerical"; } else { featureType = "binary"; } return UIMA_ERR_NONE; }
TyErrorId AnnotatorDump::initialize( AnnotatorContext & rclAnnotatorContext) { TyErrorId tyErrId; string strFileName; int uiOutputStyle; // Default Values // in append mode all data in a session/collection is dumped into one file // otherwise the same dump file is deleted and rewritten for each document // in the session/collection // default is false iv_bAppendFile = false; // we don't dump the Document Buffer iv_bDumpDocBuffer = false; iv_bSaveDocBuffer = false; // the representation will be in Xml-Format iv_enOutputStyle = Xml; // Reading the Values from the Config-Section //Filename for the Output-Stream UnicodeString us; tyErrId = rclAnnotatorContext.extractValue(ANNOTATOR_DUMP_PARAM_OUTFILE, us); // Convert filename to default encoding UnicodeStringRef usr(us); usr.extract(strFileName); if (tyErrId != UIMA_ERR_NONE) { getAnnotatorContext().getLogger().logError( _TEXT("Required option '" ANNOTATOR_DUMP_PARAM_OUTFILE "' not found"), (long)ANNOTATOR_DUMP_ERROR_OPEN); return(UIMA_ERR_USER_ANNOTATOR_CONFIG_INVALID_PARAM); } iv_clOutputFilename = strFileName.c_str(); (void) rclAnnotatorContext.extractValue(ANNOTATOR_DUMP_PARAM_DUMP_DOCBUFFER, iv_bDumpDocBuffer); (void) rclAnnotatorContext.extractValue(ANNOTATOR_DUMP_PARAM_SAVE_DOCBUFFER, iv_bSaveDocBuffer); (void) rclAnnotatorContext.extractValue(ANNOTATOR_DUMP_PARAM_APPEND, iv_bAppendFile); // in append mode all data in a session/collection is dumped into one file // otherwise the same dump file is deleted and rewritten for each document // in the session/collection if (iv_bAppendFile) { tyErrId = openOutputFile(); if (tyErrId != UIMA_ERR_NONE) { return tyErrId; } } //Output Style uiOutputStyle = 0; tyErrId = rclAnnotatorContext.extractValue(ANNOTATOR_DUMP_PARAM_STYLE, uiOutputStyle); if (tyErrId != UIMA_ERR_CONFIG_OPTION_NOT_FOUND) { switch (uiOutputStyle) { case 0: iv_enOutputStyle = Xml; break; case 1: iv_enOutputStyle = XCas; break; default: getAnnotatorContext().getLogger().logWarning( "Invalid Output Style. Use Default", (long) ANNOTATOR_DUMP_MSG_STYLE); break; } } /* int iDummy; if ( rclAnnotatorContext.extractValue(ANNOTATOR_DUMP_OUTPUT_TYPES, iDummy)){ getAnnotatorContext().getLogger().logWarning((long) ANNOTATOR_DUMP_MSG_TYPES, _TEXT("Specification of output types currently not suported. All types will be dumped.")); } */ // Test getting a multi-valued parameter vector<string*> vecOutputTypes; tyErrId = rclAnnotatorContext.extractValue(ANNOTATOR_DUMP_OUTPUT_TYPES, vecOutputTypes); if (tyErrId != UIMA_ERR_CONFIG_OPTION_NOT_FOUND) { size_t i, len = 0; for (i=0; i<vecOutputTypes.size(); ++i) { string * rString = vecOutputTypes[i]; len += rString->length(); } cout << " parameter OutputTypes has "<<i<<" values with a total of "<<len<<" characters." << endl; // Release contents of vector allocated by extractValue in case library uses a different heap. rclAnnotatorContext.release(vecOutputTypes); } // Release string buffer allocated by library in case it uses a different heap. usr.release(strFileName); return(TyErrorId)UIMA_ERR_NONE; }
TyErrorId initialize(AnnotatorContext &ctx) { outInfo("initialize"); ctx.extractValue("test_param", test_param); return UIMA_ERR_NONE; }
TyErrorId initialize(AnnotatorContext &ctx) { outInfo("initialize"); if(ctx.isParameterDefined("border")) { ctx.extractValue("border", border); } std::vector<std::string *> temp; if(ctx.isParameterDefined("defaultRegions")) { ctx.extractValue("defaultRegions", temp); for(auto s : temp) { outInfo(*s); defaultRegions.push_back(*s); } } if(ctx.isParameterDefined("enable_change_detection")) { ctx.extractValue("enable_change_detection", changeDetection); } if(ctx.isParameterDefined("enable_frustum_culling")) { ctx.extractValue("enable_frustum_culling", frustumCulling_); } if(ctx.isParameterDefined("pixel_threshold")) { ctx.extractValue("pixel_threshold", pixelThreshold); } if(ctx.isParameterDefined("depth_threshold")) { ctx.extractValue("depth_threshold", depthThreshold); } if(ctx.isParameterDefined("global_threshold")) { ctx.extractValue("global_threshold", threshold); } if(ctx.isParameterDefined("change_timeout")) { int tmp = 120; ctx.extractValue("change_timeout", tmp); timeout = tmp; } return UIMA_ERR_NONE; }
TyErrorId extractConfigOptionListImpl( const AnnotatorContext& crclConfig, const UnicodeString* cpclConfigGroup, const ConfigOptionInfo::StOptionInfo& crclOptionInfo, ContainerType& rclTargetContainer, ElementType* /*not used, just for type information since ContainerType::value_type does not work with HP compiler*/ ) { assert(crclOptionInfo.bOptionIsMultiValued); TyErrorId utErrId = UIMA_ERR_NONE; size_t i; #if defined(__HPX_ACC__) || defined(__xlC__) || defined(__GNUC__) ElementType tTemp; #else ContainerType::value_type tTemp; #endif #if defined(__SUNPRO_CC) std::vector<ContainerType::value_type> elements; #else std::vector<ElementType> elements; #endif if (EXISTS(cpclConfigGroup)) { crclConfig.extractValue(*cpclConfigGroup, crclOptionInfo.cpszOptionName, elements); } else { crclConfig.extractValue(crclOptionInfo.cpszOptionName, elements); } for (i = 0; i < elements.size(); ++i) { rclTargetContainer.insert(rclTargetContainer.end(), elements[i]); } if (utErrId != UIMA_ERR_NONE || (elements.size() == 0)) { // could not find option or value(s) if (crclOptionInfo.uiNbrOfValuesRequired != 0 || crclOptionInfo.cpszDefaultValueAsString == NULL) { // required value not there: return error we got from config return utErrId; } std::vector<std::string> vecTmpStrings; delimitedString2Vector( vecTmpStrings, (std::string) crclOptionInfo.cpszDefaultValueAsString, ",", true, // trim strings false // insert empty strings ); // our default value too must have the required nbr of values assert(vecTmpStrings.size() >= crclOptionInfo.uiNbrOfValuesRequired); for (i = 0; i < vecTmpStrings.size(); ++i) { convertFromString(vecTmpStrings[i], tTemp); // assumes rclTargetContainer to be an STL container rclTargetContainer.insert(rclTargetContainer.end(), tTemp); } } if (i < crclOptionInfo.uiNbrOfValuesRequired) { /* taph 8/6/1999: ?? maybe we should have a more precise error id: UIMA_ERR_CONFIG_REQUIRED_OPTION_HAS_NOT_ENOUGH_VALUES */ return UIMA_ERR_CONFIG_REQUIRED_OPTION_IS_EMPTY; } return utErrId; }