0

我试图找出两个图像有多相似,但我遇到了分割错误。我究竟做错了什么?

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);

编辑:我意识到它打破了 SimilarityImage。0x000000371dc5fdfa in SimilarityImage () from /usr/lib64/libMagickCore.so.2

4

1 回答 1

0

在这个例子中,我相信分段错误/总线错误与similarity变量的双指针有关。像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  *similarity = (double *)malloc(sizeof(double));
于 2013-12-23T18:57:47.260 回答