gpu的问题:调整大小
Issues with gpu::resize
我正在尝试计算GPU上不同级别的HOG功能,然后将每个级别的功能保存到yml文件中。下面是我正在使用的函数。
void App::run()
{
unsigned int count = 0;
FileStorage fs;
running = true;
int width = 640;
int height = 480;
Size win_size(args.win_width, args.win_width * 2);
Size win_stride(args.win_stride_width, args.win_stride_height);
cv::gpu::HOGDescriptor gpu_hog(win_size, Size(16, 16), Size(8, 8), Size(8, 8), 9,
cv::gpu::HOGDescriptor::DEFAULT_WIN_SIGMA, 0.2, gamma_corr,
cv::gpu::HOGDescriptor::DEFAULT_NLEVELS);
VideoCapture vc("/home/ubuntu/Desktop/getdescriptor/images/image%d.jpg");
Mat frame;
Mat Left;
Mat img_aux, img, img_to_show, img_new;
cv::Mat temp;
gpu::GpuMat gpu_img, descriptors, new_img;
char cbuff[20];
while (running)
{
vc.read(frame);
if (!frame.empty())
{
workBegin();
sprintf (cbuff, "%04d", count);
// Change format of the image
if (make_gray) cvtColor(frame, img_aux, CV_BGR2GRAY);
else if (use_gpu) cvtColor(frame, img_aux, CV_BGR2BGRA);
else Left.copyTo(img_aux);
// Resize image
if (args.resize_src) resize(img_aux, img, Size(args.width, args.height));
else img = img_aux;
img_to_show = img;
gpu_hog.nlevels = nlevels;
hogWorkBegin();
if (use_gpu)
{
gpu_img.upload(img);
new_img.upload(img_new);
fs.open(cbuff, FileStorage::WRITE);
//double scale = 1.05;
for(int levels = 0; levels < nlevels; levels++)
{
gpu_hog.getDescriptors(gpu_img, win_stride, descriptors, cv::gpu::HOGDescriptor::DESCR_FORMAT_ROW_BY_ROW);
descriptors.download(temp);
printf("size %d %dn", temp.rows, temp.cols);
fs <<"level" << levels;
fs << "features" << temp;
cout<<"("<<width<<","<<height<<")"<<endl;
width = round(width/scale);
height = round(height/scale);
cout<<"Levels "<<levels<<endl;
if(width < win_size.width || height < win_size.height)
break;
resize(img,img_new,Size(width,height));
scale *= scale;
}
cout<<count<<endl;
count++;
}
hogWorkEnd();
fs.release();
}
else running = false;
}
}
对于第一个图像,它正确地计算了所有级别的HOG特征,但对于下一个图像,其采用了宽度和高度的旧值,在这种情况下,它打破了以下循环。
if(width < win_size.width || height < win_size.height)
break;
有人能指出我的错误吗。我试着调试,但不幸的是还没有成功。
1.宽度
2.身高
3.规模
当它为下一个图像计算HOG特征时,它会立即打破循环。一个常见的编程错误。
相关文章:
- 警告处理为错误这里有什么问题
- 最小硬币更换问题(自上而下方法)
- 我的C++程序有问题.涉及动态调整整数数组的大小
- OPENCV C 调整问题
- 调整动态数组大小时保留用户输入的值的问题
- 调整TAB大小控制闪烁问题
- 特征,实现阻尼伪逆时的矩阵大小调整问题
- 滚动条缩略图跟踪长度 基于图像的水平适合调整窗口大小时出现问题
- 当在拖动/调整窗口大小的同时对窗口调用isActive()时,返回false.(X11,问题5.4.0)
- 调整窗口大小后交换渲染缓冲区会导致问题
- 用std::vector编写可调整大小的矢量时出现问题
- 问题:如何在调整centralwidget的大小时使mainWindow自动调整大小
- 在wxGLCanvas上调整大小之前初始化着色器时出现问题
- QWidget调整大小问题
- 滚动区域中的大小调整问题
- gpu的问题:调整大小
- 动态数组调整大小函数问题
- 为调整堆栈大小分配内存时出现问题
- Qt调整窗口大小以适应滚动区域问题中的纵横比
- 大型应用程序插件中的CEF关闭/调整大小问题