我想製作一個程序,它從兩張相同的圖片找到齊次座標,但是對象已經被旋轉或翻譯,然後取第一張圖片並覆蓋第二張圖片圖片。Substracting不同大小的兩個矩陣,OpenCV錯誤
問題是,我得到一個矩陣錯誤,因爲我有不同的矩陣大小。
我已經找到了解決方案,我需要應用旋轉和平移獲得第二的第一張照片(該值,我需要去申請第二矩陣)
這是我的代碼:
Size size(image2.cols, image2.rows);
Mat dest = cv::Mat::zeros(image2.rows, image2.cols, CV_32FC2);
warpAffine(image2, dest, t, size);
namedWindow("manipulated img", CV_WINDOW_NORMAL);
imshow("manipulated img", dest);
Mat output;
cout << image1.size() << endl;
cout << dest.size() << endl;
bitwise_and(dest, image1, output);
//subtract(dest, image1, output);
namedWindow("output img", CV_WINDOW_NORMAL);
imshow("output img", output);
我得到以下錯誤:
> [3722 x 2937]
> [3722 x 2932]
> OpenCV Error: Sizes of input arguments do
> not match (The operation is neither 'a rray op array' (where arrays
> have the same size and type), nor 'array op scalar' , nor 'scalar op
> array') in cv::binary_op, file C:\builds\master_PackSlave-win32
> -vc12-shared\opencv\modules\core\src\arithm.cpp, line 1573
我想我知道問題是什麼,但我不知道該解決方案是什麼。
矩陣具有不同的尺寸
image1.size() = [3722 x 2937]
dest.size() = [3722 x 2932]
我能做些什麼,來解決這個問題?
你想如何在不同大小的矩陣之間進行位移?這在理論上是不可能的 –
哦,我忘了提及,我也試圖減去每個圖像。有什麼方法可以「添加」像素嗎? – larsen