Pass matlab javaArray(​'java.lang​.Integer',​Length) as "java method input: int[]" to be filled in the method failed

조회 수: 1 (최근 30일)
In java/C#/C++ method, there is a way to input a empty array as one argument in, and the method can fill this array, which could be used then.
Here I have a try in java-Matlab to see if this is feasible using a demo: read a jpg pixel value array using java command from Matlab environment:
filepath = 'C:\.....jpg';
aBufferedImage = javax.imageio.ImageIO.read(java.io.File(filepath));
aContainerJavaArr = javaArray('java.lang.Integer',aWidth*aHeight); % the aWidth and aHeight is the known width and height of the jpg file.
% then use empty aContainerJavaArr as input to the method getRGB, to let it be filled with true pixel RGB color values
aBufferedImage.getRGB(0,0,aWidth,aHeight,aContainerJavaArr,0,aWidth);
No method 'getRGB' with matching signature found for class 'java.awt.image.BufferedImage'.
The argin list is :int,int,int,int,int[],int,int. So I convert all the argument to java.lang.Integer(), but the error is still same.
aBufferedImage.getRGB(java.lang.Integer(0),java.lang.Integer(0),...
java.lang.Integer(aWidth),java.lang.Integer(aHeight),aContainerJavaArr,java.lang.Integer(0),java.lang.Integer(aWidth));
Why the javaArray('java.lang.Integer',...) cannot be used in this manner?
Thanks.

채택된 답변

raym
raym 2020년 8월 6일
I find an answer here.
https://www.mathworks.com/matlabcentral/answers/94559-why-do-i-receive-an-error-when-i-call-the-read-method-of-the-fileinputstream-in-matlab

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Call Java from MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by