OpenCV错误:断言

时间:2017-12-06 03:58:02

标签: c++ opencv image-processing

Mat m1 = Mat(500, 300, CV_64F, Vec3b(255,255,255));
  for (int i = 0; i < m1.rows; ++i)
    for (int j = 0; j < m1.cols; ++j)
    {
        Vec3b color=m1.at<Vec3b>(Point(i, j));
    }
imshow("test2", m1);
waitKey();

变量颜色应该包含白色像素的颜色,但是当我运行代码时,我得到错误:

  

OpenCV错误:断言失败(((((sizeof(size_t)&lt;&lt; 28)| 0x8442211)&gt;&gt;   ((traits :: Depth&lt; _Tp&gt; :: value)&amp;((1 <&lt; 3) - 1))* 4)&amp; 15)==   elemSize1())在cv :: Mat :: at,file中   c:\ opencv \ build \ include \ opencv2 \ core \ mat.inl.hpp,第1118行

2 个答案:

答案 0 :(得分:0)

错误消息告诉您需要知道的内容。你已经走出界限了!

尝试:

Point(j, i)

列对应x。行对应y

答案 1 :(得分:-1)

尝试

aggregated_type_1 = PublishedRecordedActivity.objects.filter(
activity_type=1, published_details=publisheddetails__id).annotate(month=TruncMonth('timestamp_added')).values(
'month').annotate(sum_by_month=Count('month')).order_by('-timestamp_added')