断言失败(image.type() == CV_32F).GPU卷积.OpenCV
Assertion failed (image.type() == CV_32F). GPU convolution. OpenCV
当我尝试使用GPU进行卷积时,我得到了这个错误。
OpenCV错误:Assertion failed (image.type() == CV_32F) in cv::gpu::convolve,文件d: OpenCV sourcesmodulesgpusrcimgproc.cpp,第1413行
我已经将图像类型转换为CV_32,但我有这个问题。在使用gpu::filter2D时,我也有类似的问题。
(我在GPU中使用Sobel或Gaussianblur没有问题。)
但是,当我在main中这样做时:
int a = image.type ();a的值为21。不是CV_32F。
请让我知道如何解决这个问题!我真的需要你的帮助!!谢谢你! !
using namespace cv;
using namespace std;
int main()
{
// read kernel from text file
int kernel_size=15;
ifstream fin;
fin.open ("PSF00.txt");
float kernel0[15][15];
for (int i=0; i<kernel_size; i++)
{
for (int j=0; j<kernel_size; j++)
{
fin >> kernel0[i][j];
}
}
// Save 2D Kernel array into MAT format
Mat kernel = Mat(kernel_size, kernel_size, CV_32F, kernel0);
// load image
Mat image = imread("blurry_00.jpg");
image.convertTo(image, CV_32F);
// GPU
gpu::GpuMat gpu_input, gpu_input1, gpu_output, gpu_kernel;
gpu_input.upload(image);
gpu_kernel.upload(kernel);
gpu_input.convertTo(gpu_input1, CV_32F);
gpu::convolve(gpu_input1, gpu_kernel, gpu_output);
// Download image from GPU to CPU
Mat dst(gpu_output);
dst.convertTo(dst, CV_8U);
// Create a window for display.
namedWindow( "Display window (GPU)", WINDOW_AUTOSIZE );
imshow( "Display window (GPU)", dst );
waitKey(0);
return 0;
我想你已经知道答案了,实际上21是CV_32F。
#define CV_MAKETYPE(depth,cn) (CV_MAT_DEPTH(depth) + (((cn)-1) << CV_CN_SHIFT))
#define CV_8S 1 //depth
#define CV_32F 5 //cn
#define CV_MAT_DEPTH(flags) ((flags) & CV_MAT_DEPTH_MASK)
0x21 -> cn = 5, depth = 1
相关文章:
- 在使用GPU支持编译Tensorflow时,会遇到CUDA_TOOLKIT_PATH未绑定变量
- 有没有办法简单地从 GPU 调用多个 cpp 输出文件?
- 在 DirectX 11 中从 GPU 读回顶点缓冲区(并获取顶点)
- 跨平台 GPU 计算
- C++:从GPU内存(cudaMemcpy2D)获取BGR图像(cv::Mat)
- 请求最简单的 OpenMP 目标 GPU 示例
- DirectX 11 如何处理来自 GPU 上的 sharedHandle 的图像
- 编译 GPU 的张量流示例自定义操作
- 多 GPU 批处理 1D FFT:似乎只有一个 GPU 可以工作
- 如何在GPU支持下编译tflite?
- OpenCL 在 NVIDIA 和 Intel GPU 上启动内核时CL_INVALID_COMMAND_QUEUE
- OpenGL glGetUniformBlockIndex 在 nvidea GPU 上返回INVALID_INDEX
- SDL GPU 为什么将两个图像分成两个单独的循环更快?
- 使 C++ Pi 近似在 GPU Nvidia 970M CUDA 上的 Paralell 中运行
- 具有 GPU 时间表的卤化物产生黑色图像
- TensorFlow c++ SetDefaultDevice 在多 GPU 模式下
- 在C++应用程序中使用 Tensorflow:如何释放 GPU 内存
- 利用 GPU 的最佳方式
- Cuda 中的多个 GPU - 以前可以使用代码,但现在不再使用
- 如何使用 CUDA 将 std::vector<std::string> 复制到 GPU 设备