我有以下代码,试图加载图像。但是Image构造函数抛出异常,我无法捕获它。
try {
Magick::Blob blob(&input_buffer_[0], input_buffer_.size());
Magick::Image image(blob);
int w = image.columns();
int h = image.rows();
input_mat_.create(h, w, CV_8UC3);
image.write(0, 0, w, h, "BGR", Magick::CharPixel, input_mat_.data);
} catch (...) {
return false;
}
#0 0x00007f9808d8a617 in raise () from /lib64/libc.so.6
No symbol table info available.
#1 0x00007f9808d8bd08 in abort () from /lib64/libc.so.6
No symbol table info available.
#2 0x00007f9808d83586 in __assert_fail_base () from /lib64/libc.so.6
No symbol table info available.
#3 0x00007f9808d83632 in __assert_fail () from /lib64/libc.so.6
No symbol table info available.
#4 0x00007f97f833badd in LockSemaphoreInfo (semaphore_info=<optimized out>) at MagickCore/semaphore.c:294
__PRETTY_FUNCTION__ = "LockSemaphoreInfo"
#5 0x00007f981fdacaa8 in Magick::throwException (exception_=exception_@entry=0x7f9278009aa0, quiet_=<optimized out>) at Magick++/lib/Exception.cpp:846
q = 0x0
message = {static npos = <optimized out>, _M_dataplus = {<std::allocator<char>> = {<__gnu_cxx::new_allocator<char>> = {<No data fields>}, <No data fields>},
_M_p = 0x7f927803aba8 "nginx"}}
p = <optimized out>
nestedException = 0x0
severity = <optimized out>
index = <optimized out>
#6 0x00007f981fdba21d in Magick::Image::read (this=0x7f97da6211b0, image=<optimized out>, exceptionInfo=0x7f9278009aa0) at Magick++/lib/Image.cpp:5047
No locals.
#7 0x00007f981fdba37f in Magick::Image::read (this=<optimized out>, blob_=...) at Magick++/lib/Image.cpp:3982
newImage = <optimized out>
exceptionInfo = <optimized out>
#8 0x00007f981fdba3c9 in Magick::Image::Image (this=0x7f97da6211b0, blob_=...) at Magick++/lib/Image.cpp:89
No locals.
ImageMagick版本:7.Q16HDRI
答案 0 :(得分:0)
艾伦的评论正确。 LockSemaphoreInfo
建议在读取图像之前未初始化ImageMagick。在程序启动时添加以下内容。
int main(int argc,char **argv) {
InitializeMagick(*argv); // <= Here