gpt4 book ai didi

c++ - 无法从 'cv::Mat *' 转换为 'const cv::Mat'

转载 作者:行者123 更新时间:2023-11-28 02:25:07 25 4
gpt4 key购买 nike

我正在尝试将图像从 main() 传递给另一个函数。然后我尝试将该图像上传到 GPU。但是我在这样做时遇到了错误。

重要:我必须注意计算时间。

我的代码:

void gpuProcessing( const Mat& cpuBayerImage)
{
//Loading image to the GPU
cv::gpu::GpuMat gpuBayerImage;
gpuBayerImage.upload(cpuRawBayerImage);
}

int main ()
{
---
Mat cpuBayerImage(size[1], size[0], CV_16UC1, imageData);
gpuProcessing( &cpuBayerImage);
}

错误:

error C2664: 'gpuProcessing' : cannot convert parameter 1 from 'cv::Mat *' to 'const cv::Mat &'
1> Reason: cannot convert from 'cv::Mat *' to 'const cv::Mat'
1> No constructor could take the source type, or constructor overload resolution was ambiguous

最佳答案

I am trying to pass an Image from main() to another function by reference

您实际上是通过指针传递它。变化:

gpuProcessing( &cpuBayerImage );

到:

gpuProcessing( cpuBayerImage );

我猜 cpuBayerImage 只是一个 cv::Mat。函数 gpuProcessing 引用了 const cv::Mat,但你取的是它的地址并给它一个指向 cv::Mat< 的指针。指针和引用尽管是相似的概念,但不能相互转换。

关于c++ - 无法从 'cv::Mat *' 转换为 'const cv::Mat',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31024857/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com