【问题标题】:Assertion failed when trying to copy part of OpenCV Matrix尝试复制部分 OpenCV 矩阵时断言失败
【发布时间】:2016-01-16 13:34:01
【问题描述】:

我试图将 Mat 的一部分复制到其他矩阵,这是我的代码:

Mat OCRprocess;
OCRImage(Rect(plates[i].x, plates[i].y, plates[i].width, plates[i].height)).copyTo(OCRprocess);

ROI:x: 1200 y: 608 w: 356 h: 89(来自级联检测器的数据)

这是返回:

OpenCV 错误:断言失败 (0

【问题讨论】:

  • 我认为你只需要熟悉你的调试器...

标签: c++ opencv


【解决方案1】:

在调用copyTo之前,需要初始化矩形大小相同的OcrProcess

// Your rect
Rect r(plates[i].x, plates[i].y, plates[i].width, plates[i].height);
// Initialize the destination image
Mat OCRprocess(r.height, r.width, OCRImage.type());
// Copy
OCRImage(Rect).copyTo(OCRprocess);

或者,更简单地说,使用clone

Mat OCRprocess = OCRImage(Rect(plates[i].x, plates[i].y, plates[i].width, plates[i].height)).clone();

【讨论】:

  • 两个都测试过,还是一样的问题。
  • 那么您还有另一个问题:您的矩形超出了图像边界。
猜你喜欢
  • 2018-01-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-02-10
  • 2021-09-28
  • 1970-01-01
相关资源
最近更新 更多