Opencv错误:断言失败
Opencv Error:Assertion failed
我遇到以下问题-我试图运行以下代码,但遇到了这个问题:
OpenCV Error: Assertion failed (dims <= 2 && data && (unsigned)i0 < (unsigned)size.p[0] && (unsigned)(i1*DataType<_Tp>::channels) < (unsigned)(size.p[1]*channels()) && ((((sizeof(size_t)<<28)|0x8442211)
((DataType<_Tp>::depth) & ((1 << 3) - 1))*4) & 15) == elemSize1()) in unknown function, file C:opencv231buildincludeopencv2/core/mat.hpp, line 537.
代码:
int l = (int)Lines.size();
Mat sep_seam_map = Mat::zeros(n,l - 1, CV_32F);// initialize the seperating seam map of coordinates.
for (int k = 1; k < l - 1; k++){
//apply constrained seam carving for each pair of text lines:
int L_a = Lines[k].first.x;
int L_b = Lines[k + 1].first.x;
for (int row = 2; row < n; row++) {
for (int col = L_a; col < L_b; col++) {
//Defining the bounderies upon which to find the minimum value seams.
int left = std::max(col - 1, L_a);
int right = std::min(col + 1, L_b);
double minpath,max;
Mat last_row = energy_map.operator()(Range(row - 1, row), Range(left, right));
minMaxLoc(last_row, &minpath, &max);
std::cout << last_row << " " << " " << endl;
std::cout << "minpath: "<<minpath << " " << " " << endl;
//End Cases -
if (minpath == 0) {
if (col > left)
energy_map.at<float>(row, col) = energy_map.at<float>(row - 1, right);
if (col < right)
energy_map.at<float>(row, col) = energy_map.at<float>(row - 1, left);
}
else
std::cout << energy_map.at<float>(row, col) = energy_map.at<double>(row, col) + minpath;
}
}
我读过以前关于这个错误的讨论,这是访问矩阵条目时出错的结果,但我似乎没有做错什么(但很明显我做错了什么…)如果有任何帮助,我会非常乐意。当做
好吧,所以我访问矩阵条目时出错了——我应该使用uchar作为模板来编辑条目。
相关文章:
- 尝试使用 std::vector<std::thread时出现静态断言失败错误>
- uint_not_usable_without_attribute在业力规则中使用数字生成器时静态断言失败
- 从 exe 文件 (Visual Studio ) 启动时调试断言失败
- 断言"id < 0"在Qt ActiveX中失败
- 在 CppUnit 中测试中止断言失败
- 使用扫描的调试断言失败
- MS 本机单元测试 - 断言::线程失败不起作用
- 为什么我的Qt程序在断言失败后继续运行?
- 图片不显示,关闭时出错 --> 调试断言失败!表达式:is_block_type_valid(标头>_block_use)
- 访问提升:shared_ptr 主范围外崩溃,断言失败:px != 0.指针的正确用法是什么?
- C++ 调试断言失败 - 矢量下标超出视觉工作室的范围
- 错误:断言失败 (src.type() == CV_8UC1) 在阈值中
- Boost Beast 异步服务器失败,断言失败:(id_ != T::id) 在多个 aync 调用中
- 使用imwrite OpenCV时断言失败
- 调试断言失败的缓冲区!=nullptr
- 使用 ofstream 写入文本文件时断言失败
- OpenCV 错误:相机校准:断言在matrix_wrap.cpp失败
- 提升继续恢复断言失败
- 获取有关调试断言失败的错误:表达式:"(_Ptr_user &(_BIG_ALLOCATION_ALIGNMENT -1)) == 0" &&0
- 打破gdb中失败断言的正确方法是什么