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


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

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


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

示例1: DetectAdditional

	int MarkerDetectorImpl::DetectAdditional(IplImage *image, Camera *cam, bool visualize, double max_track_error)
	{
		assert(image->origin == 0); // Currently only top-left origin supported
		if(!labeling) return -1;
		double error=-1;
		int orientation;
		int count=0;
		vector<vector<PointDouble> >& blob_corners = labeling->blob_corners;

		for (size_t ii=0; ii<_track_markers_size(); ii++) {
			Marker *mn = _track_markers_at(ii);
			if (mn->GetError(Marker::DECODE_ERROR|Marker::MARGIN_ERROR) > 0) continue; // We track only perfectly decoded markers
			int track_i=-1;
			int track_orientation=0;
			double track_error=1e200;
			for(unsigned i = 0; i < blob_corners.size(); ++i) {
				if (blob_corners[i].empty()) continue;
				mn->CompareCorners(blob_corners[i], &orientation, &error);
				if (error < track_error) {
					track_i = i;
					track_orientation = orientation;
					track_error = error;
				}
			}
			if (track_error <= max_track_error) {
				mn->SetError(Marker::DECODE_ERROR, 0);
				mn->SetError(Marker::MARGIN_ERROR, 0);
				mn->SetError(Marker::TRACK_ERROR, track_error);
				mn->UpdatePose(blob_corners[track_i], cam, track_orientation);
				_markers_push_back(mn);
				count++;
				blob_corners[track_i].clear(); // We don't want to handle this again...

				if (visualize) {
					mn->Visualize(image, cam, CV_RGB(0,255,255));
				}
			}
		}
		return count;
	}
开发者ID:Bewolf2,项目名称:alvar,代码行数:40,代码来源:MarkerDetector.cpp

示例2: Detect

	int MarkerDetectorImpl::Detect(IplImage *image,
			   Camera *cam,
			   bool track,
			   bool visualize,
			   double max_new_marker_error,
			   double max_track_error,
			   LabelingMethod labeling_method,
			   bool update_pose)
	{
		assert(image->origin == 0); // Currently only top-left origin supported
		double error=-1;

		// Swap marker tables
		_swap_marker_tables();
		_markers_clear();

		switch(labeling_method)
		{
			case CVSEQ :
		
				if(!labeling)
					labeling = new LabelingCvSeq();
				((LabelingCvSeq*)labeling)->SetOptions(detect_pose_grayscale);
				break;
		}

		labeling->SetCamera(cam);
		labeling->LabelSquares(image, visualize);
		vector<vector<PointDouble> >& blob_corners = labeling->blob_corners;
		IplImage* gray = labeling->gray;

		int orientation;

		// When tracking we find the best matching blob and test if it is near enough?
		if (track) {
			for (size_t ii=0; ii<_track_markers_size(); ii++) {
				Marker *mn = _track_markers_at(ii);
				if (mn->GetError(Marker::DECODE_ERROR|Marker::MARGIN_ERROR) > 0) continue; // We track only perfectly decoded markers
				int track_i=-1;
				int track_orientation=0;
				double track_error=1e200;
				for(unsigned i = 0; i < blob_corners.size()/*blobs_ret.size()*/; ++i) {
					if (blob_corners[i].empty()) continue;
					mn->CompareCorners(blob_corners[i], &orientation, &error);
					if (error < track_error) {
						track_i = i;
						track_orientation = orientation;
						track_error = error;
					}
				}
				if (track_error <= max_track_error) {
					mn->SetError(Marker::DECODE_ERROR, 0);
					mn->SetError(Marker::MARGIN_ERROR, 0);
					mn->SetError(Marker::TRACK_ERROR, track_error);
					mn->UpdatePose(blob_corners[track_i], cam, track_orientation, update_pose);
					_markers_push_back(mn);
					blob_corners[track_i].clear(); // We don't want to handle this again...
					if (visualize) mn->Visualize(image, cam, CV_RGB(255,255,0));
				}
			}
		}

		// Now we go through the rest of the blobs -- in case there are new markers...
		for(size_t i = 0; i < blob_corners.size(); ++i)
		{
			if (blob_corners[i].empty()) continue;

			Marker *mn = new_M(edge_length, res, margin);
			if (mn->UpdateContent(blob_corners[i], gray, cam) &&
			    mn->DecodeContent(&orientation) &&
				(mn->GetError(Marker::MARGIN_ERROR | Marker::DECODE_ERROR) <= max_new_marker_error))
			{
				if (map_edge_length.find(mn->GetId()) != map_edge_length.end()) {
					mn->SetMarkerSize(map_edge_length[mn->GetId()], res, margin);
				}
				mn->UpdatePose(blob_corners[i], cam, orientation, update_pose);
				_markers_push_back(mn);
 
				if (visualize) mn->Visualize(image, cam, CV_RGB(255,0,0));
			}
			delete mn;
		}

		return (int) _markers_size();
	}
开发者ID:Bewolf2,项目名称:alvar,代码行数:85,代码来源:MarkerDetector.cpp

示例3: videocallback

void videocallback(IplImage *image)
{
    static Camera cam;
    Pose pose;
    bool flip_image = (image->origin?true:false);
    if (flip_image) {
        cvFlip(image);
        image->origin = !image->origin;
    }

    static bool init = true;
    if (init)
    {

        init = false;

        // Initialize camera
        cout<<"Loading calibration: "<<calibrationFilename.str();

        if (cam.SetCalib(calibrationFilename.str().c_str(), image->width, image->height))
        {
            cout<<" [Ok]"<<endl;
        }
        else
        {
            cam.SetRes(image->width, image->height);
            cout<<" [Fail]"<<endl;
        }

        vector<int> id_vector;
        for(int i = 0; i < nof_markers; ++i)
            id_vector.push_back(i);

        // We make the initialization for MultiMarkerBundle using a fixed marker field (can be printed from ALVAR.pdf)
        marker_detector.SetMarkerSize(marker_size);
        marker_detector.SetMarkerSizeForId(0, marker_size*2);
        multi_marker = new MultiMarker(id_vector);
        pose.Reset();
        multi_marker->PointCloudAdd(0, marker_size*2, pose);
        pose.SetTranslation(-marker_size*2.5, +marker_size*1.5, 0);
        multi_marker->PointCloudAdd(1, marker_size, pose);
        pose.SetTranslation(+marker_size*2.5, +marker_size*1.5, 0);
        multi_marker->PointCloudAdd(2, marker_size, pose);
        pose.SetTranslation(-marker_size*2.5, -marker_size*1.5, 0);
        multi_marker->PointCloudAdd(3, marker_size, pose);
        pose.SetTranslation(+marker_size*2.5, -marker_size*1.5, 0);
        multi_marker->PointCloudAdd(4, marker_size, pose);
    }

    double error=-1;
    if (marker_detector.Detect(image, &cam, true, (visualize == 1), 0.0)) {
        if (detect_additional) {
            error = multi_marker->Update(marker_detector.markers, &cam, pose);
            multi_marker->SetTrackMarkers(marker_detector, &cam, pose, visualize ? image : NULL);
            marker_detector.DetectAdditional(image, &cam, (visualize == 1));
        }
        if (visualize == 2) 
            error = multi_marker->Update(marker_detector.markers, &cam, pose, image);
        else
            error = multi_marker->Update(marker_detector.markers, &cam, pose);
    }

    static Marker foo;
    foo.SetMarkerSize(marker_size*4);
    if ((error >= 0) && (error < 5))
    {
        foo.pose = pose;
    }
    foo.Visualize(image, &cam);

    if (flip_image) {
        cvFlip(image);
        image->origin = !image->origin;
    }
}
开发者ID:130s,项目名称:ar_track_alvar,代码行数:75,代码来源:SampleMultiMarker.cpp


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