gpt4 book ai didi

xcode - 如何让 chamerMatching 在 OSX 上工作?

转载 作者:太空宇宙 更新时间:2023-11-03 23:14:09 25 4
gpt4 key购买 nike

我正在尝试使用 OpenCV 的 chamferMatching 功能在 OSX 上工作,但收到有关尝试释放未分配对象失败的错误(据我所知):

fs(58697,0x100b3c000) malloc: *** error for object 0x103800000: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug

我发现很少有像这两个有用的帖子:

  1. chamerMatching malloc error
  2. debug assertion failed vc\include\vector vector iterator + offset out of range in chamferMatching Opencv

在 Ubuntu 上,只需编译 OpenCV 2.4.1从源代码并使用它就可以了。

虽然在 OSX 上同样没有工作。我还在 Matching 析构函数中注释掉了模板删除:

~Matching()
{
for (size_t i = 0; i<templates.size(); i++) {
// delete templates[i];
}
}

但没有快乐。

我什至尝试注释掉 chamfermatching.cpp 中的所有删除语句,但我仍然遇到同样的错误。

更新 我已经尝试使用 3 个不同版本的 g++ 重新编译 OpenCV 2.4.1:4.9、5 和 6,但出现链接错误。这是一个使用 g++ 5 编译的示例:

g++-5 ../fs.cpp -I/Users/George/Downloads/Grouped/cv/opencv-2.4.1/build/install/include/opencv -I/Users/George/Downloads/Grouped/cv/opencv-2.4.1/build/install/include -L/Users/George/Downloads/Grouped/cv/opencv-2.4.1/build/install/lib -lopencv_calib3d -lopencv_contrib -lopencv_core -lopencv_features2d -lopencv_flann -lopencv_gpu -lopencv_highgui -lopencv_imgproc -lopencv_legacy -lopencv_ml -lopencv_nonfree -lopencv_objdetect -lopencv_photo -lopencv_stitching -lopencv_video -lopencv_videostab -o fs
Undefined symbols for architecture x86_64:
"cv::chamerMatching(cv::Mat&, cv::Mat&, std::vector<std::vector<cv::Point_<int>, std::allocator<cv::Point_<int> > >, std::allocator<std::vector<cv::Point_<int>, std::allocator<cv::Point_<int> > > > >&, std::vector<float, std::allocator<float> >&, double, int, double, int, int, int, double, double, double, double)", referenced from:
_main in ccTJvcHd.o
"std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > cv::CommandLineParser::analyzeValue<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool)", referenced from:
std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > cv::CommandLineParser::get<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool) in ccTJvcHd.o
"cv::CommandLineParser::has(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)", referenced from:
std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > cv::CommandLineParser::get<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool) in ccTJvcHd.o
"cv::CommandLineParser::getString(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)", referenced from:
std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > cv::CommandLineParser::get<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool) in ccTJvcHd.o
"cv::imread(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)", referenced from:
_main in ccTJvcHd.o
"cv::imshow(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cv::_InputArray const&)", referenced from:
_main in ccTJvcHd.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status

我试过添加标志,例如 -std=c++11 然后是 -std=c++0x,但没有成功。

关于我如何解决这个问题的任何提示?

最佳答案

虽然很老套,但一个选项在 OSX 上有效(即使使用 OpenCV 2.4.13):删除已编译的 .dylib 并将未编译的 contrib 模块添加到项目中。

对于 OpenCV 2.4.1,只需注释掉 delete 语句即可。对于 OpenCV 2.4.13,我还必须注释掉两个 cvconfig.h 包含。

关于xcode - 如何让 chamerMatching 在 OSX 上工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43288875/

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