更新时间:2023-11-10 19:33:52
我对 cmake 并不满意,但是您似乎无法链接imwrite()
函数.
I am not best on cmake, but you appear to have failed to link the imwrite()
function.
我在Mac上,因此如果您在其他地方,则情况会有所不同,但是如果您在OpenCV库目录中查找,尤其是在libopencv_imgcodecs.dylib
中,如下所示:
I'm on a Mac so this will be different if you are elsewhere, but if you look in the OpenCV libraries directory, specifically in libopencv_imgcodecs.dylib
like this:
nm -gUP libopencv_imgcodecs.dylib | grep -i write
您将看到类似的内容:
__ZN2cv7imwriteERKNS_6StringERKNS_11_InputArrayERKNSt3__16vector...
这意味着imgcodecs
提供了您需要的功能.
That means that imgcodecs
provides the function you need.
我希望(感谢@ Ptaq666)能可靠地告知添加该库的***方法是使用:
I am, I hope (thanks to @Ptaq666), reliably informed that the best way of adding this library will be to use:
find_package(OpenCV 3 REQUIRED)
其次:
target_link_libraries(<as you already have> ${OpenCV_LIBRARIES})
原始建议
这意味着imgcodecs
提供了您需要的功能,因此我认为您需要将其添加到CMakeLists.txt
的此行中:
That means that imgcodecs
provides the function you need, so I think you need to add that into this line in your CMakeLists.txt
:
find_package(OpenCV 3 COMPONENTS core highgui imgproc REQUIRED)
我想那应该是这样的:
find_package(OpenCV 3 COMPONENTS core highgui imgproc imgcodecs REQUIRED)