2017-08-06 86 views
0

我想知道下面給出的Python numpy矩陣的Java Equivalent。訪問Java中的OpenCV Mat元素

輸出=矩陣[0] [0,:,:]

矩陣如下所示

[ [ [ [ 0.06240631 0.05016533 0.04039866 0.05481339]
[ 0.05615342 0.0268873 0.02446797 0.02856365]
[ 0.04960712 0.02596745 0.01981818 0.02116911]
[ 0.06562919 0.03579292 0.02395858 0.02714126] ] ] ]

和輸出如下所示

[ [ 0.06240631 0.05016533 0.04039866 0.05481339]
[ 0.05615342 0.0268873 0.02446797 0.02856365]
[ 0.04960712 0.02596745 0.01981818 0.02116911]
[ 0.06562919 0.03579292 0.02395858 0.02714126] ]

任何人都可以指導我正確的方向?

回答

0

看着你報告的數據:

  • 矩陣是一個4名維數組
  • 輸出是一個2名維數組

兩者在考慮這些假設,這是應該的對應於Java(使用大括號來初始化矩陣陣列):

double[][][][] matrix = {{{{0.06240631, 0.05016533, 0.04039866, 0.05481339}, 

      {0.05615342, 0.0268873, 0.02446797, 0.02856365}, 

      {0.04960712, 0.02596745, 0.01981818, 0.02116911}, 

      {0.06562919, 0.03579292, 0.02395858, 0.02714126}}}};  

double[][] output = matrix[0][0]; 

要測試output,可以使用以下行打印出來:

System.out.println(Arrays.deepToString(output));