// TODO: simplify logic here void Flea3Camera::SetVideoMode(int& video_mode, int& format7_mode, int& pixel_format, int& width, int& height) { // Try setting video mode based on video_mode, fail silently if (video_mode == Flea3Dyn_format7) { SetFormat7VideoMode(format7_mode, pixel_format, width, height); } else { SetStandardVideoMode(video_mode); } // Update params const auto video_mode_and_frame_rate_pg = GetVideoModeAndFrameRate(camera_); if (video_mode_and_frame_rate_pg.first == VIDEOMODE_FORMAT7) { const auto fmt7_settings = GetFormat7ImageSettings(camera_); pixel_format = hsb(fmt7_settings.pixelFormat); width = fmt7_settings.width; height = fmt7_settings.height; format7_mode = fmt7_settings.mode; video_mode = Flea3Dyn_format7; } else { video_mode = static_cast<int>(video_mode_and_frame_rate_pg.first); format7_mode = 0; pixel_format = 0; width = 0; height = 0; } }
int main() { Listener l; NSInitialize(); NSFrame frame; NSVContainer con(500, 500); NSVScrollbar vsb(10, 200, &l); NSHScrollbar hsb(10, 400, &l); vsb.movement(5); hsb.movement(4); con.add(&vsb); con.add(&hsb); con.reallocate(); frame.container(&con); frame.map(); XFlush(NSdisplay()); NSMainLoop(); return 0; }
LimaStatusCode LinearTextRepresentationDumper::process( AnalysisContent& analysis) const { DUMPERLOGINIT; // get metadata LinguisticMetaData* metadata=dynamic_cast<LinguisticMetaData*>(analysis.getData("LinguisticMetaData")); if (metadata == 0) { LERROR << "LinearTextRepresentationDumper::process: no LinguisticMetaData ! abort" << LENDL; return MISSING_DATA; } // get the analysis graph AnalysisGraph* anaGraph = dynamic_cast<AnalysisGraph*>(analysis.getData("PosGraph")); if (anaGraph == 0) { LERROR << "LinearTextRepresentationDumper::process: no AnalysisGraph ! abort" << LENDL; return MISSING_DATA; } // get sentence boundaries SegmentationData* sb = dynamic_cast<SegmentationData*>(analysis.getData("SentenceBoundaries")); if (sb == 0) { LERROR << "LinearTextRepresentationDumper::process: no SentenceBounds ! abort" << LENDL; return MISSING_DATA; } // build LTRText LTR_Text textRep; LTRTextBuilder builder(m_language, m_stopList); builder.buildLTRTextFrom( *(anaGraph->getGraph()), sb, anaGraph->lastVertex(), &textRep, metadata->getStartOffset()); // write LTR_Text LDEBUG << "handler will be: " << m_handler << LENDL; // MediaId langid = static_cast<const Common::MediaticData::LanguageData&>(Common::MediaticData::MediaticData::single().mediaData(metadata->getMetaData("Lang"))).getMedia(); AnalysisHandlerContainer* h = static_cast<AnalysisHandlerContainer*>(analysis.getData("AnalysisHandlerContainer")); AbstractTextualAnalysisHandler* handler = static_cast<AbstractTextualAnalysisHandler*>(h->getHandler(m_handler)); if (handler == 0) { LERROR << "LinearTextRepresentationDumper::process: handler " << m_handler << " has not been given to the core client" << LENDL; return MISSING_DATA; } handler->startAnalysis(); HandlerStreamBuf hsb(handler); ostream out(&hsb); LDEBUG << textRep << LENDL; textRep.binaryWriteOn(out); out.flush(); handler->endAnalysis(); return SUCCESS_ID; }
SHSB RGBtoHSB( SRGB rgb ) { int x = max( rgb.r, max( rgb.g, rgb.b ) ); int y = min( rgb.r, min( rgb.g, rgb.b ) ); int d = x- y; SHSB hsb( 0, 0, 0 ); if ( rgb.r == x ) hsb.h = ( 60 * ( rgb.g - rgb.b ) / d ) % 360; else if ( rgb.g == x ) hsb.h = ( 60 * ( 2 + ( rgb.b - rgb.r ) / d ) ) % 360; else hsb.h = ( 60 * ( 4 + ( rgb.r - rgb.g ) / d ) ) % 360; if ( x == 0 ) hsb.s = 0; else hsb.s = x - y / x; hsb.b = x; return hsb; }
LimaStatusCode EasyXmlDumper::process(AnalysisContent& analysis) const { TimeUtils::updateCurrentTime(); DUMPERLOGINIT; LinguisticMetaData* metadata = static_cast<LinguisticMetaData*>(analysis.getData("LinguisticMetaData")); if (metadata == 0) { LERROR << "EasyXmlDumper::process no LinguisticMetaData ! abort"; return MISSING_DATA; } string filename = metadata->getMetaData("FileName"); LDEBUG << "EasyXmlDumper::process Filename: " << filename; LDEBUG << "handler will be: " << m_handler; // MediaId langid = static_cast<const Common::MediaticData::LanguageData&>(Common::MediaticData::MediaticData::single().mediaData(metadata->getMetaData("Lang"))).getMedia(); AnalysisHandlerContainer* h = static_cast<AnalysisHandlerContainer*>(analysis.getData("AnalysisHandlerContainer")); AbstractTextualAnalysisHandler* handler = static_cast<AbstractTextualAnalysisHandler*>(h->getHandler(m_handler)); if (handler==0) { LERROR << "EasyXmlDumper::process: handler " << m_handler << " has not been given to the core client"; return MISSING_DATA; } AnalysisGraph* graph = static_cast<AnalysisGraph*>(analysis.getData(m_graph)); if (graph == 0) { graph = new AnalysisGraph(m_graph,m_language,true,true); analysis.setData(m_graph,graph); } SyntacticData* syntacticData = static_cast<SyntacticData*>(analysis.getData("SyntacticData")); if (syntacticData == 0) { syntacticData = new SyntacticAnalysis::SyntacticData(static_cast<AnalysisGraph*>(analysis.getData(m_graph)),0); syntacticData->setupDependencyGraph(); analysis.setData("SyntacticData",syntacticData); } AnnotationData* annotationData = static_cast< AnnotationData* >(analysis.getData("AnnotationData")); if (annotationData == 0) { annotationData = new AnnotationData(); if (static_cast<AnalysisGraph*>(analysis.getData("AnalysisGraph")) != 0) { static_cast<AnalysisGraph*>(analysis.getData("AnalysisGraph"))->populateAnnotationGraph(annotationData, "AnalysisGraph"); } analysis.setData("AnnotationData",annotationData); } handler->startAnalysis(); HandlerStreamBuf hsb(handler); std::ostream outputStream(&hsb); LDEBUG << "EasyXmlDumper:: process before printing heading"; AnalysisGraph* anaGraph = static_cast<AnalysisGraph*>(analysis.getData("AnalysisGraph")); AnalysisGraph* posGraph = static_cast<AnalysisGraph*>(analysis.getData("PosGraph")); if (anaGraph != 0 && posGraph != 0) { LDEBUG << "EasyXmlDumper:: begin of posgraph"; std::vector< bool > alreadyDumpedTokens; std::map< LinguisticAnalysisStructure::Token*, uint64_t > fullTokens; LinguisticGraphVertexIt i, i_end; uint64_t id = 0; alreadyDumpedTokens.resize(num_vertices(*posGraph->getGraph())); for (boost::tie(i, i_end) = vertices(*posGraph->getGraph()); i != i_end; ++i) { LDEBUG << "EasyXmlDumper:: examine posgraph for " << id; alreadyDumpedTokens[id] = false; fullTokens[get(vertex_token, *posGraph->getGraph(), *i)] = id; id++; } /* No need for sentence boundaries in Easy input LinguisticGraphVertex sentenceBegin = sb->getStartVertex(); SegmentationData::iterator sbItr = sb->begin(); LinguisticGraphVertex sentenceBegin = sb->getStartVertex(); SegmentationData::iterator sbItr = sb->begin(); */ LinguisticGraphVertex sentenceBegin = posGraph->firstVertex(); LinguisticGraphVertex sentenceEnd = posGraph->lastVertex(); string sentIdPrefix; try { sentIdPrefix = metadata->getMetaData("docid"); LDEBUG << "EasyXmlDumper:: retrieve sentence id " << sentIdPrefix; }catch (LinguisticProcessingException& ) { sentIdPrefix = ""; } if(sentIdPrefix.length() <= 0) sentIdPrefix = "E"; /* No need for sentence boundaries in Easy input while (sbItr != sb->end()) { LinguisticGraphVertex sentenceEnd = *sbItr; */ LDEBUG << "EasyXmlDumper:: inside posgraph while "; dumpLimaData(outputStream, sentenceBegin, sentenceEnd, *anaGraph, *posGraph, *annotationData, *syntacticData, "PosGraph", alreadyDumpedTokens, fullTokens, sentIdPrefix); /* No need for sentence boundaries in Easy input sentenceBegin = sentenceEnd; sbItr++; } */ LDEBUG << "EasyXmlDumper:: end of posgraph"; } return SUCCESS_ID; }
LimaStatusCode GeoDumper::process( AnalysisContent& analysis) const { DUMPERLOGINIT; LDEBUG << "Process GeoDumper "; LinguisticMetaData* metadata=static_cast<LinguisticMetaData*>(analysis.getData("LinguisticMetaData")); if (metadata == 0) { LERROR << "GeoDumper::process: no LinguisticMetaData ! abort"; return MISSING_DATA; } /*AnalysisHandlerContainer* handlerContainer=static_cast<AnalysisHandlerContainer*>(analysis.getData("AnalysisHandlerContainer")); if (handlerContainer == 0) { LERROR << "GeoDumper::process: no handler in analysisContent ! abort"; return MISSING_DATA; }*/ Lima::Common::AnnotationGraphs::AnnotationData* annotationData = static_cast< Lima::Common::AnnotationGraphs::AnnotationData* >(analysis.getData("AnnotationData")); if (annotationData==0) { LERROR << "GeoDumper::process: no AnnotationData ! abort"; return MISSING_DATA; } //AbstractTextualAnalysisHandler* handler = static_cast<AbstractTextualAnalysisHandler*>(handlerContainer->getHandler()); LDEBUG << "handler will be: " << m_handler; //MediaId langid = static_cast<const Common::MediaticData::LanguageData&>(Common::MediaticData::MediaticData::single().mediaData(metadata->getMetaData("Lang"))).getMedia(); AnalysisHandlerContainer* h = static_cast<AnalysisHandlerContainer*>(analysis.getData("AnalysisHandlerContainer")); AbstractTextualAnalysisHandler* handler = static_cast<AbstractTextualAnalysisHandler*>(h->getHandler(m_handler)); if (handler==0) { LERROR << "GeoDumper::process: handler " << m_handler << " has not been given to the core client"; return MISSING_DATA; } //handler->setOut(&std::cout); handler->startAnalysis(); HandlerStreamBuf hsb(handler); std::ostream out(&hsb); map<Token*, pair<LinguisticGraphVertex,vector<MorphoSyntacticData*> >, lTokenPosition > categoriesMapping; AnalysisGraph* anagraph=static_cast<AnalysisGraph*>(analysis.getData(m_graph)); LinguisticGraph* graph=anagraph->getGraph(); ltNormProperty sorter(m_propertyAccessor); //const FsaStringsPool& sp=Common::MediaticData::MediaticData::single().stringsPool(m_language); LinguisticGraphVertexIt vxItr,vxItrEnd; boost::tie(vxItr,vxItrEnd) = vertices(*graph); for (;vxItr!=vxItrEnd;vxItr++) { Token* ft=get(vertex_token,*graph,*vxItr); if( ft!=0) { std::pair<LinguisticGraphVertex,vector<MorphoSyntacticData*> > element =categoriesMapping[ft]; element.second.push_back(get(vertex_data,*graph,*vxItr)); element.first=*vxItr; categoriesMapping[ft]=element; } } for (map<Token*, pair<LinguisticGraphVertex,vector<MorphoSyntacticData*> >, lTokenPosition >::const_iterator ftItr=categoriesMapping.begin(); ftItr!=categoriesMapping.end(); ftItr++) { Token* ft=ftItr->first; std::ostringstream os; // get position uint64_t position=ft->position() + metadata->getStartOffset(); // get string std::string str=Common::Misc::limastring2utf8stdstring(ft->stringForm()); // replace separator in string by '_' string::size_type sepLen=m_sep.size(); string::size_type p=0; while ( (p = str.find(m_sep, p)) != string::npos ) { str.replace( p, sepLen, "_"); p++; } // newlines (paragraphes) => print empty line //if (str=="\n") { // os << str; continue; //} if (m_printPosition) { os << position << m_sep; } os << str << m_sep; // POS std::set<LinguisticCode> props; vector<MorphoSyntacticData*> vt=ftItr->second.second; for (vector<MorphoSyntacticData*>::const_iterator dataItr=vt.begin(); dataItr!=vt.end(); dataItr++) { MorphoSyntacticData* data=*dataItr; sort(data->begin(),data->end(),sorter); //StringsPoolIndex norm(0),curNorm(0); LinguisticCode prop(0); // output first MorphoSyntacticData::const_iterator elemIt=data->begin(),elemIt_end=data->end(); //norm=elemIt->normalizedForm; if(elemIt != elemIt_end) { prop=m_propertyAccessor->readValue(elemIt->properties); os << m_propertyManager->getPropertySymbolicValue(prop); props.insert(prop); // output rest, with separator for ( elemIt++; elemIt!=elemIt_end; elemIt++) { //curNorm=elemIt->normalizedForm; prop=m_propertyAccessor->readValue(elemIt->properties); //if ((curNorm != norm) || (curProp != prop)) { // norm=curNorm; // prop=curProp; if (props.find(prop)==props.end()) { os << m_sepPOS << m_propertyManager->getPropertySymbolicValue(prop); props.insert(prop); } } } } std::set< AnnotationGraphVertex > matches = annotationData->matches(anagraph->getGraphId(),(ftItr->second).first,"annot"); if (annotationData->hasAnnotation(*matches.begin(),utf8stdstring2limastring("GeoEntity"))) { os << m_sep; os << annotationData->annotation(*matches.begin(),Common::Misc::utf8stdstring2limastring("GeoEntity")) .pointerValue<GeoEntityAnnotation>()->getPosition(); os << m_sep; std::set<std::string> classes=annotationData->annotation(*matches.begin(),Common::Misc::utf8stdstring2limastring("GeoEntity")) .pointerValue<GeoEntityAnnotation>()->getGeoClasses(); for (std::set<std::string>::iterator iT = classes.begin(); iT!=classes.end();) { os << *iT; iT++; if (iT!=classes.end()) os << " "; } } out << os.str(); out << endl; } out.flush(); handler->endAnalysis(); return SUCCESS_ID; }