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


C++ Mat::deallocate方法代码示例

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


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

示例1: isValidPair

	bool Epipolar::isValidPair(vector<DMatch>& matches, vector<KeyPoint>& key1, vector<KeyPoint>& key2, Mat& cam, Mat& distor, Mat& ess, Mat& inliersMask, double inlierPercent){
		vector<Point2f>pts1, pts2;
		inliersMask.deallocate();
		Mat rot, trans;
		size_t n = matches.size();
		Utility:: getPointMatches(key1, key2, matches, pts1, pts2);
		undistortPoints(pts1, pts1, cam, distor);
		undistortPoints(pts2, pts2, cam, distor);
		ess = findEssentialMat(pts1, pts2, 1.0, Point(0, 0), RANSAC, 0.999, 1.25, inliersMask);
		int inliers = recoverPose(ess, pts1, pts2, rot, trans, 1.0, Point(0, 0), inliersMask);
		return ((double)inliers / n) > inlierPercent;
	}
开发者ID:islam56naser,项目名称:3Dizer,代码行数:12,代码来源:Epipolar.cpp

示例2: imgcb


//.........这里部分代码省略.........
			{
		    // Draw polygonal contour + bonding rects + circles
		    Mat drawing = Mat::zeros( diffImg->size(), CV_8UC3 );
		    Mat andFilter = Mat::zeros( diffImg->size(), CV_8UC3 );
		    
		    for( int i = 0; i< j; i++ )
		    {
		      //Scalar color = Scalar( rng.uniform(0, 255), rng.uniform(0,255), rng.uniform(0,255) );
		      rectangle( drawing, lBoundRect[i].tl(), lBoundRect[i].br(), Scalar(255,255,255), CV_FILLED, 8, 0 );
		    }
		    
		    // AND filter on the initial image
		    bitwise_and(drawing, currImg, andFilter, noArray());
		    
		    // Find color
		    bool isGreen =  detect_color(Scalar(70,64,0), Scalar(100,139,255), &andFilter);
		    bool isOrange =  detect_color(Scalar(0,128,0), Scalar(20,200,255), &andFilter);
		    
		    if(isGreen)
		    {
		    	nbGreen += 1;
		    }
		    if(isOrange)
		    {
		    	nbOrange += 1;
		    }
		    
		    // Send data

		    /// Show in a window
		    cv::imshow("final", andFilter);
		    
      	drawing.refcount = 0;
      	drawing.deallocate();
	    }
	    else
	    {
	    	// Find color
		    bool isGreen =  detect_color(Scalar(70,64,0), Scalar(100,139,255), &currImg);
		    bool isOrange =  detect_color(Scalar(0,128,0), Scalar(20,200,255), &currImg);
		    
		    if(isGreen)
		    {
		    	nbGreen += 1;
		    }
		    if(isOrange)
		    {
		    	nbOrange += 1;
		    }
	    }
      
      // Destruct and free memory
      prevImgBlur->refcount = 0;
      prevImgBlur->deallocate();
      currImgBlur->refcount = 0;
      currImgBlur->deallocate();
      diffImg->refcount = 0;
      diffImg->deallocate();
      
      currImgGrey->refcount = 0;
      currImgGrey->deallocate();
      prevImgGrey->refcount = 0;
      prevImgGrey->deallocate();
      
      if(nbFrames > FRAME_PER_SEC)
      {
开发者ID:emmanueldumont,项目名称:tracker,代码行数:67,代码来源:tracker_node.cpp

示例3: main


//.........这里部分代码省略.........
    disparityRightGPU.data = (unsigned char*) nppiMalloc_32f_C1(width, height, &disparityRightGPU.step);
    disparityRightGPU.setUp(width, height, 1, sl::zed::FLOAT, GPU);

    // create and alloc GPU memory for the depth matrix
    Mat depthRightGPU;
    depthRightGPU.data = (unsigned char*) nppiMalloc_32f_C1(width, height, &depthRightGPU.step);
    depthRightGPU.setUp(width, height, 1, sl::zed::FLOAT, GPU);

    // create and alloc GPU memory for the image matrix
    Mat imageDisplayGPU;
    imageDisplayGPU.data = (unsigned char*) nppiMalloc_8u_C4(width, height, &imageDisplayGPU.step);
    imageDisplayGPU.setUp(width, height, 4, sl::zed::UCHAR, GPU);

    // create a CPU image for display purpose
    cv::Mat imageDisplay(height, width, CV_8UC4);

    float depthMax = 6.; //Meter
    bool depthMaxAsChanged = true;

    char key = ' ';

    // launch a loop
    bool run = true;
    while (run) {

        // Grab the current images and compute the disparity
        bool res = zed->grab(RAW, 0, 1);

        // get the right image
        // !! WARNING !! this is not a copy, here we work with the data allocated by the zed object
        // this can be done ONLY if we call ONE time this methode before the next grab, make a copy if you want to get multiple IMAGE
        Mat imageRightGPU = zed->getView_gpu(STEREO_RIGHT);

        // get the disparity
        // !! WARNING !! this is not a copy, here we work with the data allocated by the zed object
        // this can be done ONLY if we call ONE time this methode before the next grab, make a copy if you want to get multiple MEASURE
        Mat disparityGPU = zed->retrieveMeasure_gpu(DISPARITY);

        //  Call the cuda function that convert the disparity from left to right
        cuConvertDisparityLeft2Right(disparityGPU, disparityRightGPU);

        // Call the cuda function that convert disparity to depth
        cuConvertDisparity2Depth(disparityRightGPU, depthRightGPU, fx, baseline);

        // Call the cuda function that convert depth to color and merge it with the current right image
        cuOverlayImageAndDepth(depthRightGPU, imageRightGPU, imageDisplayGPU, depthMax);

        // Copy the processed image frome the GPU to the CPU for display
        cudaMemcpy2D((uchar*) imageDisplay.data, imageDisplay.step, (Npp8u*) imageDisplayGPU.data, imageDisplayGPU.step, imageDisplayGPU.getWidthByte(), imageDisplayGPU.height, cudaMemcpyDeviceToHost);

        if (printHelp) // write help text on the image if needed
            cv::putText(imageDisplay, helpString, cv::Point(20, 20), CV_FONT_HERSHEY_SIMPLEX, 0.5, cv::Scalar(111, 111, 111, 255), 2);

        // display the result
        cv::imshow("Image right Overlay", imageDisplay);
        key = cv::waitKey(20);

        switch (key)// handle the pressed key
        {
            case 'q': // close the program
            case 'Q':
                run = false;
                break;

            case 'p': // increase the distance threshold
            case 'P':
                depthMax += 1;
                depthMaxAsChanged = true;
                break;

            case 'm': // decrease the distance threshold
            case 'M':
                depthMax = (depthMax > 1 ? depthMax - 1 : 1);
                depthMaxAsChanged = true;
                break;

            case 'h': // print help
            case 'H':
                printHelp = !printHelp;
                cout << helpString << endl;
                break;
            default:
                break;
        }

        if (depthMaxAsChanged) {
            cout << "New distance max " << depthMax << "m" << endl;
            depthMaxAsChanged = false;
        }
    }

    // free all the allocated memory before quit
    imageDisplay.release();
    disparityRightGPU.deallocate();
    depthRightGPU.deallocate();
    imageDisplayGPU.deallocate();
    delete zed;

    return 0;
}
开发者ID:hangqiu,项目名称:ZED,代码行数:101,代码来源:main.cpp


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