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


C++ SimpleTimer::startTimer方法代码示例

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


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

示例1: displace

/*
 * SpeeDroid image processing is done here.
 *
 * PARAMS:
 * JNIEnv*			-	JNI function access pointer (not used)
 * jobject			-	Java "this" (not used)
 * jlong addrRgba	-	Memory address of frame to process (OpenCV Mat)
 * jint				-	ROI width as percentage of image
 * jint				-	ROI height as percentage of
 */
JNIEXPORT void JNICALL Java_mvs_speedroid_SpeeDroidActivity_ProcessImage(JNIEnv*, jobject, jlong addrRgba, jint roiWidth, jint roiHeight)
{
    //Get the image data from Java side pointer
	Mat& rgb = *(Mat*)addrRgba;

	//Buffer images
    Mat thresh;
    Mat mainRoiImg;
    Mat cropped;

    //log the function execution time
    clock_t startTime = clock();
    clock_t endTime;

    //We do the processing for to regions of interest.
    //We create a ROI on both sides of the image to scan both sides of the road.
    //Both ROIs have same dimensions.
    unsigned int roiW = (unsigned int)(rgb.cols/2 * (roiWidth / 100.0));
    unsigned int roiH = (unsigned int)(rgb.rows * (roiHeight / 100.0));

    if(roiW == 0){
    	LOGD("ROI width set to 0!");
    	return;
    }

    if(roiH == 0){
    	LOGD("ROI height set to 0!");
    	return;
    }

    //Timer for cooldown after successful detection
    static SimpleTimer resultCooldown = SimpleTimer();

    //Circle to store RANSAC result
    CircleType c = {Point(0,0), 0};

    if(rgb.cols < 2*roiW || rgb.rows < roiH){
    	LOGD("Too small frame!");
    	return;
    }

    //Copy the rois from input image
    mainRoiImg = Mat::zeros(Size(2*roiW,roiH), CV_8UC4);
	rgb(Rect(0,0,roiW,roiH)).copyTo(mainRoiImg(Rect(0,0,roiW,roiH)));
	rgb(Rect(rgb.cols-roiW, 0, roiW, roiH)).copyTo(mainRoiImg(Rect(roiW,0,roiW,roiH)));

	//median blur on the rois to remove noise but preserve edges
    //this is quite expensive operation!!
    //medianBlur(mainRoiImg, mainRoiImg, 3);

    //Find red pixels in the image
    findRed(mainRoiImg, thresh);

    //Identify red circles as traffic sign candidates
    if (CircleRANSAC(thresh, c)){

    	//correct the coordinate if the circle center is in roi 2
		if(c.center.x >= roiW){
			c.center.x = (c.center.x - roiW) + (rgb.cols - roiW);
		}

		Point displace(c.radius, c.radius);
		Rect roiSign(c.center-displace, c.center+displace);

		safeCrop(rgb, cropped, roiSign);

		//update results if the sign candidate is accepted and
		//2 seconds has elapsed since last detection
		if(!detectFalsePositives(cropped) && resultCooldown.isElapsed()){

			//findFeatures(cropped);
			updateDetectedSigns(cropped);
			resultCooldown.startTimer(2.0);
		}

		//Draw RANSAC result on output Mat
		circle(rgb, c.center, c.radius, Scalar(0,255,255), 4);
    }

    //Draw the ROI on the output Mat
	rectangle(rgb, Rect(0,0,roiW,roiH), Scalar(0,0,255), 2);
	rectangle(rgb, Rect(rgb.cols-roiW,0,roiW,roiH), Scalar(0,0,255), 2);

	//Draw detection results to output Mat
	drawDetectedSigns(rgb);

    thresh.release();
    mainRoiImg.release();
    cropped.release();

//.........这里部分代码省略.........
开发者ID:mvjseppa,项目名称:SpeeDroid,代码行数:101,代码来源:speeDroidJniMain.cpp


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