2016-09-15 16 views
0

簡単な質問。私は解決策を見つけることができません!ベクトル乗算による行列

Mat dst = new Mat(); 
     Mat a = Mat.ones(3,3,CvType.CV_32FC1); 
     Mat b = Mat.ones(3,3,CvType.CV_32FC1); 
     Core.multiply(a, b, dst); 
     System.out.println("DST\n" + dst.dump()); 

しかし、これはエラーにつながる: これはokです

Mat dst = new Mat(); 

     Mat a = Mat.ones(3,3,CvType.CV_32FC1); 
     Mat b = Mat.ones(1,3,CvType.CV_32FC1); 

//neither this 
     Core.multiply(a, b, dst); ///<<<< ERROR 
//nor this works 
     Core.multiply(a, b.t(), dst); ///<<<< ERROR 
     System.out.println("DST\n" + dst.dump()); 

OpenCV Error: Sizes of input arguments do not match (The operation is neither 'array op array' (where arrays have the same size and the same number of channels), nor 'array op scalar', nor 'scalar op array') in cv::arithm_op, file C:\builds\master_PackSlaveAddon-win64-vc12-static\opencv\modules\core\src\arithm.cpp, line 1987

、解決策を見つけるために助けてください。どのようにしてベクトルで行列を作ることができますか?

+2

あなたはhttp://stackoverflow.com/questions/10168058/basic-matrix-muを見ましたか? opencv-for-androidでのltiplication? – SergeyS

+0

@ SergeyS、oh。ありがとう!それを見つけていない。 – Vyacheslav

答えて

0

私はopencvフレームワークを知りませんが、エラーメッセージに従って、2番目のコードサンプルのbは1行の行列のようです。あなたは、単一列の行列を必要とする:

は、次のように定義されたBをお試しください:

Mat b = Mat.ones(3,1,CvType.CV_32FC1); 
+0

これはb.t()と同じです。私はもう試した。 – Vyacheslav

+0

明らかにこの乗算方法は、1つの要素の乗算であり、探している行列の乗算ではありません。 –