在Java中编写“.shape”等价物

2024-09-30 16:22:26 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在将Python代码重写为Java代码(Android),但我不知道如何在图像上执行函数.shape

Python:

def getProcessedImage(srcImage):
image = copy.copy(srcImage) 
print ("image.shape"), image.shape 

r = 600.0 / image.shape[1]   
dim = (600, int(image.shape[0] * r)) 
print ("dimension ="), dim

爪哇:

public Mat getProcessedImage(srcImage) {
  Mat image = new Mat(srcImage);
  srcImage.copyTo(image);

  Object[] truple = new Object[Array.getLength(srcImage)] //Got stuck here and don't even think its correct 

  // Mat processedImage =.......
  return processedImage;
}

Tags: 代码图像imagenewobjectjavaandroidprint