我一直在努力與opencv項目中的一些斷言。OpenCV C++ Assertion
首先,我將墊對象,以確保他們的類型:
gray_im.convertTo(gray_im, CV_8U);
diff_im.convertTo(diff_im, CV_8U);
然後我做了減法。這條線路是在那裏我得到斷言:
diff_im = gray_im - prev_im;
這裏是斷言:
OpenCV Error: Bad argument (When the input arrays in add/subtract/multiply/divide functions have different types, the output array type must be explicitly specified) in arithm_op, file /build/buildd/opencv-2.4.8+dfsg1/modules/core/src/arithm.cpp, line 1313
當我打印信息約我使用減法圖像;
diff_im. type: 5 rows: 600 cols 800
gray_im. type: 5 rows: 600 cols 800
prev_im. type: 0 rows: 600 cols 800
我認爲我明確指定輸出數組(如果我是正確的,這裏diff_im是輸出數組,對吧?),通過將其轉換爲CV_8U。另外當我在運行時打印diff_im的類型信息時,它說它是「5」,這意味着我明確指定了「diff_im」的類型。
我錯了嗎?有什麼建議麼?
OpenCV版本:2.4.8 在此先感謝。
但是斷言說**當添加的輸入數組/減/乘/除功能有不同的類型,輸出數組類型必須明確指定* *,這意味着(我認爲)**我可以處理不同類型的輸入,但在這種情況下,您必須指定我將寫入的類型。如果我是正確的,在這種情況下,輸出是diff_im,並且它的類型是明確指定的(在本例中爲5)。對? –
請在上面找到我的更新#1 – Kornel
好的,我會試一試。將在今天結束時讓你知道結果。另外,是否有任何理由不經意地改變圖像類型? –