为了账号安全,请及时绑定邮箱和手机立即绑定

c++和python层之间的opencv.groupRectangles()差异

c++和python层之间的opencv.groupRectangles()差异

白猪掌柜的 2021-10-26 10:29:39
我正在尝试将 opencv 的调用groupRectangles()从 python转换为 c++,并且注意到 python 绑定的输出与 c++ 调用的输出不匹配。我已经编辑了下面的输出以反映在 ubuntu 18.04 上使用 opencv 3.2 重现这个库版本我在 Ubuntu 18.04 上运行 opencv。C++ 程序链接到 opencv 3.2.0(据 ldd 报告)。python 模块报告版本 3.2.0C++代码我编写了以下程序来获取一组 (x1, y1, x2, y2) 输入并将它们传递给groupRectangles()组阈值为 3 和 epsilon 为 0.02 的值。为了便于比较,输出以python的列表格式打印。#include <opencv2/opencv.hpp>#include <iostream>#include <vector>// display in python formatstd::ostream& operator<<(std::ostream& out, std::vector<cv::Rect>& rectangles){    out << '[';    for (auto i = 0u; i<rectangles.size(); ++i)    {        if (i)            out << ',';        out << '[' << rectangles[i].tl().x << ',' << rectangles[i].tl().y << ',' << rectangles[i].br().x << ',' << rectangles[i].br().y << ']';    }    return out << ']';}// inputs are x1,y1,x2,y2int main(){    std::vector<cv::Rect> candidates;    std::transform(std::begin(inputs), std::end(inputs), std::back_inserter(candidates),        [](const float coord[4]) {            return cv::Rect(cv::Point((int)coord[0], (int)coord[1]), cv::Point((int)coord[2], (int)coord[3]));         });    std::cout << "input:\n" << candidates << '\n';    std::vector<int> weights(candidates.size());    cv::groupRectangles(candidates, weights, 3, 0.02);     std::cout << "output:\n" << candidates << '\n';    return EXIT_SUCCESS;}这是我转换为cv::Rect,非确定性groupRectangles()或其他方面的问题吗?
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 260 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号