簡體   English   中英

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:\opencv231\build\include\opencv2/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作為模板來編輯條目。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM