1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-29 23:33:05 +04:00

Merge remote-tracking branch 'origin/2.4' into merge-2.4

Conflicts:
	CMakeLists.txt
	modules/calib3d/src/calibration.cpp
	modules/ocl/src/cl_programcache.cpp
	modules/ocl/src/filtering.cpp
	modules/ocl/src/imgproc.cpp
	samples/ocl/adaptive_bilateral_filter.cpp
	samples/ocl/bgfg_segm.cpp
	samples/ocl/clahe.cpp
	samples/ocl/facedetect.cpp
	samples/ocl/pyrlk_optical_flow.cpp
	samples/ocl/squares.cpp
	samples/ocl/surf_matcher.cpp
	samples/ocl/tvl1_optical_flow.cpp
This commit is contained in:
Roman Donchenko
2013-10-28 13:38:25 +04:00
182 changed files with 894 additions and 1088 deletions
+31 -29
View File
@@ -10,15 +10,13 @@ using namespace std;
Ptr<CLAHE> pFilter;
int tilesize;
int cliplimit;
string outfile;
static void TSize_Callback(int pos)
{
if(pos==0)
{
pFilter->setTilesGridSize(Size(1,1));
}
pFilter->setTilesGridSize(Size(tilesize,tilesize));
else
pFilter->setTilesGridSize(Size(tilesize,tilesize));
}
static void Clip_Callback(int)
@@ -32,63 +30,64 @@ int main(int argc, char** argv)
"{ i input | | specify input image }"
"{ c camera | 0 | specify camera id }"
"{ s use_cpu | false | use cpu algorithm }"
"{ o output | clahe_output.jpg | specify output save path}";
"{ o output | clahe_output.jpg | specify output save path}"
"{ h help | false | print help message }";
CommandLineParser cmd(argc, argv, keys);
string infile = cmd.get<string>("i");
outfile = cmd.get<string>("o");
cv::CommandLineParser cmd(argc, argv, keys);
if (cmd.has("help"))
{
cout << "Usage : clahe [options]" << endl;
cout << "Available options:" << endl;
cmd.printMessage();
return EXIT_SUCCESS;
}
string infile = cmd.get<string>("i"), outfile = cmd.get<string>("o");
int camid = cmd.get<int>("c");
bool use_cpu = cmd.get<bool>("s");
VideoCapture capture;
bool running = true;
namedWindow("CLAHE");
createTrackbar("Tile Size", "CLAHE", &tilesize, 32, (TrackbarCallback)TSize_Callback);
createTrackbar("Clip Limit", "CLAHE", &cliplimit, 20, (TrackbarCallback)Clip_Callback);
Mat frame, outframe;
ocl::oclMat d_outframe;
ocl::oclMat d_outframe, d_frame;
int cur_clip;
Size cur_tilesize;
if(use_cpu)
{
pFilter = createCLAHE();
}
else
{
pFilter = ocl::createCLAHE();
}
pFilter = use_cpu ? createCLAHE() : ocl::createCLAHE();
cur_clip = (int)pFilter->getClipLimit();
cur_tilesize = pFilter->getTilesGridSize();
setTrackbarPos("Tile Size", "CLAHE", cur_tilesize.width);
setTrackbarPos("Clip Limit", "CLAHE", cur_clip);
if(infile != "")
{
frame = imread(infile);
if(frame.empty())
{
cout << "error read image: " << infile << endl;
return -1;
return EXIT_FAILURE;
}
}
else
{
capture.open(camid);
}
cout << "\nControls:\n"
<< "\to - save output image\n"
<< "\tESC - exit\n";
while(running)
for (;;)
{
if(capture.isOpened())
capture.read(frame);
else
frame = imread(infile);
if(frame.empty())
{
continue;
}
if(use_cpu)
{
cvtColor(frame, frame, COLOR_BGR2GRAY);
@@ -96,15 +95,18 @@ int main(int argc, char** argv)
}
else
{
ocl::oclMat d_frame(frame);
ocl::cvtColor(d_frame, d_outframe, COLOR_BGR2GRAY);
ocl::cvtColor(d_frame = frame, d_outframe, COLOR_BGR2GRAY);
pFilter->apply(d_outframe, d_outframe);
d_outframe.download(outframe);
}
imshow("CLAHE", outframe);
char key = (char)waitKey(3);
if(key == 'o') imwrite(outfile, outframe);
else if(key == 27) running = false;
if(key == 'o')
imwrite(outfile, outframe);
else if(key == 27)
break;
}
return 0;
return EXIT_SUCCESS;
}