FrameManager::FrameManager() { playerList = CreateFrameArrayFromFile ( "player", gcnew array<Point> { Point(0,14), // Idle Point(15,29), // Hurt Point(30,110), // Boss Hurt Point(111,185), // Lesser Ice Point(186,242), // Greater Ice Point(243,260), // Walk Point(261,290), // Basic Attack Point(291,327), // Dodge Point(328,383), // Electric Storm Point(384,425), // Heavy Attack Point(426,472), // Whirlwind Attack Point(473,499) // Heal } ); cocoonList = CreateFrameArrayFromFile ( "cocoon", gcnew array<Point> { Point(0,22), // Idle Point(23,71), // Hurt Point(72,104), // Desecrate Point(105,158), // Tentishock Point(159,215), // Oil Spill Point(216,249) // Killed } ); perunaList = CreateFrameArrayFromFile ( "peruna", gcnew array<Point> { Point(0,12), // Idle Point(13,22), // Hurt Point(23,47), // Desecrate Point(48,72), // Tentishock Point(73,91), // Oil Spill Point(92,105) // Killed } ); fluppitList = CreateFrameArrayFromFile ( "fluppit", gcnew array<Point> { Point(0,7), // Idle Point(7,46), // Hurt Point(46,75), // Desecrate Point(75,97), // Tentishock Point(97,107), // Oil Spill Point(108,125) // Killed } ); floppitList = CreateFrameArrayFromFile ( "floppit", gcnew array<Point> { Point(0,7), // Idle Point(7,46), // Hurt Point(46,75), // Desecrate Point(75,97), // Tentishock Point(97,107), // Oil Spill Point(108,125) // Killed } ); makhanaList = CreateFrameArrayFromFile ( "makhana", gcnew array<Point> { Point(0,22), // Idle Point(23,60), // Hurt Point(61,134), // Desecrate Point(135,188), // Tentishock Point(189,259), // Oil Spill Point(260,303) // Killed } ); }
BonkEnc::GeneralSettingsDialog::GeneralSettingsDialog() { Point pos; Size size; currentConfig = BonkEnc::currentConfig; mainWnd = new Window(BonkEnc::i18n->TranslateString("General settings setup"), currentConfig->wndPos + Point(40, 40), Size(570, 352)); mainWnd->SetRightToLeft(BonkEnc::i18n->IsActiveLanguageRightToLeft()); mainWnd_titlebar = new Titlebar(TB_CLOSEBUTTON); divbar = new Divider(39, OR_HORZ | OR_BOTTOM); register_layer_encoders = new GeneralSettingsLayerEncoders(); register_layer_playlists= new GeneralSettingsLayerPlaylists(); register_layer_language = new GeneralSettingsLayerLanguage(); register_layer_cdrip = new GeneralSettingsLayerCDRip(); register_layer_cddb = new GeneralSettingsLayerCDDB(); register_layer_plugins = new GeneralSettingsLayerPlugins(); register_layer_tags = new GeneralSettingsLayerTags(); pos.x = 175; pos.y = 29; size.cx = 0; size.cy = 0; btn_cancel = new Button(BonkEnc::i18n->TranslateString("Cancel"), NIL, pos, size); btn_cancel->onAction.Connect(&GeneralSettingsDialog::Cancel, this); btn_cancel->SetOrientation(OR_LOWERRIGHT); pos.x -= 88; btn_ok = new Button(BonkEnc::i18n->TranslateString("OK"), NIL, pos, size); btn_ok->onAction.Connect(&GeneralSettingsDialog::OK, this); btn_ok->SetOrientation(OR_LOWERRIGHT); pos.x = 7; pos.y = 7; size.cx = 548; size.cy = 265; reg_register = new TabWidget(pos, size); Add(mainWnd); mainWnd->Add(mainWnd_titlebar); mainWnd->Add(divbar); mainWnd->Add(btn_ok); mainWnd->Add(btn_cancel); mainWnd->Add(reg_register); reg_register->Add(register_layer_encoders); reg_register->Add(register_layer_playlists); if (BonkEnc::i18n->GetNOfLanguages() > 1) reg_register->Add(register_layer_language); if (currentConfig->enable_cdrip && currentConfig->cdrip_numdrives >= 1) reg_register->Add(register_layer_cdrip); if (currentConfig->enable_cdrip && currentConfig->cdrip_numdrives >= 1) reg_register->Add(register_layer_cddb); reg_register->Add(register_layer_plugins); reg_register->Add(register_layer_tags); mainWnd->SetFlags(mainWnd->GetFlags() | WF_NOTASKBUTTON); mainWnd->SetIcon(ImageLoader::Load("freac.pci:0")); }
Point input_direction(long ch) { switch (KEYBINDINGS.bound_to_key(ch)) { case IACTION_MOVE_N: return Point( 0, -1); case IACTION_MOVE_NE: return Point( 1, -1); case IACTION_MOVE_E: return Point( 1, 0); case IACTION_MOVE_SE: return Point( 1, 1); case IACTION_MOVE_S: return Point( 0, 1); case IACTION_MOVE_SW: return Point(-1, 1); case IACTION_MOVE_W: return Point(-1, 0); case IACTION_MOVE_NW: return Point(-1, -1); case IACTION_PAUSE: return Point( 0, 0); default: return Point(-2, -2); // Be sure to check for this! } return Point(-2, -2); }
void Node::onInit() { // map_size parameter XmlRpc::XmlRpcValue p_map_size; if (getPrivateNodeHandle().getParam("map_size", p_map_size)) { Size &map_size = parameters_("map_size", Size(0, 0, 0)); if (p_map_size.getType() == XmlRpc::XmlRpcValue::TypeInt) { map_size.x() = map_size.y() = static_cast<int>(p_map_size); } else if (p_map_size.getType() == XmlRpc::XmlRpcValue::TypeArray) { if (p_map_size.size() >= 2) { map_size.x() = static_cast<int>(p_map_size[0]); map_size.y() = static_cast<int>(p_map_size[1]); } if (p_map_size.size() >= 3) { map_size.z() = static_cast<int>(p_map_size[2]); } } } // map_resolution parameter XmlRpc::XmlRpcValue p_map_resolution; if (getPrivateNodeHandle().getParam("map_resolution", p_map_resolution)) { Resolution &resolution = parameters_("map_resolution", Resolution(0.0, 0.0, 0.0)); if (p_map_resolution.getType() == XmlRpc::XmlRpcValue::TypeDouble) { resolution.x() = resolution.y() = static_cast<double>(p_map_resolution); } else if (p_map_resolution.getType() == XmlRpc::XmlRpcValue::TypeArray) { if (p_map_resolution.size() >= 2) { resolution.x() = static_cast<double>(p_map_resolution[0]); resolution.y() = static_cast<double>(p_map_resolution[1]); } if (p_map_resolution.size() >= 3) { resolution.z() = static_cast<double>(p_map_resolution[2]); } } } // map_offset parameter XmlRpc::XmlRpcValue p_map_offset; if (getPrivateNodeHandle().getParam("map_offset", p_map_offset)) { Point &offset = parameters_("map_offset", Point(0.0, 0.0, 0.0)); if (p_map_offset.getType() == XmlRpc::XmlRpcValue::TypeArray) { if (p_map_offset.size() >= 2) { offset.x() = static_cast<double>(p_map_offset[0]); offset.y() = static_cast<double>(p_map_offset[1]); } if (p_map_offset.size() >= 3) { offset.z() = static_cast<double>(p_map_offset[2]); } } } // map_type parameter std::string p_map_type = "OccupancyGridMap2D"; getPrivateNodeHandle().getParam("map_type", p_map_type); map_ = MapFactory(parameters_).create<OccupancyGridMapBase>(p_map_type); if (!map_) { ROS_FATAL("Unknown map type: %s.\n\nAvailable map types:\n%s", p_map_type.c_str(), MapFactory::getMapTypes().c_str()); ros::shutdown(); return; } // scan matcher parameters ScanMatcherParameters &matcher_parameters = parameters_("matcher", ScanMatcherParameters()); getPrivateNodeHandle().getParam("match_level_minimum", matcher_parameters.match_level_minimum()); getPrivateNodeHandle().getParam("match_level_maximum", matcher_parameters.match_level_maximum()); getPrivateNodeHandle().getParam("occupied_space_residual_weight", matcher_parameters.occupied_space_residual_weight()); getPrivateNodeHandle().getParam("free_space_residual_weight", matcher_parameters.free_space_residual_weight()); getPrivateNodeHandle().getParam("motion_residual_weight", matcher_parameters.motion_residual_weight()); getPrivateNodeHandle().getParam("function_tolerance", matcher_parameters.function_tolerance()); getPrivateNodeHandle().getParam("gradient_tolerance", matcher_parameters.gradient_tolerance()); getPrivateNodeHandle().getParam("parameter_tolerance", matcher_parameters.parameter_tolerance()); getPrivateNodeHandle().getParam("max_num_iterations", matcher_parameters.max_num_iterations()); getPrivateNodeHandle().getParam("max_solver_time_in_seconds", matcher_parameters.max_solver_time_in_seconds()); // get occupancy parameters OccupancyParameters &occupancy_parameters = parameters_("occupancy", OccupancyParameters::Default()); double p_update_factor_free, p_update_factor_occupied; // private_nh_.param("update_factor_free", p_update_factor_free_, 0.4); // private_nh_.param("update_factor_occupied", p_update_factor_occupied_, 0.9); if (getPrivateNodeHandle().getParam("update_factor_free", p_update_factor_free)) occupancy_parameters.step_free() = occupancy_parameters.getOccupancy(p_update_factor_free); if (getPrivateNodeHandle().getParam("update_factor_occupied", p_update_factor_occupied)) occupancy_parameters.step_occupied() = occupancy_parameters.getOccupancy(p_update_factor_occupied); // get scan parameters ScanParameters &scan_parameters = parameters_("scan", ScanParameters()); getPrivateNodeHandle().getParam("laser_min_dist", scan_parameters.min_distance()); getPrivateNodeHandle().getParam("laser_max_dist", scan_parameters.max_distance()); getPrivateNodeHandle().getParam("laser_z_min_value", scan_parameters.min_z()); getPrivateNodeHandle().getParam("laser_z_max_value", scan_parameters.max_z()); // get other parameters getPrivateNodeHandle().getParam("map_frame", p_map_frame_); getPrivateNodeHandle().getParam("base_frame", p_base_frame_); getPrivateNodeHandle().getParam("odom_frame", p_odom_frame_); getPrivateNodeHandle().getParam("use_tf_scan_transformation", p_use_tf_scan_transformation_); getPrivateNodeHandle().getParam("use_tf_pose_start_estimate", p_use_tf_pose_start_estimate_); getPrivateNodeHandle().getParam("pub_map_odom_transform", p_pub_map_odom_transform_); getPrivateNodeHandle().getParam("advertise_map_service", p_advertise_map_service_); getPrivateNodeHandle().getParam("map_update_distance_thresh", p_map_update_translational_threshold_); getPrivateNodeHandle().getParam("map_update_angle_thresh", p_map_update_angular_threshold_); // private_nh_.param("pub_drawings", p_pub_drawings, false); // private_nh_.param("pub_debug_output", p_pub_debug_output_, false); // private_nh_.param("pub_map_odom_transform", p_pub_map_odom_transform_,true); // private_nh_.param("pub_odometry", p_pub_odometry_,false); // private_nh_.param("advertise_map_service", p_advertise_map_service_,true); // private_nh_.param("scan_subscriber_queue_size", p_scan_subscriber_queue_size_, 5); // private_nh_.param("map_resolution", p_map_resolution_, 0.025); // private_nh_.param("map_size", p_map_size_, 1024); // private_nh_.param("map_start_x", p_map_start_x_, 0.5); // private_nh_.param("map_start_y", p_map_start_y_, 0.5); // private_nh_.param("map_multi_res_levels", p_map_multi_res_levels_, 3); // private_nh_.param("update_factor_free", p_update_factor_free_, 0.4); // private_nh_.param("update_factor_occupied", p_update_factor_occupied_, 0.9); // private_nh_.param("map_update_distance_thresh", p_map_update_distance_threshold_, 0.4); // private_nh_.param("map_update_angle_thresh", p_map_update_angle_threshold_, 0.9); // private_nh_.param("scan_topic", p_scan_topic_, std::string("scan")); // private_nh_.param("sys_msg_topic", p_sys_msg_topic_, std::string("syscommand")); // private_nh_.param("pose_update_topic", p_pose_update_topic_, std::string("poseupdate")); // private_nh_.param("use_tf_scan_transformation", p_use_tf_scan_transformation_,true); // private_nh_.param("use_tf_pose_start_estimate", p_use_tf_pose_start_estimate_,false); // private_nh_.param("map_with_known_poses", p_map_with_known_poses_, false); // private_nh_.param("base_frame", p_base_frame_, std::string("base_link")); // private_nh_.param("map_frame", p_map_frame_, std::string("map")); // private_nh_.param("odom_frame", p_odom_frame_, std::string("odom")); // private_nh_.param("pub_map_scanmatch_transform", p_pub_map_scanmatch_transform_,true); // private_nh_.param("tf_map_scanmatch_transform_frame_name", p_tf_map_scanmatch_transform_frame_name_, std::string("scanmatcher_frame")); // private_nh_.param("output_timing", p_timing_output_,false); // private_nh_.param("map_pub_period", p_map_pub_period_, 2.0); // double tmp = 0.0; // private_nh_.param("laser_min_dist", tmp, 0.4); // p_sqr_laser_min_dist_ = static_cast<float>(tmp*tmp); // private_nh_.param("laser_max_dist", tmp, 30.0); // p_sqr_laser_max_dist_ = static_cast<float>(tmp*tmp); // private_nh_.param("laser_z_min_value", tmp, -1.0); // p_laser_z_min_value_ = static_cast<float>(tmp); // private_nh_.param("laser_z_max_value", tmp, 1.0); // p_laser_z_max_value_ = static_cast<float>(tmp); // initialize scan and scan matcher if (p_use_tf_scan_transformation_) scan_.setTransformer(getTransformListener(), p_base_frame_); matcher_ = ScanMatcher::Factory(parameters_); // subscribe scan scan_subscriber_ = getNodeHandle().subscribe<sensor_msgs::LaserScan>("scan", 10, &Node::scanCallback, this); cloud_subscriber_ = getNodeHandle().subscribe<sensor_msgs::PointCloud2>("point_cloud", 10, &Node::cloudCallback, this); // initial pose subscriber initial_pose_subscriber_ = getNodeHandle().subscribe<geometry_msgs::PoseWithCovarianceStamped>("initialpose", 10, &Node::initialPoseCallback, this); // static map subscriber static_map_subscriber_ = getNodeHandle().subscribe<nav_msgs::OccupancyGrid>("static_map", 10, &Node::staticMapCallback, this); // subscribe syscommand (reset) syscommand_subscriber_ = getNodeHandle().subscribe<std_msgs::String>("syscommand", 10, &Node::syscommandCallback, this); // advertise map map_publisher_ = getNodeHandle().advertise<nav_msgs::OccupancyGrid>("map", 1); map_metadata_publisher_ = getNodeHandle().advertise<nav_msgs::MapMetaData>("map_metadata", 1, true); ROS_INFO("Advertised map as %s", map_publisher_.getTopic().c_str()); // advertise map service if (p_advertise_map_service_) { map_service_ = getNodeHandle().advertiseService("map", &Node::mapServiceCallback, this); } // advertise pose pose_with_covariance_publisher_ = getNodeHandle().advertise<geometry_msgs::PoseWithCovarianceStamped>("poseupdate", 1); pose_publisher_ = getPrivateNodeHandle().advertise<geometry_msgs::PoseStamped>("pose", 1); covariance_publisher_ = getPrivateNodeHandle().advertise<visualization_msgs::Marker>("covariance", 1); // advertise tf if (p_pub_map_odom_transform_) { getTransformListener(); getTransformBroadcaster(); } // advertise scan cloud bool p_publish_scan_cloud = true; getPrivateNodeHandle().getParam("publish_scan_cloud", p_publish_scan_cloud); if (p_publish_scan_cloud) scan_.advertisePointCloud(getPrivateNodeHandle()); // setup map publish thread double p_map_publish_period = 1.0; getPrivateNodeHandle().getParam("map_publish_period", p_map_publish_period); if (p_map_publish_period > 0.0) { map_publish_thread_ = boost::thread(boost::bind(&Node::mapPublishThread, this, ros::Rate(ros::Duration(p_map_publish_period)))); } // advertise timing information #ifdef USE_HECTOR_TIMING timing_publisher_ = getPrivateNodeHandle().advertise<hector_diagnostics::TimingInfo>("timing", 1); #endif // reset reset(); }
} float blockX = m_relativeX + m_blockLength * (c - 1) + blockSpt->getContentSize().width/2; float blockY = m_relativeY +m_blockLength * (r - 1) + blockSpt->getContentSize().height/2; blockSpt->runAction(Sequence::createWithTwoActions(DelayTime::create(0.03 * i), JumpTo::create(0.3f, Point(blockX, blockY), 30, 1))); i++; } m_tipsLayer = LayerColor::create(Color4B(0, 0, 0, 50)); addChild(m_tipsLayer); LabelTTF *tipsTitleLabel = LabelTTF::create("Tap To Continue", "Arial", 40*BBGameDataManager::getInstance()->getScreenScale()); tipsTitleLabel->setColor(Color3B(255, 255, 255)); tipsTitleLabel->setPosition(Point(m_visibleSize.width/2, m_visibleSize.height/2 - 260*BBGameDataManager::getInstance()->getScreenScale())); m_tipsLayer->addChild(tipsTitleLabel); tipsTitleLabel->runAction(RepeatForever::create(Sequence::create(FadeIn::create(.45), FadeOut::create(.65),DelayTime::create(.3), NULL))); m_showTips = true; } void BBHandleLayer::removeTipsLayer() { if (!m_showTips) { return; } Object *spt = NULL; int i = 0;
void ComboBox::Layout(const Rect& previous_rect) { __super::Layout(previous_rect); edit_text_box_->SetRect(Rect(Point(), GetTextRect().size)); }
void FlipY3D::update(float time) { float angle = (float)M_PI * time; // 180 degrees float mz = sinf( angle ); angle = angle / 2.0f; // x calculates degrees from 0 to 90 float my = cosf(angle); Vertex3F v0, v1, v, diff; v0 = getOriginalVertex(Point(1, 1)); v1 = getOriginalVertex(Point(0, 0)); float y0 = v0.y; float y1 = v1.y; float y; Point a, b, c, d; if (y0 > y1) { // Normal Grid a = Point(0,0); b = Point(0,1); c = Point(1,0); d = Point(1,1); y = y0; } else { // Reversed Grid b = Point(0,0); a = Point(0,1); d = Point(1,0); c = Point(1,1); y = y1; } diff.y = y - y * my; diff.z = fabsf(floorf((y * mz) / 4.0f)); // bottom-left v = getOriginalVertex(a); v.y = diff.y; v.z += diff.z; setVertex(a, v); // upper-left v = getOriginalVertex(b); v.y -= diff.y; v.z -= diff.z; setVertex(b, v); // bottom-right v = getOriginalVertex(c); v.y = diff.y; v.z += diff.z; setVertex(c, v); // upper-right v = getOriginalVertex(d); v.y -= diff.y; v.z -= diff.z; setVertex(d, v); }
bool WelcomeLayer::init(){ if(!Layer::init()){ return false; } //get the origin point of the X-Y axis, and the visiable size of the screen Size visiableSize = Director::getInstance()->getVisibleSize(); Point origin = Director::getInstance()->getVisibleOrigin(); //get the current time, the background image will selected by current time day or night: bg_day or bg_night time_t t = time(NULL); tm* lt = localtime(&t); int hour = lt->tm_hour; //create the background image according to the current time; Sprite *background; if(hour >= 6 && hour <= 17){ background = Sprite::createWithSpriteFrame(AtlasLoader::getInstance()->getSpriteFrameByName("bg_day")); }else{ background = Sprite::createWithSpriteFrame(AtlasLoader::getInstance()->getSpriteFrameByName("bg_night")); } background->setAnchorPoint(Point::ZERO); background->setPosition(Point::ZERO); this->addChild(background); //add the word game-title to the current scene Sprite *title = Sprite::createWithSpriteFrame(AtlasLoader::getInstance()->getSpriteFrameByName("title")); title->setPosition(Point(origin.x + visiableSize.width/2 , (visiableSize.height * 5) / 7)); this->addChild(title); //add the start-menu to the current scene Sprite *startButton = Sprite::createWithSpriteFrame(AtlasLoader::getInstance()->getSpriteFrameByName("button_play")); Sprite *activeStartButton = Sprite::createWithSpriteFrame(AtlasLoader::getInstance()->getSpriteFrameByName("button_play")); activeStartButton->setPositionY(5); auto menuItem = MenuItemSprite::create(startButton,activeStartButton,NULL,CC_CALLBACK_1(WelcomeLayer::menuStartCallback, this)); menuItem->setPosition(Point(origin.x + visiableSize.width/2 ,origin.y + visiableSize.height*2/5)); auto menu = Menu::create(menuItem,NULL); menu->setPosition(Point(origin.x ,origin.y)); this->addChild(menu,1); //create a bird and set the position in the center of the screen this->bird = BirdSprite::getInstance(); this->bird->createBird(); this->bird->setTag(BIRD_SPRITE_TAG); this->bird->setPosition(Point(origin.x + visiableSize.width / 2,origin.y + visiableSize.height*3/5 - 10)); this->bird->idle(); this->addChild(this->bird); // Add the land this->land1 = Sprite::createWithSpriteFrame(AtlasLoader::getInstance()->getSpriteFrameByName("land")); this->land1->setAnchorPoint(Point::ZERO); this->land1->setPosition(Point::ZERO); this->addChild(this->land1); this->land2 = Sprite::createWithSpriteFrame(AtlasLoader::getInstance()->getSpriteFrameByName("land")); this->land2->setAnchorPoint(Point::ZERO); this->land2->setPosition(this->land1->getContentSize().width - 2.0f, 0); this->addChild(this->land2); this->schedule(schedule_selector(WelcomeLayer::scrollLand), 0.01f); //add the copyright-text to the current scne Sprite *copyright = Sprite::createWithSpriteFrame(AtlasLoader::getInstance()->getSpriteFrameByName("brand_copyright")); copyright->setPosition(Point(origin.x + visiableSize.width/2, origin.y + visiableSize.height/6)); this->addChild(copyright, 10); return true; }
Point SystemDraw::GetOffset() const { return offset.GetCount() ? offset.Top() : Point(0, 0); }
void Minimap::Impl::updateImage() { int mapsize = tilemap->getSize(); fullmap->lock(); // here we can draw anything // std::cout << "center is (" << _mapArea->getCenterX() << "," << _mapArea->getCenterZ() << ")" << std::endl; int border = (162 - mapsize) / 2; int max = border + mapsize; for (int y = border; y < max; y++) { for (int x = border; x < max; x++) { const Tile& tile = tilemap->at(x - border, y - border); Point pnt = getBitmapCoordinates(x - border, y - border, mapsize); int c1, c2; getTerrainColours( tile, c1, c2); if( pnt.getX() >= fullmap->getWidth()-1 || pnt.getY() >= fullmap->getHeight() ) continue; fullmap->setPixel( pnt, c1); fullmap->setPixel( pnt + Point( 1, 0 ), c2); } } // show center of screen on minimap // Exit out of image size on small carts... please fix it /*sdlFacade.setPixel(surface, TilemapRenderer::instance().getMapArea().getCenterX(), mapsize * 2 - TilemapRenderer::instance().getMapArea().getCenterZ(), kWhite); sdlFacade.setPixel(surface, TilemapRenderer::instance().getMapArea().getCenterX() + 1, mapsize * 2 - TilemapRenderer::instance().getMapArea().getCenterZ(), kWhite); sdlFacade.setPixel(surface, TilemapRenderer::instance().getMapArea().getCenterX(), mapsize * 2 - TilemapRenderer::instance().getMapArea().getCenterZ() + 1, kWhite); sdlFacade.setPixel(surface, TilemapRenderer::instance().getMapArea().getCenterX() + 1, mapsize * 2 - TilemapRenderer::instance().getMapArea().getCenterZ() + 1, kWhite); for ( int i = TilemapRenderer::instance().getMapArea().getCenterX() - 18; i <= TilemapRenderer::instance().getMapArea().getCenterX() + 18; i++ ) { sdlFacade.setPixel(surface, i, mapsize * 2 - TilemapRenderer::instance().getMapArea().getCenterZ() + 34, kYellow); sdlFacade.setPixel(surface, i, mapsize * 2 - TilemapRenderer::instance().getMapArea().getCenterZ() - 34, kYellow); } for ( int j = mapsize * 2 - TilemapRenderer::instance().getMapArea().getCenterZ() - 34; j <= mapsize * 2 - TilemapRenderer::instance().getMapArea().getCenterZ() + 34; j++ ) { sdlFacade.setPixel(surface, TilemapRenderer::instance().getMapArea().getCenterX() - 18, j, kYellow); sdlFacade.setPixel(surface, TilemapRenderer::instance().getMapArea().getCenterX() + 18, j, kYellow); } */ fullmap->unlock(); // this is window where minimap is displayed int i = center.getX(); int j = center.getY(); minimap->fill( 0xff000000, Rect() ); minimap->draw( *fullmap, 146/2 - i, 112/2 + j - mapsize*2 ); }
Point getBitmapCoordinates(int x, int y, int mapsize ) { return Point( x + y, x + mapsize - y - 1 ); }
Point getQuadraturePoint(unsigned short i) const { assert(i < n_points); return Point(points[i]); }
// The actual implementation of building elements. void InfElemBuilder::build_inf_elem(const Point& origin, const bool x_sym, const bool y_sym, const bool z_sym, const bool be_verbose, std::set< std::pair<dof_id_type, unsigned int> >* inner_faces) { if (be_verbose) { #ifdef DEBUG libMesh::out << " Building Infinite Elements:" << std::endl; libMesh::out << " updating element neighbor tables..." << std::endl; #else libMesh::out << " Verbose mode disabled in non-debug mode." << std::endl; #endif } // update element neighbors this->_mesh.find_neighbors(); START_LOG("build_inf_elem()", "InfElemBuilder"); // A set for storing element number, side number pairs. // pair.first == element number, pair.second == side number std::set< std::pair<dof_id_type,unsigned int> > faces; std::set< std::pair<dof_id_type,unsigned int> > ofaces; // A set for storing node numbers on the outer faces. std::set<dof_id_type> onodes; // The distance to the farthest point in the mesh from the origin Real max_r=0.; // The index of the farthest point in the mesh from the origin int max_r_node = -1; #ifdef DEBUG if (be_verbose) { libMesh::out << " collecting boundary sides"; if (x_sym || y_sym || z_sym) libMesh::out << ", skipping sides in symmetry planes..." << std::endl; else libMesh::out << "..." << std::endl; } #endif // Iterate through all elements and sides, collect indices of all active // boundary sides in the faces set. Skip sides which lie in symmetry planes. // Later, sides of the inner boundary will be sorted out. { MeshBase::element_iterator it = this->_mesh.active_elements_begin(); const MeshBase::element_iterator end = this->_mesh.active_elements_end(); for(; it != end; ++it) { Elem* elem = *it; for (unsigned int s=0; s<elem->n_neighbors(); s++) { // check if elem(e) is on the boundary if (elem->neighbor(s) == NULL) { // note that it is safe to use the Elem::side() method, // which gives a non-full-ordered element AutoPtr<Elem> side(elem->build_side(s)); // bool flags for symmetry detection bool sym_side=false; bool on_x_sym=true; bool on_y_sym=true; bool on_z_sym=true; // Loop over the nodes to check whether they are on the symmetry planes, // and therefore sufficient to use a non-full-ordered side element for(unsigned int n=0; n<side->n_nodes(); n++) { const Point dist_from_origin = this->_mesh.point(side->node(n)) - origin; if(x_sym) if( std::abs(dist_from_origin(0)) > 1.e-3 ) on_x_sym=false; if(y_sym) if( std::abs(dist_from_origin(1)) > 1.e-3 ) on_y_sym=false; if(z_sym) if( std::abs(dist_from_origin(2)) > 1.e-3 ) on_z_sym=false; // if(x_sym) // if( std::abs(dist_from_origin(0)) > 1.e-6 ) // on_x_sym=false; // if(y_sym) // if( std::abs(dist_from_origin(1)) > 1.e-6 ) // on_y_sym=false; // if(z_sym) // if( std::abs(dist_from_origin(2)) > 1.e-6 ) // on_z_sym=false; //find the node most distant from origin Real r = dist_from_origin.size(); if (r > max_r) { max_r = r; max_r_node=side->node(n); } } sym_side = (x_sym && on_x_sym) || (y_sym && on_y_sym) || (z_sym && on_z_sym); if (!sym_side) faces.insert( std::make_pair(elem->id(), s) ); } // neighbor(s) == NULL } // sides } // elems } // If a boundary side has one node on the outer boundary, // all points of this side are on the outer boundary. // Start with the node most distant from origin, which has // to be on the outer boundary, then recursively find all // sides and nodes connected to it. Found sides are moved // from faces to ofaces, nodes are collected in onodes. // Here, the search is done iteratively, because, depending on // the mesh, a very high level of recursion might be necessary. if (max_r_node > 0) onodes.insert(max_r_node); { std::set< std::pair<dof_id_type,unsigned int> >::iterator face_it = faces.begin(); unsigned int facesfound=0; while (face_it != faces.end()) { std::pair<dof_id_type, unsigned int> p; p = *face_it; // This has to be a full-ordered side element, // since we need the correct n_nodes, AutoPtr<Elem> side(this->_mesh.elem(p.first)->build_side(p.second)); bool found=false; for(unsigned int sn=0; sn<side->n_nodes(); sn++) if(onodes.count(side->node(sn))) { found=true; break; } // If a new oface is found, include its nodes in onodes if(found) { for(unsigned int sn=0; sn<side->n_nodes(); sn++) onodes.insert(side->node(sn)); ofaces.insert(p); face_it++; // iteration is done here faces.erase(p); facesfound++; } else face_it++; // iteration is done here // If at least one new oface was found in this cycle, // do another search cycle. if(facesfound>0 && face_it == faces.end()) { facesfound = 0; face_it = faces.begin(); } } } #ifdef DEBUG if (be_verbose) libMesh::out << " found " << faces.size() << " inner and " << ofaces.size() << " outer boundary faces" << std::endl; #endif // When the user provided a non-null pointer to // inner_faces, that implies he wants to have // this std::set. For now, simply copy the data. if (inner_faces != NULL) *inner_faces = faces; // free memory, clear our local variable, no need // for it any more. faces.clear(); // outer_nodes maps onodes to their duplicates std::map<dof_id_type, Node *> outer_nodes; // We may need to pick our own object ids in parallel dof_id_type old_max_node_id = _mesh.max_node_id(); dof_id_type old_max_elem_id = _mesh.max_elem_id(); // for each boundary node, add an outer_node with // double distance from origin. std::set<dof_id_type>::iterator on_it = onodes.begin(); for( ; on_it != onodes.end(); ++on_it) { Point p = (Point(this->_mesh.point(*on_it)) * 2) - origin; if (_mesh.is_serial()) { // Add with a default id in serial outer_nodes[*on_it]=this->_mesh.add_point(p); } else { // Pick a unique id in parallel Node &bnode = _mesh.node(*on_it); dof_id_type new_id = bnode.id() + old_max_node_id; outer_nodes[*on_it] = this->_mesh.add_point(p, new_id, bnode.processor_id()); } } #ifdef DEBUG // for verbose, remember n_elem dof_id_type n_conventional_elem = this->_mesh.n_elem(); #endif // build Elems based on boundary side type std::set< std::pair<dof_id_type,unsigned int> >::iterator face_it = ofaces.begin(); for( ; face_it != ofaces.end(); ++face_it) { // Shortcut to the pair being iterated over std::pair<dof_id_type,unsigned int> p = *face_it; // build a full-ordered side element to get the base nodes AutoPtr<Elem> side(this->_mesh.elem(p.first)->build_side(p.second)); // create cell depending on side type, assign nodes, // use braces to force scope. bool is_higher_order_elem = false; { Elem* el; switch(side->type()) { // 3D infinite elements // TRIs case TRI3: el=new InfPrism6; break; case TRI6: el=new InfPrism12; is_higher_order_elem = true; break; // QUADs case QUAD4: el=new InfHex8; break; case QUAD8: el=new InfHex16; is_higher_order_elem = true; break; case QUAD9: el=new InfHex18; // the method of assigning nodes (which follows below) // omits in the case of QUAD9 the bubble node; therefore // we assign these first by hand here. el->set_node(16) = side->get_node(8); el->set_node(17) = outer_nodes[side->node(8)]; is_higher_order_elem=true; break; // 2D infinite elements case EDGE2: el=new InfQuad4; break; case EDGE3: el=new InfQuad6; el->set_node(4) = side->get_node(2); break; // 1D infinite elements not supported default: libMesh::out << "InfElemBuilder::build_inf_elem(Point, bool, bool, bool, bool): " << "invalid face element " << std::endl; continue; } // In parallel, assign unique ids to the new element if (!_mesh.is_serial()) { Elem *belem = _mesh.elem(p.first); el->processor_id() = belem->processor_id(); // We'd better not have elements with more than 6 sides el->set_id (belem->id() * 6 + p.second + old_max_elem_id); } // assign vertices to the new infinite element const unsigned int n_base_vertices = side->n_vertices(); for(unsigned int i=0; i<n_base_vertices; i++) { el->set_node(i ) = side->get_node(i); el->set_node(i+n_base_vertices) = outer_nodes[side->node(i)]; } // when this is a higher order element, // assign also the nodes in between if (is_higher_order_elem) { // n_safe_base_nodes is the number of nodes in \p side // that may be safely assigned using below for loop. // Actually, n_safe_base_nodes is _identical_ with el->n_vertices(), // since for QUAD9, the 9th node was already assigned above const unsigned int n_safe_base_nodes = el->n_vertices(); for(unsigned int i=n_base_vertices; i<n_safe_base_nodes; i++) { el->set_node(i+n_base_vertices) = side->get_node(i); el->set_node(i+n_safe_base_nodes) = outer_nodes[side->node(i)]; } } // add infinite element to mesh this->_mesh.add_elem(el); } // el goes out of scope } // for #ifdef DEBUG _mesh.libmesh_assert_valid_parallel_ids(); if (be_verbose) libMesh::out << " added " << this->_mesh.n_elem() - n_conventional_elem << " infinite elements and " << onodes.size() << " nodes to the mesh" << std::endl << std::endl; #endif STOP_LOG("build_inf_elem()", "InfElemBuilder"); }
bool TLDDetector::ocl_detect(const Mat& img, const Mat& imgBlurred, Rect2d& res, std::vector<LabeledPatch>& patches, Size initSize) { patches.clear(); Mat_<uchar> standardPatch(STANDARD_PATCH_SIZE, STANDARD_PATCH_SIZE); Mat tmp; int dx = initSize.width / 10, dy = initSize.height / 10; Size2d size = img.size(); double scale = 1.0; int npos = 0, nneg = 0; double maxSc = -5.0; Rect2d maxScRect; int scaleID; std::vector <Mat> resized_imgs, blurred_imgs; std::vector <Point> varBuffer, ensBuffer; std::vector <int> varScaleIDs, ensScaleIDs; //Detection part //Generate windows and filter by variance scaleID = 0; resized_imgs.push_back(img); blurred_imgs.push_back(imgBlurred); do { Mat_<double> intImgP, intImgP2; computeIntegralImages(resized_imgs[scaleID], intImgP, intImgP2); for (int i = 0, imax = cvFloor((0.0 + resized_imgs[scaleID].cols - initSize.width) / dx); i < imax; i++) { for (int j = 0, jmax = cvFloor((0.0 + resized_imgs[scaleID].rows - initSize.height) / dy); j < jmax; j++) { if (!patchVariance(intImgP, intImgP2, originalVariancePtr, Point(dx * i, dy * j), initSize)) continue; varBuffer.push_back(Point(dx * i, dy * j)); varScaleIDs.push_back(scaleID); } } scaleID++; size.width /= SCALE_STEP; size.height /= SCALE_STEP; scale *= SCALE_STEP; resize(img, tmp, size, 0, 0, DOWNSCALE_MODE); resized_imgs.push_back(tmp); GaussianBlur(resized_imgs[scaleID], tmp, GaussBlurKernelSize, 0.0f); blurred_imgs.push_back(tmp); } while (size.width >= initSize.width && size.height >= initSize.height); //Encsemble classification for (int i = 0; i < (int)varBuffer.size(); i++) { prepareClassifiers((int)blurred_imgs[varScaleIDs[i]].step[0]); if (ensembleClassifierNum(&blurred_imgs[varScaleIDs[i]].at<uchar>(varBuffer[i].y, varBuffer[i].x)) <= ENSEMBLE_THRESHOLD) continue; ensBuffer.push_back(varBuffer[i]); ensScaleIDs.push_back(varScaleIDs[i]); } //NN classification //Prepare batch of patches int numOfPatches = (int)ensBuffer.size(); Mat_<uchar> stdPatches(numOfPatches, 225); double *resultSr = new double[numOfPatches]; double *resultSc = new double[numOfPatches]; uchar *patchesData = stdPatches.data; for (int i = 0; i < (int)ensBuffer.size(); i++) { resample(resized_imgs[ensScaleIDs[i]], Rect2d(ensBuffer[i], initSize), standardPatch); uchar *stdPatchData = standardPatch.data; for (int j = 0; j < 225; j++) patchesData[225*i+j] = stdPatchData[j]; } //Calculate Sr and Sc batches ocl_batchSrSc(stdPatches, resultSr, resultSc, numOfPatches); for (int i = 0; i < (int)ensBuffer.size(); i++) { LabeledPatch labPatch; standardPatch.data = &stdPatches.data[225 * i]; double curScale = pow(SCALE_STEP, ensScaleIDs[i]); labPatch.rect = Rect2d(ensBuffer[i].x*curScale, ensBuffer[i].y*curScale, initSize.width * curScale, initSize.height * curScale); double srValue, scValue; srValue = resultSr[i]; ////To fix: Check the paper, probably this cause wrong learning // labPatch.isObject = srValue > THETA_NN; labPatch.shouldBeIntegrated = abs(srValue - THETA_NN) < 0.1; patches.push_back(labPatch); // if (!labPatch.isObject) { nneg++; continue; } else { npos++; } scValue = resultSc[i]; if (scValue > maxSc) { maxSc = scValue; maxScRect = labPatch.rect; } } if (maxSc < 0) return false; res = maxScRect; return true; }
bool HandSplitterNew::compute(ForegroundExtractorNew& foreground_extractor, MotionProcessorNew& motion_processor, string name, bool visualize) { if (value_store.get_bool("first_pass", false) == false) { value_store.set_bool("first_pass", true); algo_name += name; } bool algo_name_found = false; for (String& algo_name_current : algo_name_vec_old) if (algo_name_current == algo_name) { algo_name_found = true; break; } LowPassFilter* low_pass_filter = value_store.get_low_pass_filter("low_pass_filter"); //------------------------------------------------------------------------------------------------------------------------ Mat image_find_contours = Mat::zeros(HEIGHT_SMALL, WIDTH_SMALL, CV_8UC1); for (BlobNew& blob : *foreground_extractor.blob_detector.blobs) if (blob.active) blob.fill(image_find_contours, 254); vector<vector<Point>> contours = legacyFindContours(image_find_contours); if (contours.size() == 0) return false; int complexity = 0; for (vector<Point>& contour : contours) { vector<Point> contour_approximated; approxPolyDP(Mat(contour), contour_approximated, 10, false); complexity += contour_approximated.size(); } //------------------------------------------------------------------------------------------------------------------------ int x_min = foreground_extractor.x_min_result; int x_max = foreground_extractor.x_max_result; int y_min = foreground_extractor.y_min_result; int y_max = foreground_extractor.y_max_result; float x_seed_vec0_max = value_store.get_float("x_seed_vec0_max"); float x_seed_vec1_min = value_store.get_float("x_seed_vec1_min"); int intensity_array[WIDTH_SMALL] { 0 }; for (BlobNew& blob : *foreground_extractor.blob_detector.blobs) if (blob.active) for (Point& pt : blob.data) ++intensity_array[pt.x]; vector<Point> hist_pt_vec; for (int i = 0; i < WIDTH_SMALL; ++i) { int j = intensity_array[i]; low_pass_filter->compute(j, 0.5, "histogram_j"); if (j < 10) continue; for (int j_current = 0; j_current < j; ++j_current) hist_pt_vec.push_back(Point(i, j_current)); } Point seed0 = Point(x_min, 0); Point seed1 = Point(x_max, 0); vector<Point> seed_vec0; vector<Point> seed_vec1; while (true) { seed_vec0.clear(); seed_vec1.clear(); for (Point& pt : hist_pt_vec) { float dist0 = get_distance(pt, seed0, false); float dist1 = get_distance(pt, seed1, false); if (dist0 < dist1) seed_vec0.push_back(pt); else seed_vec1.push_back(pt); } if (seed_vec0.size() == 0 || seed_vec1.size() == 0) break; Point seed0_new = Point(0, 0); for (Point& pt : seed_vec0) { seed0_new.x += pt.x; seed0_new.y += pt.y; } seed0_new.x /= seed_vec0.size(); seed0_new.y /= seed_vec0.size(); Point seed1_new = Point(0, 0); for (Point& pt : seed_vec1) { seed1_new.x += pt.x; seed1_new.y += pt.y; } seed1_new.x /= seed_vec1.size(); seed1_new.y /= seed_vec1.size(); if (seed0 == seed0_new && seed1 == seed1_new) break; seed0 = seed0_new; seed1 = seed1_new; } bool dual = false; if (seed_vec0.size() > 0 && seed_vec1.size() > 0) { x_seed_vec0_max = seed_vec0[seed_vec0.size() - 1].x; x_seed_vec1_min = seed_vec1[0].x; low_pass_filter->compute_if_smaller(x_seed_vec0_max, 0.5, "x_seed_vec0_max"); low_pass_filter->compute_if_larger(x_seed_vec1_min, 0.5, "x_seed_vec1_min"); value_store.set_float("x_seed_vec0_max", x_seed_vec0_max); value_store.set_float("x_seed_vec1_min", x_seed_vec1_min); value_store.set_bool("x_min_max_set", true); //------------------------------------------------------------------------------------------------------------------------ int width0 = x_seed_vec0_max - x_min; int width1 = x_max - x_seed_vec1_min; int width_min = min(width0, width1); float gap_size = x_seed_vec1_min - x_seed_vec0_max; low_pass_filter->compute_if_larger(gap_size, 0.1, "gap_size"); //------------------------------------------------------------------------------------------------------------------------ bool bool_complexity = complexity >= 15; bool bool_width_min = width_min >= 20; bool bool_gap_size = gap_size >= 5; bool bool_gap_order = x_seed_vec0_max < x_seed_vec1_min; dual = bool_gap_order && bool_width_min && (bool_gap_size || bool_complexity); } //------------------------------------------------------------------------------------------------------------------------ BlobNew* blob_max_size_left = NULL; BlobNew* blob_max_size_right = NULL; BlobNew* blob_max_size = NULL; for (BlobNew& blob : *foreground_extractor.blob_detector.blobs) { if (blob.x <= motion_processor.x_separator_middle && (blob_max_size_left == NULL || blob.count > blob_max_size_left->count)) blob_max_size_left = &blob; else if (blob.x > motion_processor.x_separator_middle && (blob_max_size_right == NULL || blob.count > blob_max_size_right->count)) blob_max_size_right = &blob; if (blob_max_size == NULL || blob.count > blob_max_size->count) blob_max_size = &blob; } //------------------------------------------------------------------------------------------------------------------------ int count_left = 0; int count_right = 0; int x_min_left = 9999; int x_max_left = 0; int x_min_right = 9999; int x_max_right = 0; for (BlobNew& blob : *foreground_extractor.blob_detector.blobs) if (blob.active) { for (Point& pt : blob.data) if (pt.x < motion_processor.x_separator_middle) { ++count_left; if (pt.x < x_min_left) x_min_left = pt.x; if (pt.x > x_max_left) x_max_left = pt.x; } else { ++count_right; if (pt.x < x_min_right) x_min_right = pt.x; if (pt.x > x_max_right) x_max_right = pt.x; } } int width_left = x_max_left - x_min_left; int width_right = x_max_right - x_min_right; //------------------------------------------------------------------------------------------------------------------------ bool reference_is_left = value_store.get_bool("reference_is_left", false); bool dual_old = value_store.get_bool("dual_old", dual); bool merge = value_store.get_bool("merge", false); if (!dual && dual_old) { float count_small = reference_is_left ? count_right : count_left; float count_large = reference_is_left ? count_left : count_right; if (count_small / count_large > 0.5) { merge = true; value_store.set_bool("merge", merge); } } dual_old = dual; value_store.set_bool("dual_old", dual_old); //------------------------------------------------------------------------------------------------------------------------ int reference_x_offset = value_store.get_int("reference_x_offset", 0); int reference_x_offset_blob = value_store.get_int("reference_x_offset_blob", 0); bool do_reset = value_store.get_bool("do_reset", false); if (dual || !algo_name_found || do_reset) { if (dual) { motion_processor.compute_x_separator_middle = false; set_value(&motion_processor.x_separator_middle, (x_seed_vec1_min + x_seed_vec0_max) / 2, 0, WIDTH_SMALL_MINUS); } reference_is_left = count_left > count_right; value_store.set_bool("reference_is_left", reference_is_left); if (!algo_name_found || do_reset) set_value(&motion_processor.x_separator_middle, motion_processor.x_separator_middle_median, 0, WIDTH_SMALL_MINUS); int reference_x = reference_is_left ? foreground_extractor.x_min_result : foreground_extractor.x_max_result; reference_x_offset = reference_x - motion_processor.x_separator_middle; value_store.set_int("reference_x_offset", reference_x_offset); int reference_x_blob = -1; if (reference_is_left && blob_max_size_left != NULL) reference_x_blob = blob_max_size_left->x_max; else if (!reference_is_left && blob_max_size_right != NULL) reference_x_blob = blob_max_size_right->x_min; if (reference_x_blob != -1) { reference_x_offset_blob = reference_x_blob - motion_processor.x_separator_middle; value_store.set_int("reference_x_offset_blob", reference_x_offset_blob); } merge = false; value_store.set_bool("merge", merge); do_reset = false; value_store.set_bool("do_reset", do_reset); } //------------------------------------------------------------------------------------------------------------------------ if (!dual && !merge) { int reference_x = reference_is_left ? foreground_extractor.x_min_result : foreground_extractor.x_max_result; int reference_x_blob = reference_is_left ? blob_max_size->x_max : blob_max_size->x_min; const int x_separator_middle_target = reference_x_blob - reference_x_offset_blob; const int x_separator_middle = motion_processor.x_separator_middle; const int i_increment = x_separator_middle_target > motion_processor.x_separator_middle ? 1 : -1; int cost = 0; for (int i = x_separator_middle; i != x_separator_middle_target; i += i_increment) for (int j = 0; j < HEIGHT_SMALL; ++j) if (foreground_extractor.image_foreground.ptr<uchar>(j, i)[0] > 0) ++cost; if ((float)cost / blob_max_size->count < 0.5) set_value(&motion_processor.x_separator_middle, x_separator_middle_target, 0, WIDTH_SMALL_MINUS); else { do_reset = true; value_store.set_bool("do_reset", do_reset); } } //------------------------------------------------------------------------------------------------------------------------ Point seed_left = value_store.get_point("seed_left", Point(x_min, 0)); Point seed_right = value_store.get_point("seed_right", Point(x_max, 0)); if (merge || dual) { seed_left = Point(0, 0); int seed_left_count = 0; for (BlobNew& blob : blobs_left) for (Point& pt : blob.data) { seed_left.x += pt.x; seed_left.y += pt.y; ++seed_left_count; } seed_right = Point(0, 0); int seed_right_count = 0; for (BlobNew& blob : blobs_right) for (Point& pt : blob.data) { seed_right.x += pt.x; seed_right.y += pt.y; ++seed_right_count; } if (seed_left_count > 0 && seed_right_count > 0) { seed_left.x /= seed_left_count; seed_left.y /= seed_left_count; seed_right.x /= seed_right_count; seed_right.y /= seed_right_count; vector<Point> seed_left_vec; vector<Point> seed_right_vec; while (true) { seed_left_vec.clear(); seed_right_vec.clear(); for (BlobNew& blob : *foreground_extractor.blob_detector.blobs) if (blob.active) for (Point& pt : blob.data) { float dist_left = get_distance(pt, seed_left, false); float dist_right = get_distance(pt, seed_right, false); if (dist_left < dist_right) seed_left_vec.push_back(pt); else seed_right_vec.push_back(pt); } if (seed_left_vec.size() > 0 && seed_right_vec.size() > 0) { Point seed_left_new = Point(0, 0); for (Point& pt : seed_left_vec) { seed_left_new.x += pt.x; seed_left_new.y += pt.y; } seed_left_new.x /= seed_left_vec.size(); seed_left_new.y /= seed_left_vec.size(); Point seed_right_new = Point(0, 0); for (Point& pt : seed_right_vec) { seed_right_new.x += pt.x; seed_right_new.y += pt.y; } seed_right_new.x /= seed_right_vec.size(); seed_right_new.y /= seed_right_vec.size(); if (seed_left.x == seed_left_new.x && seed_left.y == seed_left_new.y && seed_right.x == seed_right_new.x && seed_right.y == seed_right_new.y) { break; } seed_left = seed_left_new; seed_right = seed_right_new; } else break; } if (merge) set_value(&motion_processor.x_separator_middle, (seed_left.x + seed_right.x) / 2, 0, WIDTH_SMALL_MINUS); } } value_store.set_point("seed_left", seed_left); value_store.set_point("seed_right", seed_right); //------------------------------------------------------------------------------------------------------------------------ const int x_separator_middle = motion_processor.x_separator_middle; const int x_separator_middle_median = motion_processor.x_separator_middle_median; const int x_separator_left_median = motion_processor.x_separator_left_median; const int x_separator_right_median = motion_processor.x_separator_right_median; const int y_separator_down_median = motion_processor.y_separator_down_median; const int y_separator_up_median = motion_processor.y_separator_up_median; while (dual) { const int i_min = seed_left.x; const int i_max = seed_right.x; const int j_min = 0; const int j_max = y_separator_up_median; if (!(i_max > i_min && i_min >= 0 && i_max <= WIDTH_SMALL_MINUS)) break; Point pt0 = Point(i_min, 0); Point pt1 = Point(i_max, 0); Point pt2 = Point(x_separator_middle, j_max); //tip point if (pt2.y < 2 || i_max - i_min < 2) break; Mat image_triangle_fill = Mat::zeros(j_max + 1, WIDTH_SMALL, CV_8UC1); line(image_triangle_fill, pt0, pt2, Scalar(254), 1); line(image_triangle_fill, pt1, pt2, Scalar(254), 1); floodFill(image_triangle_fill, Point(x_separator_middle, 0), Scalar(254)); for (int i = i_min; i <= i_max; ++i) for (int j = j_min; j <= j_max; ++j) if (image_triangle_fill.ptr<uchar>(j, i)[0] > 0) motion_processor.fill_image_background_static(i, j, motion_processor.image_ptr); break; } //------------------------------------------------------------------------------------------------------------------------ x_min_result_right = 9999; x_max_result_right = -1; y_min_result_right = 9999; y_max_result_right = -1; x_min_result_left = 9999; x_max_result_left = -1; y_min_result_left = 9999; y_max_result_left = -1; blobs_right.clear(); blobs_left.clear(); for (BlobNew& blob : *foreground_extractor.blob_detector.blobs) if (blob.active) { if (blob.x > motion_processor.x_separator_middle) { if (blob.x_min < x_min_result_right) x_min_result_right = blob.x_min; if (blob.x_max > x_max_result_right) x_max_result_right = blob.x_max; if (blob.y_min < y_min_result_right) y_min_result_right = blob.y_min; if (blob.y_max > y_max_result_right) y_max_result_right = blob.y_max; blobs_right.push_back(blob); } else { if (blob.x_min < x_min_result_left) x_min_result_left = blob.x_min; if (blob.x_max > x_max_result_left) x_max_result_left = blob.x_max; if (blob.y_min < y_min_result_left) y_min_result_left = blob.y_min; if (blob.y_max > y_max_result_left) y_max_result_left = blob.y_max; blobs_left.push_back(blob); } } //------------------------------------------------------------------------------------------------------------------------ if (visualize) { Mat image_visualization = Mat::zeros(HEIGHT_SMALL, WIDTH_SMALL, CV_8UC1); for (BlobNew& blob : *foreground_extractor.blob_detector.blobs) if (blob.active) blob.fill(image_visualization, 254); line(image_visualization, Point(x_separator_left_median, 0), Point(x_separator_left_median, 999), Scalar(254), 1); line(image_visualization, Point(x_separator_right_median, 0), Point(x_separator_right_median, 999), Scalar(254), 1); line(image_visualization, Point(x_separator_middle, 0), Point(x_separator_middle, 999), Scalar(254), 1); line(image_visualization, Point(0, y_separator_down_median), Point(999, y_separator_down_median), Scalar(254), 1); line(image_visualization, Point(0, y_separator_up_median), Point(999, y_separator_up_median), Scalar(254), 1); imshow("image_visualizationsdlkfjhasdf" + name, image_visualization); } if (blobs_right.size() > 0 || blobs_left.size() > 0) { algo_name_vec.push_back(algo_name); return true; } return false; }
/** Add a point, specified by its position and normal, to the point cloud. */ void addPoint(Vector3 const & p, Vector3 const & n) { points.push_back(Point(p, n)); bbox.merge(p); }
Point offset() const { return Point(m_page_offset_x, m_page_offset_y); }
Point Point::operator - () const // Negate coordinates { return Point (-m_x,-m_y); }
void FlipX3D::update(float time) { float angle = (float)M_PI * time; // 180 degrees float mz = sinf(angle); angle = angle / 2.0f; // x calculates degrees from 0 to 90 float mx = cosf(angle); Vertex3F v0, v1, v, diff; v0 = getOriginalVertex(Point(1, 1)); v1 = getOriginalVertex(Point(0, 0)); float x0 = v0.x; float x1 = v1.x; float x; Point a, b, c, d; if ( x0 > x1 ) { // Normal Grid a = Point(0,0); b = Point(0,1); c = Point(1,0); d = Point(1,1); x = x0; } else { // Reversed Grid c = Point(0,0); d = Point(0,1); a = Point(1,0); b = Point(1,1); x = x1; } diff.x = ( x - x * mx ); diff.z = fabsf( floorf( (x * mz) / 4.0f ) ); // bottom-left v = getOriginalVertex(a); v.x = diff.x; v.z += diff.z; setVertex(a, v); // upper-left v = getOriginalVertex(b); v.x = diff.x; v.z += diff.z; setVertex(b, v); // bottom-right v = getOriginalVertex(c); v.x -= diff.x; v.z -= diff.z; setVertex(c, v); // upper-right v = getOriginalVertex(d); v.x -= diff.x; v.z -= diff.z; setVertex(d, v); }
Point Point::operator * (double factor) const //scale coordinates by a factor { return Point (m_x*factor, m_y*factor); }
//////////////////////////////////////////////////////// // // ParticleMainScene // //////////////////////////////////////////////////////// void ParticleMainScene::initWithSubTest(int asubtest, int particles) { //srandom(0); subtestNumber = asubtest; Size s = Director::getInstance()->getWinSize(); lastRenderedCount = 0; quantityParticles = particles; MenuItemFont::setFontSize(65); MenuItemFont *decrease = MenuItemFont::create(" - ", [&](Object *sender) { quantityParticles -= kNodesIncrease; if( quantityParticles < 0 ) quantityParticles = 0; updateQuantityLabel(); createParticleSystem(); }); decrease->setColor(Color3B(0,200,20)); MenuItemFont *increase = MenuItemFont::create(" + ", [&](Object *sender) { quantityParticles += kNodesIncrease; if( quantityParticles > kMaxParticles ) quantityParticles = kMaxParticles; updateQuantityLabel(); createParticleSystem(); }); increase->setColor(Color3B(0,200,20)); Menu *menu = Menu::create(decrease, increase, NULL); menu->alignItemsHorizontally(); menu->setPosition(Point(s.width/2, s.height/2+15)); addChild(menu, 1); LabelTTF *infoLabel = LabelTTF::create("0 nodes", "Marker Felt", 30); infoLabel->setColor(Color3B(0,200,20)); infoLabel->setPosition(Point(s.width/2, s.height - 90)); addChild(infoLabel, 1, kTagInfoLayer); // particles on stage LabelAtlas *labelAtlas = LabelAtlas::create("0000", "fps_images.png", 12, 32, '.'); addChild(labelAtlas, 0, kTagLabelAtlas); labelAtlas->setPosition(Point(s.width-66,50)); // Next Prev Test ParticleMenuLayer* menuLayer = new ParticleMenuLayer(true, TEST_COUNT, s_nParCurIdx); addChild(menuLayer, 1, kTagMenuLayer); menuLayer->release(); // Sub Tests MenuItemFont::setFontSize(40); Menu* pSubMenu = Menu::create(); for (int i = 1; i <= 6; ++i) { char str[10] = {0}; sprintf(str, "%d ", i); MenuItemFont* itemFont = MenuItemFont::create(str, CC_CALLBACK_1(ParticleMainScene::testNCallback, this)); itemFont->setTag(i); pSubMenu->addChild(itemFont, 10); if (i <= 3) { itemFont->setColor(Color3B(200,20,20)); } else { itemFont->setColor(Color3B(0,200,20)); } } pSubMenu->alignItemsHorizontally(); pSubMenu->setPosition(Point(s.width/2, 80)); addChild(pSubMenu, 2); LabelTTF *label = LabelTTF::create(title().c_str(), "Arial", 40); addChild(label, 1); label->setPosition(Point(s.width/2, s.height-32)); label->setColor(Color3B(255,255,40)); updateQuantityLabel(); createParticleSystem(); schedule(schedule_selector(ParticleMainScene::step)); }
Point Point:: operator + (const Point& P) const//add coordinates { return Point(m_x+P.m_x,m_y+P.m_y); }
BoundingBox Sphere::getBoundingBox() const { return BoundingBox(Point(center - Point(1, 1, 1) * radius), Point(center + Point(1, 1, 1) * radius)); }
BBox Disk::ObjectBound() const { return BBox(Point(-radius, -radius, height), Point( radius, radius, height)); }
void BBHandleLayer::showTips(Object* obj) { if (!m_isReady) { return; } if (m_showTips) { return; } Object *spt = NULL; int i = 0; CCARRAY_FOREACH(m_blockArr, spt) { auto blockSpt = (BBBlockSprite*)spt; int order = blockSpt->getOrder(); int c = order % m_col; int r = floor(order / m_col) + 1; if (c == 0){ c = m_col; r = r - 1; } float blockX = m_relativeX + m_blockLength * (c - 1) + blockSpt->getContentSize().width/2; float blockY = m_relativeY +m_blockLength * (r - 1) + blockSpt->getContentSize().height/2; blockSpt->runAction(Sequence::createWithTwoActions(DelayTime::create(0.03 * i), JumpTo::create(0.3f, Point(blockX, blockY), 30, 1))); i++; }
Point TabbedStackPresentation::ComputeMinimumSize() { QSize point = folder->GetTabFolder()->ComputeSize(Constants::DEFAULT, Constants::DEFAULT); return Point(point.width(), point.height()); }