cv::vector<cv::Mat*> CGlObjLoader::getAppearance(double r, double p, double y){ roll = r; pitch = p; yaw = y; Reshape(640, 480); Display(); cv::Mat* app = new cv::Mat(frontBuffer); cv::Mat* depth = new cv::Mat(depthBuffer); cv::vector<cv::Mat*> appearance(0); appearance.push_back(app); appearance.push_back(depth); return appearance; }
Mat TrackingAndDetection::createAppearance(Mat frame, Location location, int width, int height) { int xStart, yStart; location.getCornerPoint(&xStart, &yStart, frame); Mat appearance(height, width, frame.type()); for(int x = 0; x < width; x++) { for(int y = 0; y < height; y++) { int locX = x + xStart; int locY = y + yStart; rotatePosition(location.getRotation(), &locX, &locY, frame.size().width / 2, frame.size().height / 2); appearance.at<Vec3b>(Point(x,y)) = frame.at<Vec3b>(Point(locX, locY)); } } return appearance; }
cv::vector<cv::Mat*> CGlObjLoader::getAppearance(double* angle){ roll = angle[0]; pitch = angle[1]; yaw = angle[2]; Reshape(640, 480); //for(int i = 0; i < 20; ++i) Display(); cv::Mat* app = new cv::Mat(frontBuffer); cv::Mat* depth = new cv::Mat(depthBuffer); cv::vector<cv::Mat*> appearance(0); appearance.push_back(app); appearance.push_back(depth); return appearance; }
widget_object() { handle_ = API::dev::create_window(nullptr, false, API::make_center(300, 150), appearance(), this); _m_bind_and_attach(); }
widget_object(window owner, bool nested, const rectangle& r = rectangle(), const appearance& apr = appearance()) { handle_ = API::dev::create_window(owner, nested, r, apr, this); _m_bind_and_attach(); }
widget_object(const rectangle& r, const appearance& apr = appearance()) { handle_ = API::dev::create_window(nullptr, false, r, apr, this); _m_bind_and_attach(); }
vector<vector<Event> > ChaingraphTracking::operator()(TraxelStore& ts) { LOG(logINFO) << "Calling chaingraph tracking with the following parameters:\n" << "\trandom forest filename: " << rf_fn_ << "\n" << "\tappearance: " << app_ << "\n" << "\tdisappearance: " << dis_ << "\n" << "\tdetection: " << det_ << "\n" << "\tmisdetection: " << mis_ << "\n" << "\tcellness_by_random_forest: " << use_rf_ << "\n" << "\topportunity cost: " << opportunity_cost_ << "\n" << "\tforbidden cost: " << forbidden_cost_ << "\n" << "\twith constraints: " << with_constraints_ << "\n" << "\tfixed detections: " << fixed_detections_ << "\n" << "\tmean division distance: " << mean_div_dist_ << "\n" << "\tminimal division angle: " << min_angle_ << "\n" << "\tcplex ep gap: " << ep_gap_ << "\n" << "\tn neighbors: " << n_neighbors_ << "\n" << "\twith divisions: " << with_divisions_ << "\n" << "\tcplex timeout: " << cplex_timeout_ << "\n" << "\talternative builder: " << alternative_builder_; cout << "-> building feature functions " << endl; SquaredDistance move; BorderAwareConstant appearance(app_, earliest_timestep(ts), true, 0); BorderAwareConstant disappearance(dis_, latest_timestep(ts), false, 0); GeometryDivision2 division(mean_div_dist_, min_angle_); Traxels empty; // random forest? boost::function<double(const Traxel&)> detection, misdetection; if (use_rf_) { LOG(logINFO) << "Loading Random Forest"; vigra::RandomForest<RF::RF_LABEL_TYPE> rf = RF::getRandomForest(rf_fn_); std::vector<std::string> rf_features; rf_features.push_back("volume"); rf_features.push_back("bbox"); rf_features.push_back("position"); rf_features.push_back("com"); rf_features.push_back("pc"); rf_features.push_back("intensity"); rf_features.push_back("intminmax"); rf_features.push_back("pair"); rf_features.push_back("sgf"); rf_features.push_back("lcom"); rf_features.push_back("lpc"); rf_features.push_back("lintensity"); rf_features.push_back("lintminmax"); rf_features.push_back("lpair"); rf_features.push_back("lsgf"); LOG(logINFO) << "Predicting cellness"; RF::predict_traxels(ts, rf, rf_features, 1, "cellness"); detection = NegLnCellness(det_); misdetection = NegLnOneMinusCellness(mis_); } else if (ts.begin()->features.find("detProb") != ts.begin()->features.end()) { for (TraxelStore::iterator it = ts.begin(); it != ts.end(); ++it) { Traxel trax = *it; trax.features["cellness"] = trax.features["detProb"]; assert(trax.features["detProb"].size() == 2); ts.replace(it, trax); } detection = NegLnCellness(det_); misdetection = NegLnOneMinusCellness(mis_); } else { detection = ConstantFeature(det_); misdetection = ConstantFeature(mis_); } cout << "-> building hypotheses" << endl; SingleTimestepTraxel_HypothesesBuilder::Options builder_opts(n_neighbors_, 50); SingleTimestepTraxel_HypothesesBuilder hyp_builder(&ts, builder_opts); boost::shared_ptr<HypothesesGraph> graph = boost::shared_ptr<HypothesesGraph>(hyp_builder.build()); cout << "-> init MRF reasoner" << endl; std::auto_ptr<Chaingraph> mrf; if(alternative_builder_) { pgm::chaingraph::TrainableModelBuilder b(appearance, disappearance, move, opportunity_cost_, forbidden_cost_); if (with_divisions_) { b.with_divisions(division); } b.with_detection_vars(detection, misdetection); mrf = std::auto_ptr<Chaingraph>(new Chaingraph(b, with_constraints_, ep_gap_, fixed_detections_, cplex_timeout_)); } else { pgm::chaingraph::ECCV12ModelBuilder b(appearance, disappearance, move, opportunity_cost_, forbidden_cost_); if (with_divisions_) { b.with_divisions(division); } b.with_detection_vars(detection, misdetection); mrf = std::auto_ptr<Chaingraph>(new Chaingraph(b, with_constraints_, ep_gap_, fixed_detections_, cplex_timeout_)); } cout << "-> formulate MRF model" << endl; mrf->formulate(*graph); cout << "-> infer" << endl; mrf->infer(); cout << "-> conclude" << endl; mrf->conclude(*graph); cout << "-> storing state of detection vars" << endl; last_detections_ = state_of_nodes(*graph); cout << "-> pruning inactive hypotheses" << endl; prune_inactive(*graph); cout << "-> constructing events" << endl; return *events(*graph); }
void Preferences::Save(Configuration& cfg) const { Configuration::Section preferences( cfg["preferences"] ); { Configuration::Section application( preferences["application"] ); application[ "autostart" ].YesNo() = settings[ AUTOSTART_EMULATION ]; application[ "run-background" ].YesNo() = settings[ RUN_IN_BACKGROUND ]; application[ "start-fullscreen" ].YesNo() = settings[ START_IN_FULLSCREEN ]; application[ "suppress-warnings" ].YesNo() = settings[ SUPPRESS_WARNINGS ]; application[ "exit-power-off" ].YesNo() = settings[ FIRST_UNLOAD_ON_EXIT ]; application[ "confirm-exit" ].YesNo() = settings[ CONFIRM_EXIT ]; application[ "confirm-reset" ].YesNo() = settings[ CONFIRM_RESET ]; application[ "allow-multiple-instances" ].YesNo() = settings[ ALLOW_MULTIPLE_INSTANCES ]; application[ "priority" ].Str() = ( settings.priority == PRIORITY_HIGH ? "high" : settings.priority == PRIORITY_ABOVE_NORMAL ? "above normal" : "normal" ); application[ "favored-system" ].Str() = ( settings.favoredSystem == Nes::Machine::FAVORED_NES_PAL ? "nes-pal" : settings.favoredSystem == Nes::Machine::FAVORED_FAMICOM ? "famicom" : settings.favoredSystem == Nes::Machine::FAVORED_DENDY ? "dendy" : "nes-ntsc" ); application[ "favored-system-always-ask" ].YesNo() = settings.alwaysAskSystem; } { Configuration::Section save( preferences["save"] ); save[ "logfile" ].YesNo() = settings[ SAVE_LOGFILE ]; save[ "settings" ].YesNo() = settings[ SAVE_SETTINGS ]; save[ "launcher" ].YesNo() = settings[ SAVE_LAUNCHER ]; save[ "cheats" ].YesNo() = settings[ SAVE_CHEATS ]; save[ "netplay-list" ].YesNo() = settings[ SAVE_NETPLAY_GAMELIST ]; save[ "window-main" ].YesNo() = settings[ SAVE_WINDOWPOS ]; save[ "window-launcher" ].YesNo() = settings[ SAVE_LAUNCHERSIZE ]; } { Configuration::Section appearance( preferences["appearance"] ); appearance[ "icon-style" ].Str() = ( Application::Instance::GetIconStyle() == Application::Instance::ICONSTYLE_NES ? "nes" : "famicom" ); appearance[ "menu-desktop" ][ "use-custom-color" ].YesNo() = settings.menuLookDesktop.enabled; appearance[ "menu-fullscreen" ][ "use-custom-color" ].YesNo() = settings.menuLookFullscreen.enabled; appearance[ "menu-desktop" ][ "custom-color" ].Str() = HexString( 32, settings.menuLookDesktop.color ); appearance[ "menu-fullscreen" ][ "custom-color" ].Str() = HexString( 32, settings.menuLookFullscreen.color ); } }
Preferences::Preferences(Managers::Emulator& e,const Configuration& cfg) : dialog ( IDD_PREFERENCES, this, Handlers::messages, Handlers::commands ), emulator ( e ) { NST_COMPILE_ASSERT ( START_IN_FULLSCREEN == IDC_PREFERENCES_STARTUP_FULLSCREEN - IDC_PREFERENCES_STARTUP_FULLSCREEN && SUPPRESS_WARNINGS == IDC_PREFERENCES_DISABLE_ROM_WARNINGS - IDC_PREFERENCES_STARTUP_FULLSCREEN && FIRST_UNLOAD_ON_EXIT == IDC_PREFERENCES_CLOSE_POWER_OFF - IDC_PREFERENCES_STARTUP_FULLSCREEN && CONFIRM_EXIT == IDC_PREFERENCES_CONFIRM_EXIT - IDC_PREFERENCES_STARTUP_FULLSCREEN && RUN_IN_BACKGROUND == IDC_PREFERENCES_RUN_IN_BACKGROUND - IDC_PREFERENCES_STARTUP_FULLSCREEN && AUTOSTART_EMULATION == IDC_PREFERENCES_BEGIN_EMULATION - IDC_PREFERENCES_STARTUP_FULLSCREEN && SAVE_LOGFILE == IDC_PREFERENCES_SAVE_LOGFILE - IDC_PREFERENCES_STARTUP_FULLSCREEN && ALLOW_MULTIPLE_INSTANCES == IDC_PREFERENCES_MULTIPLE_INSTANCES - IDC_PREFERENCES_STARTUP_FULLSCREEN && SAVE_LAUNCHER == IDC_PREFERENCES_SAVE_LAUNCHER - IDC_PREFERENCES_STARTUP_FULLSCREEN && CONFIRM_RESET == IDC_PREFERENCES_CONFIRM_RESET - IDC_PREFERENCES_STARTUP_FULLSCREEN && SAVE_CHEATS == IDC_PREFERENCES_SAVE_CHEATCODES - IDC_PREFERENCES_STARTUP_FULLSCREEN && SAVE_NETPLAY_GAMELIST == IDC_PREFERENCES_SAVE_NETPLAY_GAMELIST - IDC_PREFERENCES_STARTUP_FULLSCREEN && SAVE_WINDOWPOS == IDC_PREFERENCES_SAVE_WINDOWPOS - IDC_PREFERENCES_STARTUP_FULLSCREEN && SAVE_LAUNCHERSIZE == IDC_PREFERENCES_SAVE_LAUNCHERSIZE - IDC_PREFERENCES_STARTUP_FULLSCREEN ); Configuration::ConstSection preferences( cfg["preferences"] ); { Configuration::ConstSection application( preferences["application"] ); settings[ AUTOSTART_EMULATION ] = !application[ "autostart" ].No(); settings[ RUN_IN_BACKGROUND ] = application[ "run-background" ].Yes(); settings[ START_IN_FULLSCREEN ] = application[ "start-fullscreen" ].Yes(); settings[ SUPPRESS_WARNINGS ] = application[ "suppress-warnings" ].Yes(); settings[ FIRST_UNLOAD_ON_EXIT ] = application[ "exit-power-off" ].Yes(); settings[ CONFIRM_EXIT ] = !application[ "confirm-exit" ].No(); settings[ CONFIRM_RESET ] = application[ "confirm-reset" ].Yes(); settings[ ALLOW_MULTIPLE_INSTANCES ] = application[ "allow-multiple-instances" ].Yes(); { const GenericString priority( application[ "priority" ].Str() ); if (priority == L"high") { settings.priority = PRIORITY_HIGH; } else if (priority == L"above normal") { settings.priority = PRIORITY_ABOVE_NORMAL; } else { settings.priority = PRIORITY_NORMAL; } } { const GenericString favored( application[ "favored-system" ].Str() ); if (favored == L"nes-pal") { settings.favoredSystem = Nes::Machine::FAVORED_NES_PAL; } else if (favored == L"famicom") { settings.favoredSystem = Nes::Machine::FAVORED_FAMICOM; } else if (favored == L"dendy") { settings.favoredSystem = Nes::Machine::FAVORED_DENDY; } else { settings.favoredSystem = Nes::Machine::FAVORED_NES_NTSC; } } settings.alwaysAskSystem = application[ "favored-system-always-ask" ].Yes(); } { Configuration::ConstSection save( preferences["save"] ); settings[ SAVE_LOGFILE ] = !save[ "logfile" ].No(); settings[ SAVE_SETTINGS ] = !save[ "settings" ].No(); settings[ SAVE_LAUNCHER ] = !save[ "launcher" ].No(); settings[ SAVE_CHEATS ] = !save[ "cheats" ].No(); settings[ SAVE_NETPLAY_GAMELIST ] = !save[ "netplay-list" ].No(); settings[ SAVE_WINDOWPOS ] = save[ "window-main" ].Yes(); settings[ SAVE_LAUNCHERSIZE ] = save[ "window-launcher" ].Yes(); } { Configuration::ConstSection appearance( preferences["appearance"] ); settings.menuLookDesktop.enabled = appearance[ "menu-desktop" ][ "use-custom-color" ].Yes(); settings.menuLookFullscreen.enabled = appearance[ "menu-fullscreen" ][ "use-custom-color" ].Yes(); settings.menuLookDesktop.color = appearance[ "menu-desktop" ][ "custom-color" ].Int( DEFAULT_DESKTOP_MENU_COLOR ); settings.menuLookFullscreen.color = appearance[ "menu-fullscreen" ][ "custom-color" ].Int( DEFAULT_FULLSCREEN_MENU_COLOR ); Application::Instance::SetIconStyle ( appearance[ "icon-style" ].Str() == L"famicom" ? Application::Instance::ICONSTYLE_FAMICOM : Application::Instance::ICONSTYLE_NES ); } Association association; const uint iconOffset = (Application::Instance::GetIconStyle() == Application::Instance::ICONSTYLE_NES ? 3 : 4); for (uint i=0; i < Association::NUM_EXTENSIONS; ++i) association.Update( i, icons[i][iconOffset] ); }
GUI::GUI( FileLogger *logger ) :ui( API::make_center(390, 300), appearance(true,true,true,false,true,false,false ) ) ,genBridges( ui, rectangle( 270, 5, 130, 25), true) ,saveHeightMap( ui, rectangle( 270, 30, 130, 25), true) ,x(ui, rectangle( 5, 5, 190, 25 )) ,y(ui, rectangle( 5, 35, 190, 25 )) ,z(ui, rectangle( 5, 65, 190, 25 )) ,lx(ui, rectangle( 200, 10, 70, 20 )) ,ly(ui, rectangle( 200, 40, 70, 20 )) ,lz(ui, rectangle( 200, 70, 70, 20 )) ,ll(ui, rectangle( 10, 95, 70, 20 )) ,seedl(ui, rectangle( 10, 120, 40, 20 )) ,seedb(ui, rectangle( 50, 118, 142, 20 )) ,bs(ui, rectangle( 5, 150, 190, 25 )) ,bn(ui, rectangle( 5, 180, 190, 25 )) ,bm(ui, rectangle( 5, 210, 190, 25 )) ,bspa(ui, rectangle( 200, 155, 200, 40 )) ,bmin(ui, rectangle( 200, 185, 200, 40 )) ,bmax(ui, rectangle( 200, 215, 200, 40 )) ,bridl(ui, rectangle( 10, 245, 200, 20 )) ,gen(ui, rectangle( 300, 250, 80, 40 )) ,prog(ui, rectangle( 5, 280, 290, 10 )) ,lprog(ui, rectangle( 5, 265, 290, 15 )) { mLogger = logger; mLogger->Log( INFO, mPrefix + "Initializing GUI..." ); ui.caption( TITLE ); genBridges.caption( GEN_BRIDGE ); genBridges.check( gs.generateBridges ); lprog.caption( "Ready!" ); saveHeightMap.caption( SAVE_HEIGHTMAP ); saveHeightMap.check( gs.saveHeightMap ); genBridges.events().checked( [&](){ gs.generateBridges = (bool)genBridges.checked(); } ); saveHeightMap.events().checked( [&](){ gs.saveHeightMap = (bool)saveHeightMap.checked(); } ); gen.caption( "GENERATE" ); gen.events().click( [&](){ prog.unknown( false ); prog.value( 0 ); lprog.caption( "Initializing..." ); gs.seed = std::hash<std::string>()( sSeed ); mLogger->Log( INFO, mPrefix + "Seed : '" + sSeed + "'" ); mLogger->Log( INFO, mPrefix + "Seed hash: '" + to_string( gs.seed ) + "'" ); Genek generator( mLogger ); prog.value( prog.amount() / 4 ); lprog.caption( "Generating level..." ); generator.generateMap( gs ); prog.value( prog.amount() / 2 ); lprog.caption( "Saving level to file..." ); generator.exportMap(); prog.value( prog.amount() ); lprog.caption( "Done!" ); } ); x.vmax( MAX_SIZE ); y.vmax( MAX_SIZE ); z.vmax( MAX_HEIGHT ); x.value( gs.sizeX ); y.value( gs.sizeY ); z.value( gs.sizeZ ); bs.vmax( MAX_SPACING ); bn.vmax( MIN_MAX_LENGTH ); bm.vmax( MAX_LENGTH ); bs.events().value_changed( [&](){ if( bs.value() > 2 ) gs.bridgeSpacing = bs.value(); else { bs.value( 2 ); gs.bridgeSpacing = bs.value(); } bspa.caption( "Spacing: " + to_string( bs.value() ) ); } ); bn.events().value_changed( [&](){ if( bn.value() > 2 ) gs.bridgeMinLength = bn.value(); else { bn.value( 2 ); gs.bridgeMinLength = bn.value(); } bmin.caption( "Min Length: " + to_string( bn.value() ) ); } ); bm.events().value_changed( [&](){ if( bm.value() > MIN_MAX_LENGTH ) gs.bridgeMaxLength = bm.value(); else { bm.value( MIN_MAX_LENGTH ); gs.bridgeMaxLength = bm.value(); } bmax.caption( "Max Length: " + to_string( bm.value() ) ); } ); bs.value( gs.bridgeSpacing ); bn.value( gs.bridgeMinLength ); bm.value( gs.bridgeMaxLength ); bridl.caption( "BRIDGE GENERATOR SETTINGS" ); bspa.caption( "Spacing: " + to_string( bs.value() ) ); bmin.caption( "Min Length: " + to_string( bn.value() ) ); bmax.caption( "Max Length: " + to_string( bm.value() ) ); x.events().value_changed( [&](){ if( x.value() > MIN_SIZE ) gs.sizeX = x.value(); else { x.value( MIN_SIZE ); gs.sizeX = x.value(); } lx.caption( "X: " + to_string( gs.sizeX ) ); } ); y.events().value_changed( [&](){ if( y.value() > MIN_SIZE ) gs.sizeY = y.value(); else { y.value( MIN_SIZE ); gs.sizeY = y.value(); } ly.caption( "Y: " + to_string( gs.sizeY ) ); } ); z.events().value_changed( [&](){ if( z.value() > MIN_HEIGHT ) gs.sizeZ = z.value(); else { z.value( MIN_HEIGHT ); gs.sizeZ = z.value(); } lz.caption( "Z: " + to_string( gs.sizeZ ) ); } ); lx.caption( "X: " + to_string( gs.sizeX ) ); ly.caption( "Y: " + to_string( gs.sizeY ) ); lz.caption( "Z: " + to_string( gs.sizeZ ) ); ll.caption( "LEVEL SIZE" ); seedl.caption( "SEED:" ); seedb.multi_lines( false ); seedb.tip_string( "LEVEL SEED" ); seedb.events().text_changed( [&](){ seedb.getline( 0, sSeed ); } ); paint::image icon("data/icon.ico"); API::window_icon( ui, icon ); }