Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Video optimization for android - Part I
1. Intro to Android Video Optimization
Overview
This short summary is intended for C/C++ developers which haven’t worked with
Android before and would like to use Android for Signal, Image and Video processing
Applications.
Read ALL the instruction page before starting installations
Environment Setup
Goal: Understand how to use the Android development tools and Eclipse IDE.
Task: Install the tools and run an SDK sample from this list.
Choose a development OS (Windows / Linux /MAC) All builds and development should
be done on this OS.
Instructions for installation in http://developer.android.com/sdk/index.html download
both SDK and NDK (include installation of Eclipse, ADT and Phone USB driver).
Detailed instructions in the presentation.
Alternatively try performing installation according to OpenCV instructions below.
Working with ADB
Goal: Understand how to work with the ADB.
Task: Check the device is connected, pull and push files to/from the device and reset
the device.
ADB is the Android Debug Bridge, it assist developers in connecting and controlling the
device.
More on ADB commands in this wiki.
20 Giborey Israel, Sappir Industrial Park, Netanya, Israel | www.mobilevideotech.com
e-mail:info@dsp-ip.com | Telephone:+972.545.313092
2. Basic JNI compilation
Goal: Understand JNI and how to work with native C++ code.
Task: Compile and run a simple native application from the NDK samples, like the
“Hello-JNI”. Building NDK samples requires separate compilation of the C/C++ part and
the Java part. Understand the JNI mechanism.
Working with Camera
Goal: Understand how to work with the camera.
Task: Compile Run and understand “Sample 0”
Understand how to work with the camera try OpenCV samples for Android
Read more at OpenCV Android Pages .
OpenCV Android samples are run with C++ API while FastCV uses C API
Optimization for ARM
Goal: Understand optimization options for Android
There are several methods to optimize code for ARM:
1. Using already optimized functions distributed by SoC vendors, for example:
FastCV. More on FastCV Optimization in this slide.
2. Proprietary functions which don’t appear in such libraries require optimization
for VFU / NEON.
Task: earn more about NEON optimization review the “Hello-NEON” NDK sample.
20 Giborey Israel, Sappir Industrial Park, Netanya, Israel | www.mobilevideotech.com
e-mail:info@dsp-ip.com | Telephone:+972.545.313092
3. Working with SDCard
Prepare a RAW YUV video which is used to test the algorithm.
Copy the YUV input file to the SDCard using:
adb push <FileName.YUV> </SDCard/Path>
Get the output file from the device using:
adb pull “<Path>/<RawYUVOutFileName.yuv>” .
Use standard file operations to read frames from the file and pass them to image/video
processing mechanism:
FILE* MyInFile;
FILE* MyOutFile;
MyFile = fopen(“<Path>/<RawYUVInFileName.yuv>”, “rb”);
MyFile = fopen(“<Path>/<RawYUVOutFileName.yuv>”, “wb”);
Use standard fread / fwrite commands to manipulate the file
20 Giborey Israel, Sappir Industrial Park, Netanya, Israel | www.mobilevideotech.com
e-mail:info@dsp-ip.com | Telephone:+972.545.313092