当前位置: 首页>>代码示例>>C++>>正文


C++ Marker::set方法代码示例

本文整理汇总了C++中Marker::set方法的典型用法代码示例。如果您正苦于以下问题:C++ Marker::set方法的具体用法?C++ Marker::set怎么用?C++ Marker::set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Marker的用法示例。


在下文中一共展示了Marker::set方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: findRobotsByModel

void TeamDetector::findRobotsByModel(::google::protobuf::RepeatedPtrField< ::SSL_DetectionRobot >* robots, int team_color_id, const Image<raw8> * image, CMVision::ColorRegionList * colorlist, CMVision::RegionTree & reg_tree)
{

    (void)image;
    const int MaxDetections = _other_markers_max_detections;
    Marker cen; // center marker
    Marker markers[MaxDetections];
    const float marker_max_query_dist = _other_markers_max_query_distance;
    const float marker_max_dist = _pattern_max_dist;

    // partially forget old detections
    //decaySeen();

    filter_team.init( colorlist->getRegionList(team_color_id).getInitialElement());
    const CMVision::Region * reg=0;
    SSL_DetectionRobot * robot=0;

    MultiPatternModel::PatternDetectionResult res;
    // printf("finding robots...\n");
    while((reg = filter_team.getNext()) != 0) {
        vector2d reg_img_center(reg->cen_x,reg->cen_y);
        vector3d reg_center3d;
        _camera_params.image2field(reg_center3d,reg_img_center,_robot_height);
        vector2d reg_center(reg_center3d.x,reg_center3d.y);
        //TODO add masking:
        //if(det.mask.get(reg->cen_x,reg->cen_y) >= 0.5){
        // printf("if in field:\n");
        if (field_filter.isInFieldOrPlayableBoundary(reg_center)) {
            cen.set(reg,reg_center3d,getRegionArea(reg,_robot_height));
            int num_markers = 0;

            reg_tree.startQuery(*reg,marker_max_query_dist);
            double sd=0.0;
            CMVision::Region *mreg;
            while((mreg=reg_tree.getNextNearest(sd))!=0 && num_markers<MaxDetections) {
                //TODO: implement masking:
                // filter_other.check(*mreg) && det.mask.get(mreg->cen_x,mreg->cen_y)>=0.5

                if(filter_others.check(*mreg) && model.usesColor(mreg->color)) {
                    vector2d marker_img_center(mreg->cen_x,mreg->cen_y);
                    vector3d marker_center3d;
                    _camera_params.image2field(marker_center3d,marker_img_center,_robot_height);
                    Marker &m = markers[num_markers];

                    m.set(mreg,marker_center3d,getRegionArea(mreg,_robot_height));
                    vector2f ofs = m.loc - cen.loc;
                    m.dist = ofs.length();
                    m.angle = ofs.angle();

                    if(m.dist>0.0 && m.dist<marker_max_dist) {
                        num_markers++;
                    }
                }
            }
            reg_tree.endQuery();
            // printf("num markers = %d\n", num_markers);
            if(num_markers >= 2) {
                CMPattern::PatternProcessing::sortMarkersByAngle(markers,num_markers);
                for(int i=0; i<num_markers; i++) {
                    // DEBUG CODE:
                    // char colorchar='?';
                    // if (markers[i].id==color_id_green) colorchar='g';
                    // if (markers[i].id==color_id_pink) colorchar='p';
                    // if (markers[i].id==color_id_white) colorchar='w';
                    // if (markers[i].id==color_id_team) colorchar='t';
                    // if (markers[i].id==color_id_field_green) colorchar='f';
                    // if (markers[i].id==color_id_cyan) colorchar='c';
                    // printf("%c ",colorchar);
                    int j = (i + 1) % num_markers;
                    markers[i].next_dist = dist(markers[i].loc,markers[j].loc);
                    markers[i].next_angle_dist = angle_pos(angle_diff(markers[i].angle,markers[j].angle));
                }

                if (model.findPattern(res,markers,num_markers,_pattern_fit_params,_camera_params)) {
                    robot=addRobot(robots,res.conf,_max_robots*2);
                    if (robot!=0) {
                        //setup robot:
                        robot->set_x(cen.loc.x);
                        robot->set_y(cen.loc.y);
                        if (_have_angle) robot->set_orientation(res.angle);
                        robot->set_robot_id(res.id);
                        robot->set_pixel_x(reg->cen_x);
                        robot->set_pixel_y(reg->cen_y);
                        robot->set_height(cen.height);
                    }
                }
            }
        }
    }
    //remove items with 0-confidence:
    stripRobots(robots);

    //remove extra items:
    while(robots->size() > _max_robots) {
        robots->RemoveLast();
    }

}
开发者ID:KRSSG,项目名称:ssl-vision,代码行数:98,代码来源:cmpattern_teamdetector.cpp


注:本文中的Marker::set方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。