Get Started with Computer Vision Applications Using Android Device
This example shows how to use the Simulink® Support Package for Android™ Devices to get started with computer vision applications on Android devices. The example also helps you get accustomed with the Android device driver blocks such as and Video Display.
Ensure that you install OpenCV version 4.5.2 from the Hardware Setup window.
For more information on how to use the Simulink Support Package for Android Devices to run a Simulink model on your Android device, see Getting Started with Android Devices.
Android device such as a phone or tablet
Connect your Android device to the host computer using the USB cable. Set up your Android device using the Hardware Setup. For more information, see Hardware Setup.
Configure Simulink Model and Calibrate Parameters
This example uses a preconfigured Simulink model from the Simulink Support Package for Android Devices.
To open the Simulink model, run this command in the MATLAB® Command Window.
An image is given as an input to the Simulation Image subsystem where its R, G, and B values are combined into a single matrix and further given as an input to the Algorithm area.
To change the input image in the Simulation Image subsystem, on the Modeling tab of the Simulink model, in the Design section, click Model Explorer.
In the Model Explorer window, in the Model Hierarchy pane, select the name of the Simulink model and expand the down arrow. Select Model Workspace.
In the Content of: Model Workspace pane, select RGB_image.
In the Data properties: RGB_image pane, enter the path of the simulation input image in this format:
imresize(imread('Your own image path\image.jpg'), [resize value]);. For example,
imresize(imread(matlabroot,'C:\Users\Pictures\image021.jpg'), [384, 512, 3]);.
Click Apply and close the window.
Use the block to capture video using your Android device. This block is configured to its default parameters. The R, G, and B components of the video are concatenated into a single image matrix and further given as an input to the Algorithm area.
Display and Visualization
image_display function in the MATLAB Function block displays the input image fed through the Simulation Sources area.
In the deployment mode, use the Video Display block to display the output image on your Android device.
Run Simulink Model
In the Algorithm area of the Simulink model, position the Manual Switch to receive output from the Simulation Sources area.
On the Simulation tab of the Simulink model, click Run. Observe the simulation output on the figure window.
Deploy Simulink Model on Android Device
1. In the Algorithm area of the Simulink model, position the Manual Switch to receive output from the Simulation Sources area.
2. On the Hardware tab of the Simulink model, in the Mode section, click
Run on board. In the Deploy section, click Build, Deploy & Start. The androidVisionGettingStarted application launches automatically on your Android device. On the App tab of the application, observe the input image that you set in the Model Explorer window.
1. In the Algorithm area of the Simulink model, position the Manual Switch to receive output from the Android Inputs area.
2. Redeploy the Simulink model on your Android device. On the App tab of the application, observe the live camera feed output on your Android device.
Implement Histogram Equalization and Median Filtering on Images Using Android Device
Detect and Match Local Features Between Image Frames Using Android Device