一個非常簡單的概念,我有一個640x480墊子和一個800x480屏幕,所以我試圖將原始圖像複製到黑色800x480圖像的中心,所以縱橫比保持不變,但整個屏幕都被使用。將cv :: Mat複製到另一個會創建「斷言失敗0 <= _colRange.start && ..」
我跟着this後,試圖兩種解決方案(直接複製到和感興趣的區域),並得到了同樣的錯誤:
OpenCV Error: Assertion failed (0 <= _colRange.start && _colRange.start <= _colRange.end && _colRange.end <= m.cols) in Mat, file /home/pi/opencv-3.0.0/modules/core/src/matrix.cpp, line 464
terminate called after throwing an instance of 'cv::Exception'
what(): /home/pi/opencv-3.0.0/modules/core/src/matrix.cpp:464: error: (-215) 0 <= _colRange.start && _colRange.start <= _colRange.end && _colRange.end <= m.cols in function Mat
Aborted
違規代碼:
cv::Mat displayimage = cv::Mat(800, 480, CV_16U, cv::Scalar(0));
modimage1.copyTo(displayimage.rowRange(1,480).colRange(81,720));
我第一次嘗試它(0,480)和(80,720)的開始/結束範圍/行,但是這個錯誤使得它聽起來好像不能從0開始,所以當然我認爲我已經1了,並且我從1開始結果。但實際上,錯誤是針對COLUMNS而不是針對ROWS的,而列關閉1的話甚至都無關緊要。那麼,我試圖將該圖像複製到哪裏,有什麼不喜歡的?
恕我直言,子圖像更容易CV ::矩形元素進行訪問。 – Micka