Why actual resolution of the image from Simulink Android camera is different from the resolution set on the camera block ?
4 views (last 30 days)
I am working on a project to acquire Android camera image from an Android app developed with Simulink support package from Android devices. I am using Samsung galaxy S10, which was supported for the development. I set the resolution in the camera block as 1920x1080. After that using .MAT file logging, I have imported the recorded camera frames to MATLAB workspace. The actual resolution in the image seems to be 640x480. As you can see in the attached image, the overall frame is 1920x1080 but the acutal camera output is ~640x480. For reference I am also attaching the model. Please let me know how to solve this issue.
%% Code to access .MAT files logged from the Simulink phone application
%% Copy the MAT-files from the Android device into MATLAB
% results = displays the status of copy operation
% matfiles = displays the list of the MAT-files copied to MATLAB
% input the Simulink model name "getFiles"
[result, matfiles] = codertarget.android.internal.getFiles('octSignalLogging')
%% Load the variables in the MAT-file into MATLAB workspace variables
% load the specific .MAT files
OCTSignal = load('octSignalLogging_2_1.mat');
OCTSignal = OCTSignal.rt_interferogram;
OCTSignal = mean(OCTSignal,3);
Sutanu Maiti on 17 May 2022
This has been noticed and we have found that this behavior is due to Android itself. The camera frame we receive is equal to the that of its preview size on screen. Even though we request a particular frame size, if the previewed size on the screen is lesser than that, then only the preview size is returned. And this restriction is applied from OS (Operating System) to increase security and privacy.
One workaround could be to increase the camera size on the application. You may import the generated code into android studio and modify that to maximize the camera preview size.