1 | initial version |
Are you sure that opencl is not used in first case? put this line before first cvtcolor : ocl::setUseOpenCL(false);
and after // Tapi ocl::setUseOpenCL(true);
With this changed my results are
cvtColor ms [347.977] GaussianBlur ms [4.7035] Canny ms [5.39681] = Total [358.078]
TAPI results TAPI cvtColor ms [3.52646] TAPI GaussianBlur ms [6.04416] TAPI Canny ms [4.07012] = Total [13.6407] depth 3
without cvtColor ms [591.737] GaussianBlur ms [1.75547] Canny ms [4.09992] = Total [597.592]
TAPI results TAPI cvtColor ms [6.09695] TAPI GaussianBlur ms [6.23822] TAPI Canny ms [4.68735] = Total [17.0225]
2 | No.2 Revision |
Are you sure that opencl is not used in first case? put this line before first cvtcolor : ocl::setUseOpenCL(false);
and after // Tapi ocl::setUseOpenCL(true);
With this changed my results are
cvtColor ms [347.977]
GaussianBlur ms [4.7035]
Canny ms [5.39681]
= Total without
cvtColor ms [591.737]
GaussianBlur ms [1.75547]
Canny ms [4.09992]
= Total 3 | No.3 Revision |
Are you sure that opencl is not used in first case? put this line before first cvtcolor : ocl::setUseOpenCL(false);
and after // Tapi ocl::setUseOpenCL(true);
With this changed my results are
cvtColor ms [347.977]
GaussianBlur ms [4.7035]
Canny ms [5.39681]
= Total [358.078]
TAPI results
TAPI cvtColor ms [3.52646]
TAPI GaussianBlur ms [6.04416]
TAPI Canny ms [4.07012]
= Total [13.6407]
without
cvtColor ms [591.737]
GaussianBlur ms [1.75547]
Canny ms [4.09992]
= Total [597.592]
TAPI results
TAPI cvtColor ms [6.09695]
TAPI GaussianBlur ms [6.23822]
TAPI Canny ms [4.68735]
= Total [17.0225]
If you debug code you can see taht some opencl codes are call with Mat
4 | No.4 Revision |
Are you sure that opencl is not used in first case? put this line before first cvtcolor : ocl::setUseOpenCL(false);
and after // Tapi ocl::setUseOpenCL(true);
With this changed my results are
cvtColor ms [347.977]
GaussianBlur ms [4.7035]
Canny ms [5.39681]
= Total [358.078]
TAPI results
TAPI cvtColor ms [3.52646]
TAPI GaussianBlur ms [6.04416]
TAPI Canny ms [4.07012]
= Total [13.6407]
without
cvtColor ms [591.737]
GaussianBlur ms [1.75547]
Canny ms [4.09992]
= Total [597.592]
TAPI results
TAPI cvtColor ms [6.09695]
TAPI GaussianBlur ms [6.23822]
TAPI Canny ms [4.68735]
= Total [17.0225]
If you debug code you can see taht that some opencl codes are call with Mat
5 | No.5 Revision |
Are you sure that opencl is not used in first case? put this line before first cvtcolor : ocl::setUseOpenCL(false);
and after // Tapi ocl::setUseOpenCL(true);
With this changed my results are
cvtColor ms [347.977]
GaussianBlur ms [4.7035]
Canny ms [5.39681]
= Total [358.078]
TAPI results
TAPI cvtColor ms [3.52646]
TAPI GaussianBlur ms [6.04416]
TAPI Canny ms [4.07012]
= Total [13.6407]
without
cvtColor ms [591.737]
GaussianBlur ms [1.75547]
Canny ms [4.09992]
= Total [597.592]
TAPI results
TAPI cvtColor ms [6.09695]
TAPI GaussianBlur ms [6.23822]
TAPI Canny ms [4.68735]
= Total [17.0225]
If you debug code you can see that some opencl codes are call with Mat
I have improve your test to have more stat (using some previous post) and changed image with path relative to my computer.
int main(int argc, char **argv)
{
if (!cv::ocl::haveOpenCL())
{
cout << "OpenCL is not avaiable..." << endl;
return 0;
}
cv::ocl::Context context;
if (!context.create(cv::ocl::Device::TYPE_GPU))
{
cout << "Failed creating the context..." << endl;
return 0;
}
// In OpenCV 3.0.0 beta, only a single device is detected.
cout << context.ndevices() << " GPU devices are detected." << endl;
for (int i = 0; i < context.ndevices(); i++)
{
cv::ocl::Device device = context.device(i);
cout << "name : " << device.name() << endl;
cout << "available : " << device.available() << endl;
cout << "imageSupport : " << device.imageSupport() << endl;
cout << "OpenCL_C_Version : " << device.OpenCL_C_Version() << endl;
cout << endl;
}
Mat gray;
cout << "getNumberOfCPUs =" << getNumberOfCPUs() << "\t getNumThreads = " << getNumThreads() << "\n";
Mat image=imread("F:/lib/opencv/samples/data/aloeL.jpg", CV_LOAD_IMAGE_UNCHANGED); double totalTime = 0;
UMat uimage;
UMat ugray;
imread("F:/lib/opencv/samples/data/aloeL.jpg", CV_LOAD_IMAGE_COLOR).copyTo(uimage);
vector<double> tps;
int nbTest=100;
for (int nTest=0;nTest<nbTest;nTest++)
{
int64 start = getTickCount();
ocl::setUseOpenCL(false);
cvtColor(image, gray, COLOR_BGR2GRAY);
double timeMs = (getTickCount() - start) / getTickFrequency() * 1000;
tps.push_back(timeMs);
totalTime += timeMs;
cout << "cvtColor ms [" << timeMs<< "]" << endl;
start = getTickCount();
GaussianBlur(gray, gray, Size(7, 7), 1.5);
timeMs = (getTickCount() - start) / getTickFrequency() * 1000;
tps.push_back(timeMs);
totalTime += timeMs;
cout << "GaussianBlur ms [" << timeMs<< "]" << endl;
start = getTickCount();
Canny(gray, gray, 0, 50);
timeMs = (getTickCount() - start) / getTickFrequency() * 1000;
tps.push_back(timeMs);
totalTime += timeMs;
cout << "Canny ms [" << timeMs<< "]" << endl;
cout << "= Total [" << totalTime << "]" << endl;
// TAPI
ocl::setUseOpenCL(true);
cout << endl << "TAPI results" << endl;
totalTime = 0;
start = getTickCount();
cvtColor(uimage, ugray, COLOR_BGR2GRAY);
timeMs = (getTickCount() - start) / getTickFrequency() * 1000;
tps.push_back(timeMs);
totalTime += timeMs;
cout << "TAPI cvtColor ms [" << timeMs<< "]" << endl;
start = getTickCount();
GaussianBlur(ugray, ugray, Size(7, 7), 1.5);
timeMs = (getTickCount() - start) / getTickFrequency() * 1000;
tps.push_back(timeMs);
totalTime += timeMs;
cout << "TAPI GaussianBlur ms [" << timeMs<< "]" << endl;
start = getTickCount();
Canny(ugray, ugray, 0, 50);
timeMs = (getTickCount() - start) / getTickFrequency() * 1000;
tps.push_back(timeMs);
totalTime += timeMs;
cout << "TAPI Canny ms [" << timeMs<< "]" << endl;
cout << "= Total [" << totalTime << "]" << endl;
}
vector<double> mean,var;
mean.resize(6);
var.resize(6);
for (int j = 0; j < 6; j++)
{
mean[j] = 0.;
var[j] = 0.;
}
for (int i=0;i<nbTest;i++)
{
for (int j=0;j<6;j++)
mean[j] += tps[6*i+j];
}
for (int j=0;j<6;j++)
mean[j] /= nbTest;
for (int i=0;i<nbTest;i++)
{
for (int j=0;j<6;j++)
var[j] += pow(mean[j]-tps[6*i+j],2.0);
}
for (int j=0;j<6;j++)
var[j] /= nbTest;
cout << "Without opencl/ with opencl for cvtColor(0),Blur(1),Canny(2)\n";
for (int j=0;j<3;j++)
cout<<"test " <<j<<" = "<<mean[j]<<"("<<sqrt(var[j])<<") /"<<mean[j+3]<<"("<<sqrt(var[3+j])<<")\n";
return 0;
}
6 | No.6 Revision |
Are you sure that opencl is not used in first case? put this line before first cvtcolor : ocl::setUseOpenCL(false);
and after // Tapi ocl::setUseOpenCL(true);
With this changed my results are
cvtColor ms [347.977]
GaussianBlur ms [4.7035]
Canny ms [5.39681]
= Total [358.078]
TAPI results
TAPI cvtColor ms [3.52646]
TAPI GaussianBlur ms [6.04416]
TAPI Canny ms [4.07012]
= Total [13.6407]
without
cvtColor ms [591.737]
GaussianBlur ms [1.75547]
Canny ms [4.09992]
= Total [597.592]
TAPI results
TAPI cvtColor ms [6.09695]
TAPI GaussianBlur ms [6.23822]
TAPI Canny ms [4.68735]
= Total [17.0225]
If you debug code you can see that some opencl codes are call with Mat
I have improve your test to have more stat (using some previous post) and changed image with path relative to my computer.
int main(int argc, char **argv)
{
if (!cv::ocl::haveOpenCL())
{
cout << "OpenCL is not avaiable..." << endl;
return 0;
}
cv::ocl::Context context;
if (!context.create(cv::ocl::Device::TYPE_GPU))
{
cout << "Failed creating the context..." << endl;
return 0;
}
// In OpenCV 3.0.0 beta, only a single device is detected.
cout << context.ndevices() << " GPU devices are detected." << endl;
for (int i = 0; i < context.ndevices(); i++)
{
cv::ocl::Device device = context.device(i);
cout << "name : " << device.name() << endl;
cout << "available : " << device.available() << endl;
cout << "imageSupport : " << device.imageSupport() << endl;
cout << "OpenCL_C_Version : " << device.OpenCL_C_Version() << endl;
cout << endl;
}
Mat gray;
cout << "getNumberOfCPUs =" << getNumberOfCPUs() << "\t getNumThreads = " << getNumThreads() << "\n";
Mat image=imread("F:/lib/opencv/samples/data/aloeL.jpg", CV_LOAD_IMAGE_UNCHANGED); double totalTime = 0;
UMat uimage;
UMat ugray;
imread("F:/lib/opencv/samples/data/aloeL.jpg", CV_LOAD_IMAGE_COLOR).copyTo(uimage);
vector<double> tps;
int nbTest=100;
for (int nTest=0;nTest<nbTest;nTest++)
{
int64 start = getTickCount();
ocl::setUseOpenCL(false);
cvtColor(image, gray, COLOR_BGR2GRAY);
double timeMs = (getTickCount() - start) / getTickFrequency() * 1000;
tps.push_back(timeMs);
totalTime += timeMs;
cout << "cvtColor ms [" << timeMs<< "]" << endl;
start = getTickCount();
GaussianBlur(gray, gray, Size(7, 7), 1.5);
timeMs = (getTickCount() - start) / getTickFrequency() * 1000;
tps.push_back(timeMs);
totalTime += timeMs;
cout << "GaussianBlur ms [" << timeMs<< "]" << endl;
start = getTickCount();
Canny(gray, gray, 0, 50);
timeMs = (getTickCount() - start) / getTickFrequency() * 1000;
tps.push_back(timeMs);
totalTime += timeMs;
cout << "Canny ms [" << timeMs<< "]" << endl;
cout << "= Total [" << totalTime << "]" << endl;
// TAPI
ocl::setUseOpenCL(true);
cout << endl << "TAPI results" << endl;
totalTime = 0;
start = getTickCount();
cvtColor(uimage, ugray, COLOR_BGR2GRAY);
timeMs = (getTickCount() - start) / getTickFrequency() * 1000;
tps.push_back(timeMs);
totalTime += timeMs;
cout << "TAPI cvtColor ms [" << timeMs<< "]" << endl;
start = getTickCount();
GaussianBlur(ugray, ugray, Size(7, 7), 1.5);
timeMs = (getTickCount() - start) / getTickFrequency() * 1000;
tps.push_back(timeMs);
totalTime += timeMs;
cout << "TAPI GaussianBlur ms [" << timeMs<< "]" << endl;
start = getTickCount();
Canny(ugray, ugray, 0, 50);
timeMs = (getTickCount() - start) / getTickFrequency() * 1000;
tps.push_back(timeMs);
totalTime += timeMs;
cout << "TAPI Canny ms [" << timeMs<< "]" << endl;
cout << "= Total [" << totalTime << "]" << endl;
}
vector<double> mean,var;
mean.resize(6);
var.resize(6);
for (int j = 0; j < 6; j++)
{
mean[j] = 0.;
var[j] = 0.;
}
for (int i=0;i<nbTest;i++)
{
for (int j=0;j<6;j++)
mean[j] += tps[6*i+j];
}
for (int j=0;j<6;j++)
mean[j] /= nbTest;
for (int i=0;i<nbTest;i++)
{
for (int j=0;j<6;j++)
var[j] += pow(mean[j]-tps[6*i+j],2.0);
}
for (int j=0;j<6;j++)
var[j] /= nbTest;
cout << "Without opencl/ with opencl for cvtColor(0),Blur(1),Canny(2)\n";
for (int j=0;j<3;j++)
cout<<"test " <<j<<" = "<<mean[j]<<"("<<sqrt(var[j])<<") /"<<mean[j+3]<<"("<<sqrt(var[3+j])<<")\n";
"<<mean[j]<<"(+/-"<<sqrt(var[j])<<") /"<<mean[j+3]<<"(+/-"<<sqrt(var[3+j])<<")\n";
return 0;
}
7 | No.7 Revision |
Are you sure that opencl is not used in first case? put this line before first cvtcolor : ocl::setUseOpenCL(false);
and after // Tapi ocl::setUseOpenCL(true);
With this changed my results are
cvtColor ms [347.977]
GaussianBlur ms [4.7035]
Canny ms [5.39681]
= Total [358.078]
TAPI results
TAPI cvtColor ms [3.52646]
TAPI GaussianBlur ms [6.04416]
TAPI Canny ms [4.07012]
= Total [13.6407]
without
cvtColor ms [591.737]
GaussianBlur ms [1.75547]
Canny ms [4.09992]
= Total [597.592]
TAPI results
TAPI cvtColor ms [6.09695]
TAPI GaussianBlur ms [6.23822]
TAPI Canny ms [4.68735]
= Total [17.0225]
If you debug code you can see that some opencl codes are call with Mat
I have improve your test to have more stat (using some previous post) and changed image with path relative to my computer.
int main(int argc, char **argv)
{
if (!cv::ocl::haveOpenCL())
{
cout << "OpenCL is not avaiable..." << endl;
return 0;
}
cv::ocl::Context context;
if (!context.create(cv::ocl::Device::TYPE_GPU))
{
cout << "Failed creating the context..." << endl;
return 0;
}
// In OpenCV 3.0.0 beta, only a single device is detected.
cout << context.ndevices() << " GPU devices are detected." << endl;
for (int i = 0; i < context.ndevices(); i++)
{
cv::ocl::Device device = context.device(i);
cout << "name : " << device.name() << endl;
cout << "available : " << device.available() << endl;
cout << "imageSupport : " << device.imageSupport() << endl;
cout << "OpenCL_C_Version : " << device.OpenCL_C_Version() << endl;
cout << endl;
}
Mat gray;
cout << "getNumberOfCPUs =" << getNumberOfCPUs() << "\t getNumThreads = " << getNumThreads() << "\n";
Mat image=imread("F:/lib/opencv/samples/data/aloeL.jpg", CV_LOAD_IMAGE_UNCHANGED); double totalTime = 0;
UMat uimage;
UMat ugray;
imread("F:/lib/opencv/samples/data/aloeL.jpg", CV_LOAD_IMAGE_COLOR).copyTo(uimage);
CV_LOAD_IMAGE_UNCHANGED).copyTo(uimage);
vector<double> tps;
int nbTest=100;
for (int nTest=0;nTest<nbTest;nTest++)
{
int64 start = getTickCount();
ocl::setUseOpenCL(false);
cvtColor(image, gray, COLOR_BGR2GRAY);
double timeMs = (getTickCount() - start) / getTickFrequency() * 1000;
tps.push_back(timeMs);
totalTime += timeMs;
cout << "cvtColor ms [" << timeMs<< "]" << endl;
start = getTickCount();
GaussianBlur(gray, gray, Size(7, 7), 1.5);
timeMs = (getTickCount() - start) / getTickFrequency() * 1000;
tps.push_back(timeMs);
totalTime += timeMs;
cout << "GaussianBlur ms [" << timeMs<< "]" << endl;
start = getTickCount();
Canny(gray, gray, 0, 50);
timeMs = (getTickCount() - start) / getTickFrequency() * 1000;
tps.push_back(timeMs);
totalTime += timeMs;
cout << "Canny ms [" << timeMs<< "]" << endl;
cout << "= Total [" << totalTime << "]" << endl;
// TAPI
ocl::setUseOpenCL(true);
cout << endl << "TAPI results" << endl;
totalTime = 0;
start = getTickCount();
cvtColor(uimage, ugray, COLOR_BGR2GRAY);
timeMs = (getTickCount() - start) / getTickFrequency() * 1000;
tps.push_back(timeMs);
totalTime += timeMs;
cout << "TAPI cvtColor ms [" << timeMs<< "]" << endl;
start = getTickCount();
GaussianBlur(ugray, ugray, Size(7, 7), 1.5);
timeMs = (getTickCount() - start) / getTickFrequency() * 1000;
tps.push_back(timeMs);
totalTime += timeMs;
cout << "TAPI GaussianBlur ms [" << timeMs<< "]" << endl;
start = getTickCount();
Canny(ugray, ugray, 0, 50);
timeMs = (getTickCount() - start) / getTickFrequency() * 1000;
tps.push_back(timeMs);
totalTime += timeMs;
cout << "TAPI Canny ms [" << timeMs<< "]" << endl;
cout << "= Total [" << totalTime << "]" << endl;
}
vector<double> mean,var;
mean.resize(6);
var.resize(6);
for (int j = 0; j < 6; j++)
{
mean[j] = 0.;
var[j] = 0.;
}
for (int i=0;i<nbTest;i++)
{
for (int j=0;j<6;j++)
mean[j] += tps[6*i+j];
}
for (int j=0;j<6;j++)
mean[j] /= nbTest;
for (int i=0;i<nbTest;i++)
{
for (int j=0;j<6;j++)
var[j] += pow(mean[j]-tps[6*i+j],2.0);
}
for (int j=0;j<6;j++)
var[j] /= nbTest;
cout << "Without opencl/ with opencl for cvtColor(0),Blur(1),Canny(2)\n";
for (int j=0;j<3;j++)
cout<<"test " <<j<<" = "<<mean[j]<<"(+/-"<<sqrt(var[j])<<") /"<<mean[j+3]<<"(+/-"<<sqrt(var[3+j])<<")\n";
return 0;
}