You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

读取多页TIFF到Mat向量后程序Aborted终止问题排查

OpenCV读取TIFF后程序退出时Aborted终止问题

以下代码可完成TIFF文件读取功能,但程序退出时会触发Aborted (core dumped)错误:

#include <opencv2/core/mat.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/imgcodecs/imgcodecs.hpp>
#include <opencv2/highgui.hpp>
#include <iostream>
#include <vector>

using namespace cv;
using namespace std;

int main( int argc, char** argv){
    vector<Mat> mats;
    imreadmulti( argv[ 1], mats, 0, 1, -1);
    cout << "sz = " << mats.size() << endl; 
}

编译运行后输出如下:

$ g++ main.cpp -o ../bin/main -L/ucrt64/lib $(pkg-config --cflags --libs opencv4); ../bin/main data.tiff
sz = 1
Aborted (core dumped)

环境配置信息

$ g++ --version
g++ (GCC) 13.2.0
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ uname
MINGW64_NT-10.0-19045

$ echo $MSYSTEM
UCRT64

$ echo $MSYSTEM_CARCH 
x86_64

$ pacman -Qs opencv
local/mingw-w64-ucrt-x86_64-opencv 4.9.0-4
    Open Source Computer Vision Library (mingw-w64)

已完成的排查动作

  • 简化代码后问题复现,确认与TIFF文件大小无关(测试时仅读取单页,原文件共2146页,每页1MB)
  • 读取操作实际成功,甚至可通过imwritemulti将读取到的内容写入新文件,但程序退出阶段仍会触发终止错误

内容的提问来源于stack exchange,提问作者thatsme

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.01 19:03:11