gpt4 book ai didi

使用 ImageMagick MagickCore C API 比较图像

转载 作者:行者123 更新时间:2023-11-30 17:45:28 27 4
gpt4 key购买 nike

我试图找出两个图像的相似程度,但出现分割错误。我做错了什么?

ExceptionInfo     *exception;
Image *base_image, *reference_image, *composed_image, *image, *images, *images1;
double *similarity;
RectangleInfo offset;
ImageInfo *image_info, *image_info1;

char base_image_src[] = "jpgs/100000.jpg";
char reference_image_src[] = "jpgs/100000.jpg";

MagickCoreGenesis(NULL, MagickTrue);
exception = AcquireExceptionInfo();

image_info = CloneImageInfo((ImageInfo *) NULL);
(void) strcpy(image_info->filename, base_image_src);
base_image = ReadImage(image_info, exception);

image_info1 = CloneImageInfo((ImageInfo *) NULL);
(void) strcpy(image_info1->filename, reference_image_src);
reference_image = ReadImage(image_info1, exception);

offset.width = (unsigned int) 1200;
offset.height = (unsigned int) 1200;
offset.x = 0;
offset.y = 0;

composed_image = SimilarityImage(base_image, reference_image, &offset, similarity, exception);

编辑:我意识到它在相似性图像上崩溃了​​。来自/usr/lib64/libMagickCore.so.2的SimilarityImage()中的0x000000371dc5fdfa

最佳答案

在此示例中,我认为段错误/总线错误与相似度变量的双指针有关。与offset一样,在堆栈中声明它,并传递它的引用。

// From
double *similarity;
// To
double similarity;

// And from
composed_image = SimilarityImage(base_image, reference_image, &offset, similarity, exception);
// To
composed_image = SimilarityImage(base_image, reference_image, &offset, &similarity, exception);

或者分配 double

double  *similarity = (double *)malloc(sizeof(double));

关于使用 ImageMagick MagickCore C API 比较图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19625270/

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