Merge pull request #1061 from bitwangyaoyao:2.4_fix2
This commit is contained in:
commit
c8cd2cf601
@ -1816,8 +1816,14 @@ void cv::ocl::device::hog::normalize_hists(int nbins,
|
|||||||
openCLExecuteKernel(clCxt, &objdetect_hog, kernelName, globalThreads,
|
openCLExecuteKernel(clCxt, &objdetect_hog, kernelName, globalThreads,
|
||||||
localThreads, args, -1, -1, "-D CPU");
|
localThreads, args, -1, -1, "-D CPU");
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
cl_kernel kernel = openCLGetKernelFromSource(clCxt, &objdetect_hog, kernelName);
|
||||||
|
int wave_size = queryDeviceInfo<WAVEFRONT_SIZE, int>(kernel);
|
||||||
|
char opt[32] = {0};
|
||||||
|
sprintf(opt, "-D WAVE_SIZE=%d", wave_size);
|
||||||
openCLExecuteKernel(clCxt, &objdetect_hog, kernelName, globalThreads,
|
openCLExecuteKernel(clCxt, &objdetect_hog, kernelName, globalThreads,
|
||||||
localThreads, args, -1, -1);
|
localThreads, args, -1, -1, opt);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void cv::ocl::device::hog::classify_hists(int win_height, int win_width,
|
void cv::ocl::device::hog::classify_hists(int win_height, int win_width,
|
||||||
@ -1879,8 +1885,14 @@ void cv::ocl::device::hog::classify_hists(int win_height, int win_width,
|
|||||||
openCLExecuteKernel(clCxt, &objdetect_hog, kernelName, globalThreads,
|
openCLExecuteKernel(clCxt, &objdetect_hog, kernelName, globalThreads,
|
||||||
localThreads, args, -1, -1, "-D CPU");
|
localThreads, args, -1, -1, "-D CPU");
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
cl_kernel kernel = openCLGetKernelFromSource(clCxt, &objdetect_hog, kernelName);
|
||||||
|
int wave_size = queryDeviceInfo<WAVEFRONT_SIZE, int>(kernel);
|
||||||
|
char opt[32] = {0};
|
||||||
|
sprintf(opt, "-D WAVE_SIZE=%d", wave_size);
|
||||||
openCLExecuteKernel(clCxt, &objdetect_hog, kernelName, globalThreads,
|
openCLExecuteKernel(clCxt, &objdetect_hog, kernelName, globalThreads,
|
||||||
localThreads, args, -1, -1);
|
localThreads, args, -1, -1, opt);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void cv::ocl::device::hog::extract_descrs_by_rows(int win_height, int win_width,
|
void cv::ocl::device::hog::extract_descrs_by_rows(int win_height, int win_width,
|
||||||
|
@ -133,7 +133,9 @@ __kernel void compute_hists_lut_kernel(
|
|||||||
final_hist[(cell_x * 2 + cell_y) * cnbins + bin_id] =
|
final_hist[(cell_x * 2 + cell_y) * cnbins + bin_id] =
|
||||||
hist_[0] + hist_[1] + hist_[2];
|
hist_[0] + hist_[1] + hist_[2];
|
||||||
}
|
}
|
||||||
|
#ifdef CPU
|
||||||
barrier(CLK_LOCAL_MEM_FENCE);
|
barrier(CLK_LOCAL_MEM_FENCE);
|
||||||
|
#endif
|
||||||
|
|
||||||
int tid = (cell_y * CELLS_PER_BLOCK_Y + cell_x) * 12 + cell_thread_x;
|
int tid = (cell_y * CELLS_PER_BLOCK_Y + cell_x) * 12 + cell_thread_x;
|
||||||
if ((tid < cblock_hist_size) && (gid < blocks_total))
|
if ((tid < cblock_hist_size) && (gid < blocks_total))
|
||||||
@ -225,8 +227,9 @@ __kernel void compute_hists_kernel(
|
|||||||
final_hist[(cell_x * 2 + cell_y) * cnbins + bin_id] =
|
final_hist[(cell_x * 2 + cell_y) * cnbins + bin_id] =
|
||||||
hist_[0] + hist_[1] + hist_[2];
|
hist_[0] + hist_[1] + hist_[2];
|
||||||
}
|
}
|
||||||
|
#ifdef CPU
|
||||||
barrier(CLK_LOCAL_MEM_FENCE);
|
barrier(CLK_LOCAL_MEM_FENCE);
|
||||||
|
#endif
|
||||||
int tid = (cell_y * CELLS_PER_BLOCK_Y + cell_x) * 12 + cell_thread_x;
|
int tid = (cell_y * CELLS_PER_BLOCK_Y + cell_x) * 12 + cell_thread_x;
|
||||||
if ((tid < cblock_hist_size) && (gid < blocks_total))
|
if ((tid < cblock_hist_size) && (gid < blocks_total))
|
||||||
{
|
{
|
||||||
@ -318,6 +321,10 @@ float reduce_smem(volatile __local float* smem, int size)
|
|||||||
if (tid < 32)
|
if (tid < 32)
|
||||||
{
|
{
|
||||||
if (size >= 64) smem[tid] = sum = sum + smem[tid + 32];
|
if (size >= 64) smem[tid] = sum = sum + smem[tid + 32];
|
||||||
|
#if WAVE_SIZE < 32
|
||||||
|
} barrier(CLK_LOCAL_MEM_FENCE);
|
||||||
|
if (tid < 16) {
|
||||||
|
#endif
|
||||||
if (size >= 32) smem[tid] = sum = sum + smem[tid + 16];
|
if (size >= 32) smem[tid] = sum = sum + smem[tid + 16];
|
||||||
if (size >= 16) smem[tid] = sum = sum + smem[tid + 8];
|
if (size >= 16) smem[tid] = sum = sum + smem[tid + 8];
|
||||||
if (size >= 8) smem[tid] = sum = sum + smem[tid + 4];
|
if (size >= 8) smem[tid] = sum = sum + smem[tid + 4];
|
||||||
@ -418,6 +425,9 @@ __kernel void classify_hists_180_kernel(
|
|||||||
{
|
{
|
||||||
smem[tid] = product = product + smem[tid + 32];
|
smem[tid] = product = product + smem[tid + 32];
|
||||||
}
|
}
|
||||||
|
#if WAVE_SIZE < 32
|
||||||
|
barrier(CLK_LOCAL_MEM_FENCE);
|
||||||
|
#endif
|
||||||
if (tid < 16)
|
if (tid < 16)
|
||||||
{
|
{
|
||||||
smem[tid] = product = product + smem[tid + 16];
|
smem[tid] = product = product + smem[tid + 16];
|
||||||
@ -487,6 +497,10 @@ __kernel void classify_hists_252_kernel(
|
|||||||
if (tid < 32)
|
if (tid < 32)
|
||||||
{
|
{
|
||||||
smem[tid] = product = product + smem[tid + 32];
|
smem[tid] = product = product + smem[tid + 32];
|
||||||
|
#if WAVE_SIZE < 32
|
||||||
|
} barrier(CLK_LOCAL_MEM_FENCE);
|
||||||
|
if (tid < 16) {
|
||||||
|
#endif
|
||||||
smem[tid] = product = product + smem[tid + 16];
|
smem[tid] = product = product + smem[tid + 16];
|
||||||
smem[tid] = product = product + smem[tid + 8];
|
smem[tid] = product = product + smem[tid + 8];
|
||||||
smem[tid] = product = product + smem[tid + 4];
|
smem[tid] = product = product + smem[tid + 4];
|
||||||
@ -553,6 +567,10 @@ __kernel void classify_hists_kernel(
|
|||||||
if (tid < 32)
|
if (tid < 32)
|
||||||
{
|
{
|
||||||
smem[tid] = product = product + smem[tid + 32];
|
smem[tid] = product = product + smem[tid + 32];
|
||||||
|
#if WAVE_SIZE < 32
|
||||||
|
} barrier(CLK_LOCAL_MEM_FENCE);
|
||||||
|
if (tid < 16) {
|
||||||
|
#endif
|
||||||
smem[tid] = product = product + smem[tid + 16];
|
smem[tid] = product = product + smem[tid + 16];
|
||||||
smem[tid] = product = product + smem[tid + 8];
|
smem[tid] = product = product + smem[tid + 8];
|
||||||
smem[tid] = product = product + smem[tid + 4];
|
smem[tid] = product = product + smem[tid + 4];
|
||||||
|
@ -258,27 +258,13 @@ float sobel(__global unsigned char *input, int x, int y, int rows, int cols)
|
|||||||
|
|
||||||
float CalcSums(__local float *cols, __local float *cols_cache, int winsz)
|
float CalcSums(__local float *cols, __local float *cols_cache, int winsz)
|
||||||
{
|
{
|
||||||
float cache = 0;
|
unsigned int cache = cols[0];
|
||||||
float cache2 = 0;
|
|
||||||
int winsz2 = winsz/2;
|
|
||||||
|
|
||||||
int x = get_local_id(0);
|
#pragma unroll
|
||||||
int group_size_x = get_local_size(0);
|
for(int i = 1; i <= winsz; i++)
|
||||||
|
|
||||||
for(int i = 1; i <= winsz2; i++)
|
|
||||||
cache += cols[i];
|
cache += cols[i];
|
||||||
|
|
||||||
cols_cache[0] = cache;
|
return cache;
|
||||||
|
|
||||||
barrier(CLK_LOCAL_MEM_FENCE);
|
|
||||||
|
|
||||||
if (x < group_size_x - winsz2)
|
|
||||||
cache2 = cols_cache[winsz2];
|
|
||||||
else
|
|
||||||
for(int i = winsz2 + 1; i < winsz; i++)
|
|
||||||
cache2 += cols[i];
|
|
||||||
|
|
||||||
return cols[0] + cache + cache2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define RpT (2 * ROWSperTHREAD) // got experimentally
|
#define RpT (2 * ROWSperTHREAD) // got experimentally
|
||||||
@ -301,8 +287,7 @@ __kernel void textureness_kernel(__global unsigned char *disp, int disp_rows, in
|
|||||||
int beg_row = group_id_y * RpT;
|
int beg_row = group_id_y * RpT;
|
||||||
int end_row = min(beg_row + RpT, disp_rows);
|
int end_row = min(beg_row + RpT, disp_rows);
|
||||||
|
|
||||||
// if (x < disp_cols)
|
|
||||||
// {
|
|
||||||
int y = beg_row;
|
int y = beg_row;
|
||||||
|
|
||||||
float sum = 0;
|
float sum = 0;
|
||||||
@ -340,11 +325,15 @@ __kernel void textureness_kernel(__global unsigned char *disp, int disp_rows, in
|
|||||||
}
|
}
|
||||||
|
|
||||||
barrier(CLK_LOCAL_MEM_FENCE);
|
barrier(CLK_LOCAL_MEM_FENCE);
|
||||||
|
|
||||||
|
if (x < disp_cols)
|
||||||
|
{
|
||||||
float sum_win = CalcSums(cols, cols_cache + local_id_x, winsz) * 255;
|
float sum_win = CalcSums(cols, cols_cache + local_id_x, winsz) * 255;
|
||||||
if (sum_win < threshold)
|
if (sum_win < threshold)
|
||||||
disp[y * disp_step + x] = 0;
|
disp[y * disp_step + x] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
barrier(CLK_LOCAL_MEM_FENCE);
|
barrier(CLK_LOCAL_MEM_FENCE);
|
||||||
}
|
}
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
@ -118,6 +118,8 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
setDevice(oclinfo[pid], device);
|
setDevice(oclinfo[pid], device);
|
||||||
|
|
||||||
|
setBinaryDiskCache(CACHE_UPDATE);
|
||||||
|
|
||||||
cout << "Device type:" << type << endl << "Device name:" << oclinfo[pid].DeviceName[device] << endl;
|
cout << "Device type:" << type << endl << "Device name:" << oclinfo[pid].DeviceName[device] << endl;
|
||||||
return RUN_ALL_TESTS();
|
return RUN_ALL_TESTS();
|
||||||
}
|
}
|
||||||
|
@ -146,17 +146,17 @@ TEST_P(HOG, Detect)
|
|||||||
if (winSize.width == 48 && winSize.height == 96)
|
if (winSize.width == 48 && winSize.height == 96)
|
||||||
{
|
{
|
||||||
// daimler's base
|
// daimler's base
|
||||||
ocl_hog.setSVMDetector(ocl_hog.getPeopleDetector48x96());
|
ocl_hog.setSVMDetector(hog.getDaimlerPeopleDetector());
|
||||||
hog.setSVMDetector(hog.getDaimlerPeopleDetector());
|
hog.setSVMDetector(hog.getDaimlerPeopleDetector());
|
||||||
}
|
}
|
||||||
else if (winSize.width == 64 && winSize.height == 128)
|
else if (winSize.width == 64 && winSize.height == 128)
|
||||||
{
|
{
|
||||||
ocl_hog.setSVMDetector(ocl_hog.getPeopleDetector64x128());
|
ocl_hog.setSVMDetector(hog.getDefaultPeopleDetector());
|
||||||
hog.setSVMDetector(hog.getDefaultPeopleDetector());
|
hog.setSVMDetector(hog.getDefaultPeopleDetector());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ocl_hog.setSVMDetector(ocl_hog.getDefaultPeopleDetector());
|
ocl_hog.setSVMDetector(hog.getDefaultPeopleDetector());
|
||||||
hog.setSVMDetector(hog.getDefaultPeopleDetector());
|
hog.setSVMDetector(hog.getDefaultPeopleDetector());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND)
|
|||||||
target_link_libraries(${the_target} ${OPENCV_LINKER_LIBS} ${OPENCV_OCL_SAMPLES_REQUIRED_DEPS})
|
target_link_libraries(${the_target} ${OPENCV_LINKER_LIBS} ${OPENCV_OCL_SAMPLES_REQUIRED_DEPS})
|
||||||
|
|
||||||
set_target_properties(${the_target} PROPERTIES
|
set_target_properties(${the_target} PROPERTIES
|
||||||
OUTPUT_NAME "${name}_${project}"
|
OUTPUT_NAME "${project}-example-${name}"
|
||||||
PROJECT_LABEL "(EXAMPLE_${project_upper}) ${name}")
|
PROJECT_LABEL "(EXAMPLE_${project_upper}) ${name}")
|
||||||
|
|
||||||
if(ENABLE_SOLUTION_FOLDERS)
|
if(ENABLE_SOLUTION_FOLDERS)
|
||||||
|
108
samples/ocl/clahe.cpp
Normal file
108
samples/ocl/clahe.cpp
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include "opencv2/core/core.hpp"
|
||||||
|
#include "opencv2/imgproc/imgproc.hpp"
|
||||||
|
#include "opencv2/highgui/highgui.hpp"
|
||||||
|
#include "opencv2/ocl/ocl.hpp"
|
||||||
|
using namespace cv;
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Clip_Callback(int)
|
||||||
|
{
|
||||||
|
pFilter->setClipLimit(cliplimit);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char** argv)
|
||||||
|
{
|
||||||
|
const char* keys =
|
||||||
|
"{ 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}";
|
||||||
|
|
||||||
|
CommandLineParser cmd(argc, argv, keys);
|
||||||
|
string infile = cmd.get<string>("i");
|
||||||
|
outfile = cmd.get<string>("o");
|
||||||
|
int camid = cmd.get<int>("c");
|
||||||
|
bool use_cpu = cmd.get<bool>("s");
|
||||||
|
CvCapture* capture = 0;
|
||||||
|
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;
|
||||||
|
|
||||||
|
int cur_clip;
|
||||||
|
Size cur_tilesize;
|
||||||
|
if(use_cpu)
|
||||||
|
{
|
||||||
|
pFilter = createCLAHE();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pFilter = 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
capture = cvCaptureFromCAM(camid);
|
||||||
|
}
|
||||||
|
cout << "\nControls:\n"
|
||||||
|
<< "\to - save output image\n"
|
||||||
|
<< "\tESC - exit\n";
|
||||||
|
while(running)
|
||||||
|
{
|
||||||
|
if(capture)
|
||||||
|
frame = cvQueryFrame(capture);
|
||||||
|
else
|
||||||
|
frame = imread(infile);
|
||||||
|
if(frame.empty())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if(use_cpu)
|
||||||
|
{
|
||||||
|
cvtColor(frame, frame, COLOR_BGR2GRAY);
|
||||||
|
pFilter->apply(frame, outframe);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ocl::oclMat d_frame(frame);
|
||||||
|
ocl::cvtColor(d_frame, d_outframe, COLOR_BGR2GRAY);
|
||||||
|
pFilter->apply(d_outframe, d_outframe);
|
||||||
|
d_outframe.download(outframe);
|
||||||
|
}
|
||||||
|
imshow("CLAHE", outframe);
|
||||||
|
char key = (char)cvWaitKey(3);
|
||||||
|
if(key == 'o') imwrite(outfile, outframe);
|
||||||
|
else if(key == 27) running = false;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
@ -252,8 +252,13 @@ void Draw(Mat& img, vector<Rect>& faces, double scale)
|
|||||||
radius = cvRound((r->width + r->height)*0.25*scale);
|
radius = cvRound((r->width + r->height)*0.25*scale);
|
||||||
circle( img, center, radius, color, 3, 8, 0 );
|
circle( img, center, radius, color, 3, 8, 0 );
|
||||||
}
|
}
|
||||||
imshow( "result", img );
|
|
||||||
imwrite( outputName, img );
|
imwrite( outputName, img );
|
||||||
|
if(abs(scale-1.0)>.001)
|
||||||
|
{
|
||||||
|
resize(img, img, Size((int)(img.cols/scale), (int)(img.rows/scale)));
|
||||||
|
}
|
||||||
|
imshow( "result", img );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -57,6 +57,7 @@ private:
|
|||||||
string vdo_source;
|
string vdo_source;
|
||||||
string output;
|
string output;
|
||||||
int camera_id;
|
int camera_id;
|
||||||
|
bool write_once;
|
||||||
};
|
};
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
@ -97,6 +98,7 @@ App::App(CommandLineParser& cmd)
|
|||||||
<< "\tESC - exit\n"
|
<< "\tESC - exit\n"
|
||||||
<< "\tm - change mode GPU <-> CPU\n"
|
<< "\tm - change mode GPU <-> CPU\n"
|
||||||
<< "\tg - convert image to gray or not\n"
|
<< "\tg - convert image to gray or not\n"
|
||||||
|
<< "\to - save output image once, or switch on/off video save\n"
|
||||||
<< "\t1/q - increase/decrease HOG scale\n"
|
<< "\t1/q - increase/decrease HOG scale\n"
|
||||||
<< "\t2/w - increase/decrease levels count\n"
|
<< "\t2/w - increase/decrease levels count\n"
|
||||||
<< "\t3/e - increase/decrease HOG group threshold\n"
|
<< "\t3/e - increase/decrease HOG group threshold\n"
|
||||||
@ -120,6 +122,7 @@ App::App(CommandLineParser& cmd)
|
|||||||
hit_threshold = win_width == 48 ? 1.4 : 0.;
|
hit_threshold = win_width == 48 ? 1.4 : 0.;
|
||||||
scale = 1.05;
|
scale = 1.05;
|
||||||
gamma_corr = true;
|
gamma_corr = true;
|
||||||
|
write_once = false;
|
||||||
|
|
||||||
cout << "Group threshold: " << gr_threshold << endl;
|
cout << "Group threshold: " << gr_threshold << endl;
|
||||||
cout << "Levels number: " << nlevels << endl;
|
cout << "Levels number: " << nlevels << endl;
|
||||||
@ -254,10 +257,11 @@ void App::run()
|
|||||||
|
|
||||||
workEnd();
|
workEnd();
|
||||||
|
|
||||||
if (output!="")
|
if (output!="" && write_once)
|
||||||
{
|
{
|
||||||
if (img_source!="") // wirte image
|
if (img_source!="") // wirte image
|
||||||
{
|
{
|
||||||
|
write_once = false;
|
||||||
imwrite(output, img_to_show);
|
imwrite(output, img_to_show);
|
||||||
}
|
}
|
||||||
else //write video
|
else //write video
|
||||||
@ -340,6 +344,10 @@ void App::handleKey(char key)
|
|||||||
gamma_corr = !gamma_corr;
|
gamma_corr = !gamma_corr;
|
||||||
cout << "Gamma correction: " << gamma_corr << endl;
|
cout << "Gamma correction: " << gamma_corr << endl;
|
||||||
break;
|
break;
|
||||||
|
case 'o':
|
||||||
|
case 'O':
|
||||||
|
write_once = !write_once;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ struct App
|
|||||||
return ss.str();
|
return ss.str();
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
bool running;
|
bool running, write_once;
|
||||||
|
|
||||||
Mat left_src, right_src;
|
Mat left_src, right_src;
|
||||||
Mat left, right;
|
Mat left, right;
|
||||||
@ -115,6 +115,7 @@ App::App(CommandLineParser& cmd)
|
|||||||
cout << "stereo_match_ocl sample\n";
|
cout << "stereo_match_ocl sample\n";
|
||||||
cout << "\nControls:\n"
|
cout << "\nControls:\n"
|
||||||
<< "\tesc - exit\n"
|
<< "\tesc - exit\n"
|
||||||
|
<< "\to - save output image once\n"
|
||||||
<< "\tp - print current parameters\n"
|
<< "\tp - print current parameters\n"
|
||||||
<< "\tg - convert source images into gray\n"
|
<< "\tg - convert source images into gray\n"
|
||||||
<< "\tm - change stereo match method\n"
|
<< "\tm - change stereo match method\n"
|
||||||
@ -132,6 +133,7 @@ App::App(CommandLineParser& cmd)
|
|||||||
else cout << "unknown method!\n";
|
else cout << "unknown method!\n";
|
||||||
ndisp = cmd.get<int>("n");
|
ndisp = cmd.get<int>("n");
|
||||||
out_img = cmd.get<string>("o");
|
out_img = cmd.get<string>("o");
|
||||||
|
write_once = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -161,10 +163,8 @@ void App::run()
|
|||||||
printParams();
|
printParams();
|
||||||
|
|
||||||
running = true;
|
running = true;
|
||||||
bool written = false;
|
|
||||||
while (running)
|
while (running)
|
||||||
{
|
{
|
||||||
|
|
||||||
// Prepare disparity map of specified type
|
// Prepare disparity map of specified type
|
||||||
Mat disp;
|
Mat disp;
|
||||||
oclMat d_disp;
|
oclMat d_disp;
|
||||||
@ -192,19 +192,21 @@ void App::run()
|
|||||||
csbp(d_left, d_right, d_disp);
|
csbp(d_left, d_right, d_disp);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show results
|
// Show results
|
||||||
d_disp.download(disp);
|
d_disp.download(disp);
|
||||||
workEnd();
|
workEnd();
|
||||||
|
|
||||||
if (method != BM)
|
if (method != BM)
|
||||||
{
|
{
|
||||||
disp.convertTo(disp, 0);
|
disp.convertTo(disp, 0);
|
||||||
}
|
}
|
||||||
putText(disp, text(), Point(5, 25), FONT_HERSHEY_SIMPLEX, 1.0, Scalar::all(255));
|
putText(disp, text(), Point(5, 25), FONT_HERSHEY_SIMPLEX, 1.0, Scalar::all(255));
|
||||||
imshow("disparity", disp);
|
imshow("disparity", disp);
|
||||||
if(!written)
|
if(write_once)
|
||||||
{
|
{
|
||||||
imwrite(out_img, disp);
|
imwrite(out_img, disp);
|
||||||
written = true;
|
write_once = false;
|
||||||
}
|
}
|
||||||
handleKey((char)waitKey(3));
|
handleKey((char)waitKey(3));
|
||||||
}
|
}
|
||||||
@ -378,6 +380,10 @@ void App::handleKey(char key)
|
|||||||
cout << "level_count: " << csbp.levels << endl;
|
cout << "level_count: " << csbp.levels << endl;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 'o':
|
||||||
|
case 'O':
|
||||||
|
write_once = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user