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


C++ MarkerDetector::setThreshold方法代码示例

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


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

示例1: main

int main(int argc, const char * argv[])
{

    // Create the root node and add a scene
    osg::Group* root = new osg::Group();  
    
    ///////////////////////////////////////////////////////////////////////////////////
    // Step 1:
    // Open a video capture device
    cv::VideoCapture* capture = new cv::VideoCapture(0);

	
    // Check whether the video camera is available
	if (!capture ) {
		std::cout << "Error" << std::endl;
		return -1;
	}
 
    capture->set(CV_CAP_PROP_FRAME_WIDTH, (int)width);
    capture->set(CV_CAP_PROP_FRAME_HEIGHT, (int)height);
    
    // Init the video by fetching the first frame
    cv::Mat videoImage;
    cv::Mat videoImageRGB;
    (*capture) >> videoImage;
    cvtColor(videoImage, videoImageRGB, CV_RGBA2RGB);
    
	// Read the camera properties width and height;
    width = capture->get(CV_CAP_PROP_FRAME_WIDTH);
    height = capture->get(CV_CAP_PROP_FRAME_HEIGHT);
     // Query the frame size of the video image.
    cv::Size size = cvSize((int) capture->get(CV_CAP_PROP_FRAME_WIDTH), (int) capture->get(CV_CAP_PROP_FRAME_HEIGHT));

    ///////////////////////////////////////////////////////////////////////////////////
    // Step 2:
    // Create the video background
    osg::Group* videoCanvas = VideoRenderer::createSzene(videoImageRGB.ptr<uchar>(0), size.width, size.height);
    root->addChild(videoCanvas);

  
	///////////////////////////////////////////////////////////////////////////////////
    // Load the camera calibration parameters
    // output Matrices
    cv::Mat intrincsicMatrix = Mat::zeros(3,3, CV_32F);
    cv::Mat distCoeffs = Mat::zeros(1, 4, CV_32F);
    
    FileStorage fs("../data_art/Camera_Parameter_File.yml", FileStorage::READ);
    fs[ "intrinsic_matrix"] >> intrincsicMatrix;
    fs[ "dist_coeffs"] >> distCoeffs;
    fs.release();
    cout << intrincsicMatrix << endl;
    cout << distCoeffs << endl;
    

    ///////////////////////////////////////////////////////////////////////////////////
    // Step 3:
    // Init the Marker Tracker
    MarkerDetector* md = new MarkerDetector(width, height, intrincsicMatrix, distCoeffs);
    md->setThreshold(150);
    

    ///////////////////////////////////////////////////////////////////////////////////
    // Step 4:
    // Create Scene
    root->addChild(createScene());
    
    
    ///////////////////////////////////////////////////////////////////////////////////
    // Step 5:
    // Load a camera configuration and apply this configuration on the projection matrix. 
    Size imageSize;
    imageSize.width = width;
    imageSize.height = height;

    // physical size of the sensor.
    double apertureWidth = 3.2;
    double apertureHeight = 2.4;
    double fovx, fovy, focalLength, aspectRatio;
    Point2d principalPoint;
    cv::calibrationMatrixValues(intrincsicMatrix, imageSize, apertureWidth, apertureHeight, fovx, fovy, focalLength, principalPoint, aspectRatio);
    
    osg::Matrixd projectionmatrix;
    projectionmatrix.makePerspective(fovy, fovx/fovy, 0.1, 1000.0);
    
    
    ///////////////////////////////////////////////////////////////////////////////////
    // Step 6:
    // Create a viewer and add a manipulator
    osgViewer::Viewer* viewer = new osgViewer::Viewer();
	viewer->setSceneData( root );
	viewer->setUpViewOnSingleScreen(0);
    viewer->getCamera()->setClearColor(osg::Vec4(0.5, 0.5, 1.0, 1.0)) ;
    viewer->getCamera()->setProjectionMatrix(projectionmatrix);
    //viewer->setCameraManipulator(new osgGA::TrackballManipulator);
    viewer->getCamera()->setViewMatrixAsLookAt(osg::Vec3d(0.0,-10.0, 0.0), osg::Vec3d(0.0,0.0, 0.0), osg::Vec3d(0.0,0.0, 1.0));
    //viewer->addEventHandler(new KeyboardEventHandler(teapot));
    viewer->init();
    
    
    ///////////////////////////////////////////////////////////////////////////////////
//.........这里部分代码省略.........
开发者ID:rafael-radkowski,项目名称:HCI571-AR,代码行数:101,代码来源:main.cpp


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