gpt4 book ai didi

c - IplImage 的动态数组 - 与 ‘operator=’ 错误不匹配

转载 作者:行者123 更新时间:2023-11-30 15:47:23 24 4
gpt4 key购买 nike

我正在使用 IplImage 类型的动态数组来存储一些图像(我想对 cvHistogram 做同样的事情,但得到相同的错误),我需要从中提取直方图数据。不幸的是我收到了错误并且不知道如何解决它。任何以其他方式执行此操作的帮助和建议将不胜感激。

这是代码的一部分:

void getColorHistogram( void ){

IplImage *images = (IplImage *)malloc( sizeof(IplImage) * 6 );

if ( images == NULL )
{
printf("Memory error. EXITING...\n");
exit( -1 );
}

for (int i = 0; i < 6 ; i++ ){

char *num = (char *)malloc( sizeof(int) );
char *extension = (char *)".jpg";
sprintf( num, "%d", i );

int nameLen = strlen( num ) + strlen( extension ) + 1;

char *imgName = (char *)malloc( nameLen );
strlcpy( imgName, num, nameLen );
strlcat( imgName, extension, nameLen );

images[i] = cvLoadImage( imgName, CV_LOAD_IMAGE_UNCHANGED );
}

free( images );

}

这是我得到的错误

    error: no match for ‘operator=’ in ‘images[i] = cvLoadImage
(((const char*)imgName), -0x00000000000000001)’
/opt/local/include/opencv2/core/types_c.h:463: note:
candidates are: _IplImage& _IplImage::operator=(const _IplImage&)

附注我正在使用i<6循环中因为 sizeof(images)/sizeof(images[0])给我 0。

非常感谢!

最佳答案

我假设这是一个 C++ 编译。函数调用返回一个 const 指针,并且您的数组不是 const 指针列表。

关于c - IplImage 的动态数组 - 与 ‘operator=’ 错误不匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17458068/

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