运用OpenMP提速图像处理速度
// openmptest的测试程序
#include "stdafx.h"
void Test(int n){
for (int i=0;i<10000;i++)
{
int j=0;
j = j+1;
}
printf("%d",n);
}
int _tmain(int argc, _TCHAR* argv[])
{
for (int i=0;i<10;i++)
{
Test(i);
}
getchar();
return 0;
}
// openmptest的测试程序
#include "stdafx.h"
void Test(int n){
for (int i=0;i<10000;i++)
{
int j=0;
j = j+1;
}
printf("%d",n);
}
int _tmain(int argc, _TCHAR* argv[])
{
for (int i=0;i<10;i++)
{
Test(i);
}
getchar();
return 0;
}
// openmptest的测试程序
#include "stdafx.h"
#include <iostream>
#include <opencv2/opencv.hpp>
#include "GoCvHelper.h"
using namespace std;
using namespace cv;
using namespace GO;
Mat Test(Mat src){
Mat draw;
Mat gray;
cvtColor(src,gray,COLOR_BGR2GRAY);
threshold(gray,gray,100,255,THRESH_OTSU);
connection2(gray,draw);
return draw;
}
int _tmain(int argc, _TCHAR* argv[])
{
//时间记录
const int64 start = getTickCount();
vector<Mat> vectorMats;
//文件目录
char cbuf[100] = "F:/图片资源/纹理库brodatz/brodatzjpg";
//获取所有文件
getFiles(cbuf,vectorMats);
//循环处理
// #pragma omp parallel for
for (int i=0;i<vectorMats.size();i++)
{
Mat dst = Test(vectorMats[i]);
}
//时间
double duration = (cv::getTickCount() - start)/getTickFrequency();
printf("共消耗时间%f",duration);
waitKey();
return 0;
}
#pragma omp parallel sections
{
#pragma omp section
{
GetHessianLambdas(camframe,5,lambda1_Sigma5,lambda2_Sigma5);
}
#pragma omp section
{
GetHessianLambdas(camframe,7,lambda1_Sigma7,lambda2_Sigma7);
}
}
QMAKE_CXXFLAGS += -fopenmp
LIBS += -fopenmp
附件列表
目前方向:图像拼接融合、图像识别 联系方式:jsxyhelu@foxmail.com