本文整理汇总了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();
//.........这里部分代码省略.........