OpenCV的消光处理时间 [英] OpenCV Mat processing time
问题描述
我想知道是否为OpenCV的函数的src(源)和DST(目的地),具有不同的变量都会对处理时间的效果。我有以下两个功能 做同样的事情。
I'd like to know whether having different variables for the src (source) and dst (destination) of an OpenCV function will have an effect on the processing time. I have two functions below that does the same thing.
public static Mat getY(Mat m){
Mat mMattemp = new Mat();
Imgproc.cvtColor(m,mMattemp,Imgproc.COLOR_YUV420sp2RGB);
Imgproc.cvtColor(mMattemp,mMattemp, Imgproc.COLOR_RGB2HSV);
Core.inRange(mMattemp, new Scalar(20, 100, 100), new Scalar(30, 255, 255), mMattemp);
return mMattemp;
}
VERSUS
VERSUS
public static Mat getY(Mat m){
Mat mMattemp_rgb = new Mat();
Mat mMattemp_hsv = new Mat();
Mat mMattemp_ir = new Mat();
Imgproc.cvtColor(m,mMattemp_rgb,Imgproc.COLOR_YUV420sp2RGB);
Imgproc.cvtColor(mMattemp_rgb,mMattemp_hsv, Imgproc.COLOR_RGB2HSV);
Core.inRange(mMattemp_hsv, new Scalar(20, 100, 100), new Scalar(30, 255, 255), mMattemp_ir);
return mMattemp_ir;
}
这两个比较好?什么是一个优势比其他?
Which of the two is better? What is the advantage of one over the other?
推荐答案
要肯定知道,只是夹着你的的getY
方法调用OpenCV中的内置方法之间的双的GetTickCount()
和双getTickFrequency()
像这样(需要转换到Java):
To know for sure, just sandwich your getY
method calls between OpenCV's built-in methods double getTickCount()
and double getTickFrequency()
like this (will need to translate to java):
//first uniquely name the algorithms to compare (here just getY_TypeA and getY_TypeB)
double durationA = cv::getTickCount();
getY_TypeA(image); // the function to be tested
durationA = cv::getTickCount()-durationA;
durationA /= cv::getTickFrequency(); // the elapsed time in ms
//now call the other method
double durationB = cv::getTickCount();
getY_TypeB(image); // the function to be tested
durationB = cv::getTickCount()-durationB;
durationB /= cv::getTickFrequency(); // the elapsed time in ms
printf("Type A runtime: "+durationA+" Type B runtime: "+durationB);
有关最佳结果做到这一点的多个呼叫,并将结果平均。
For best results do this for multiple calls and average the results.
这篇关于OpenCV的消光处理时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!