OpenCV Mat处理时间

我想知道OpenCV函数的src(source)和dst(destination)是否有不同的变量会对处理时间产生影响。 我在下面有两个函数可以做同样的事情。

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; } 

 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; } 

哪两个更好? 一个优于另一个的优势是什么?

要确切知道,只需将您的getY方法调用夹在OpenCV的内置方法double getTickCount()double getTickFrequency() (需要转换为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); 

为获得最佳效果,请对多个调用执行此操作并对结果进