Dish Recognition SDK (Standalone Offline Edition) API Reference
Version: v1.0.0 | Build date: 2026-11-13 | Architecture: arm64-v8a (RK3566 / RK3576 / RK3588 and other RKNN platforms)
Artifact:sdk-release.aar(built-in YOLO detection model + CLIP image model + object tracking + offline activation-code gating)
This release is a pure offline standalone edition: it contains no gateway authentication, WebSocket, HTTP communication, cloud training submission, online model/feature download, version rollback or online AI matting. All inference, category features, samples and license state are kept on the device and work with the network disconnected.
1. Overview
This SDK packages the core inference capabilities of the original Android project as an AAR library for direct integration by third-party apps. Capabilities:
| Capability | Description |
|---|---|
| YOLO object detection | RKNN (NPU) inference returning boxes, classes and confidence; model best.rknn is bundled |
| CLIP image classification | On-device CLIP model extracts normalized features from the detection crop and compares them with the local category library; model clip_vision_finetuned.rknn is bundled |
| Object tracking | Multi-object tracking (track id) to stabilize detections |
| Category / exclusion management | Positive categories and exclusions (negative samples) persisted locally (bin + json) |
| Offline activation gating | Activation state persisted locally; when not activated the models refuse to initialize and inference is blocked |
1.1 Package structure (com.rockchip.gpadc.demo)
com.rockchip.gpadc.demo
├── ClipHelper # High-level CLIP recognition wrapper (recommended entry)
├── ClipHelper$Result # Recognition result {clsName, score, isNegative}
├── clip.ClipInferenceWrapper # Low-level CLIP RKNN image/text model wrapper
├── yolo.InferenceWrapper # YOLO RKNN detection wrapper (singleton)
├── yolo.PostProcess # Detection post-processing / label loading
├── tracker.ObjectTracker # Multi-object tracking
├── InferenceResult # Inference result container (OutputBuffer / Recognition / DetectResultGroup)
├── DetectionResult # Parcelable detection result (cross-process)
├── ImageBufferQueue # NPU image buffer queue
├── rga.RGA # RGA hardware-accelerated color conversion
├── rga.HALDefine # Format and resolution constants
└── license.LicenseManager # Offline activation state management and gating Note: the whole licensing loop lives inside the SDK — device identifier generation, local activation-code verification (device-bound MD5 digest, start/end validity window, clock rollback protection), activation state persistence and inference gating are all provided by LicenseManager. It never accesses the network and integrators do not need to implement the verification algorithm themselves.1.2 Bundled models and assets (assets/)
| File | Type | Size | Description |
|---|---|---|---|
clip_vision_finetuned.rknn | CLIP image model | ~175 MB | 512-dim normalized image feature extraction |
best.rknn | YOLO detection model | ~10 MB | NPU object detection (single class: food) |
text_features.bin | CLIP text features | ~6 KB | Precomputed category text features (used by default, no on-device text model needed) |
categories.json | Category mapping | <1 KB | Initial category mapping |
coco_80_labels_list.txt | Labels | <1 KB | YOLO class labels |
tokenizer/merges.txt, tokenizer/vocab.json | Vocabulary | ~1.3 MB | CLIP text tokenizer |
1.3 Native libraries (jni/arm64-v8a/)
| .so file | Size | Description |
|---|---|---|
librknn4j.so | ~66 KB | JNI core of this SDK, compiled from C++ sources with CMake |
librknnrt.so | ~7.6 MB | RKNN Runtime |
librga.so | ~1.1 MB | RGA hardware 2D acceleration |
libopencv_java3.so | ~17.1 MB | OpenCV |
Packing the two models plus the native libraries yields an AAR of about 169 MB, so the host app does not need to download or store model files separately.
2. Integration
2.1 Adding the AAR
Copy sdk-release.aar into the host project's app/libs/ directory and add the following to app/build.gradle:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
// The SDK exposes Gson through api (category/feature file IO), so do not add it again
implementation 'com.google.code.gson:gson:2.10.1'
}This SDK does not depend on OkHttp, Socket.IO or any other network library; do not leave network dependencies from the old online edition in the host app.
2.2 Permissions
The AAR's AndroidManifest.xml declares the following permissions, which are merged automatically (no INTERNET, ACCESS_NETWORK_STATE):
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" tools:ignore="ScopedStorage" />The host must still request the camera permission at runtime (Android 6.0+):
if (checkSelfPermission(Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
requestPermissions(new String[]{Manifest.permission.CAMERA}, 1);
}2.3 Hardware and system requirements
- An RKNN-capable arm64-v8a device (RK3566 / RK3576 / RK3588 etc.) with the NPU driver available; ordinary emulators have no NPU and cannot run inference.
- minSdk 25, targetSdk 33, compileSdk 33, Java 8 compatible.
3. Activation Code License (LicenseManager)
Prerequisite: local activation must be completed before calling inference APIs. When not activated,ClipHelper.initVisionModel()returnsfalse, andInferenceWrapper.initModel()/initModelFromAssets()throwLicenseNotActivatedException.
Package: com.rockchip.gpadc.demo.license.LicenseManager
3.1 How the licensing loop works
- SDK (LicenseManager): generates/reads the device identifier, verifies the activation code locally (device binding, MD5 digest, validity window, rollback protection), writes the activation state and gates the inference entry points. Everything is stored in the device's SharedPreferences; no network access.
- Host app: shows the activation page, collects the user-entered code and calls
verifyAndActivate(...)to verify and activate. You do not need to implement the MD5 / validity / rollback algorithms yourself. - Gating: when not activated, CLIP
initVisionModel()returnsfalseand YOLOinitModelFromAssets()/initModel()throwLicenseNotActivatedException; models are not loaded.
3.2 Core APIs
Package: com.rockchip.gpadc.demo.license.LicenseManager
| Method | Description |
|---|---|
static String getDeviceId(Context ctx) | Returns the unique device identifier. It reuses a locally persisted ID first; otherwise it takes the Android ID (generating a UUID when unavailable or when it is the emulator default), appends a 3-character random uppercase suffix in the form android_<androidId><XXX> and persists it. |
static boolean isActivated(Context ctx) | Synchronously reads the local activation state (no network). |
static String getActivationCode(Context ctx) | Returns the locally saved activation code, or an empty string when not activated. |
static String getExpireTime(Context ctx) | Returns the expiry display string; empty means permanent (display only). |
static boolean verifyOffline(Context ctx, String code, StringBuilder errMsg) | Verifies the activation code locally without writing state. Returns true on success; the reason/message is written to errMsg. |
static void verifyAndActivate(Context ctx, String code, LicenseCallback cb) | Recommended entry: calls verifyOffline first, then writes the activation state and updates the rollback record on success; failures invoke onFailure, success invokes onSuccess. |
static void activateOffline(Context ctx, String code, String expireTime, LicenseCallback cb) | Low-level state write without validating the code. Use only when the host has already validated it; prefer verifyAndActivate in normal scenarios. |
static boolean checkTimeRollback(Context ctx) | Checks whether the system clock has been rolled back into an invalidated interval (5-minute tolerance). |
static void recordMaxWallIfValid(Context ctx) | Updates the historical maximum wall-clock time when the current time is valid and not expired; call it in onResume or a scheduled task. |
static String decodeActivationSpan(Context ctx, String code) | Parses and returns the start/end time, valid days and current status as a display string; returns null for an invalid format. |
static void assertActivated(Context ctx) | Gating check: throws LicenseNotActivatedException when not activated. The SDK calls it automatically during model initialization, so hosts normally need not call it explicitly. |
static void resetDevice(Context ctx) | Clears the activation code, rollback record and persisted device ID (the UNLOCK- reset flow) and regenerates the device identifier afterwards. |
static void clearActivation(Context ctx) | Clears the local activation state while keeping the device ID (for code replacement / sign-out). |
Callback interface:
LicenseManager.LicenseCallback cb = new LicenseManager.LicenseCallback() {
@Override public void onSuccess(String msg) { /* Activated, go to the home screen */ }
@Override public void onFailure(String errMsg) { /* Show the error message */ }
};Exception class: LicenseManager.LicenseNotActivatedException extends IllegalStateException, thrown by the inference entry points when not activated; the host can catch it and redirect to the activation page.
3.3 Activation code structure and rules
24-character hexadecimal activation code (after removing hyphens/spaces and lowercasing):
| Position | Content |
|---|---|
| Chars 1–16 | Verification digest: first 16 characters of MD5(last 5 chars of device ID + start date hex + end date hex) |
| Chars 17–20 | Activation start date (hex day number, starting at 00:00 Beijing time) |
| Chars 21–24 | End date (hex day number, through 23:59:59 of that day) |
- Device binding: the digest is valid only for the bound device; the same code fails verification on a different device.
- Validity window: if the current time is earlier than the start date the window has not started; if later than the end date the code has expired.
- Rollback protection: the maximum historical system time is recorded; if that time is already past the end date, the code is treated as void, preventing bypassing the window by clock rollback.
Reset code (UNLOCK- prefix): in this project it is used to clear activation records and reset the device identifier (resetDevice); it is not a code that grants access directly.
The above verification is performed inside the SDK. If you generate valid activation codes on the issuing side, the digest algorithm, time zone (UTC+8) and device identifier rules must match this section.
3.4 Minimal integration example
import com.rockchip.gpadc.demo.license.LicenseManager;
import com.rockchip.gpadc.demo.license.LicenseManager.LicenseCallback;
// 1) Already activated? Use it directly
if (LicenseManager.isActivated(this)) {
goToMainPage();
} else {
// 2) Show the activation page; the SDK verifies and persists the entered code locally
LicenseManager.verifyAndActivate(this, editTextCode.getText().toString().trim(),
new LicenseCallback() {
@Override public void onSuccess(String msg) { goToMainPage(); }
@Override public void onFailure(String err) {
Toast.makeText(MainActivity.this, err, Toast.LENGTH_LONG).show();
}
});
}
// 3) Initialize inference after entering the home screen (gating now passes)
ClipHelper clip = ClipHelper.getInstance(this);
InferenceWrapper.getInstance().initModelFromAssets(this, 640, 640, 3);Add one rollback-record refresh in onResume or a scheduled task:
LicenseManager.recordMaxWallIfValid(this);3.5 FAQ
| Symptom | Cause | Resolution |
|---|---|---|
LicenseNotActivatedException | Inference initialized/called before activation | Call verifyAndActivate to complete local activation first |
| "Device mismatch or tampered" | Last 5 characters of the device ID do not match the digest, or the code was modified | Check that the device ID and activation code correspond |
| "Activation window not started / expired" | Current time is outside the start/end window | Check the date segment of the code and the device system time |
| "Void (historical time exceeded)" | The rollback record shows the end date was exceeded before | Contact the issuer for a new code, or use the reset flow |
getDeviceId changes | resetDevice was executed, or the device was replaced / factory reset | Issue a new activation code for the new device |
4. CLIP Recognition (ClipHelper)
Prerequisite: activation completed (see section 3). When not activated,initVisionModel()returnsfalseandisReady()isfalse.
CLIP recognition is image classification: given a Bitmap cropped from a detection box, it returns the best-matching category in the local category library.
4.1 Initialization (singleton)
import com.rockchip.gpadc.demo.ClipHelper;
ClipHelper clipHelper = ClipHelper.getInstance(context);
// Internally: copies clip_vision_finetuned.rknn to the cache and loads text_features.bin / categories.json
boolean ready = clipHelper.isReady();| Method | Description |
|---|---|
static ClipHelper getInstance(Context context) | Returns the global singleton; the first call runs initVisionModel() and is slow (model loading). |
static void resetInstance() | Resets the singleton and clears static caches (categories, exclusions, stability cache). |
boolean initVisionModel() | Initializes the vision model; returns false when not activated. |
boolean isReady() | Whether the model is ready. |
boolean reloadModels() / void reloadFeatures() | Reload models / feature cache. |
4.2 Image feature extraction
float[] feature = clipHelper.extractImageFeature(bitmap); // Returns a 512-dim normalized feature, or null on failure4.3 Classification (core API)
// Simple classification
ClipHelper.Result r = clipHelper.clipClassify(cropBitmap);
// With position (pass the normalized target box for position filtering)
ClipHelper.Result r = clipHelper.clipClassify(cropBitmap, rectF);
// With trackId (enables stabilization: output only after consistent results across frames)
ClipHelper.Result r = clipHelper.clipClassify(cropBitmap, rectF, trackId);ClipHelper.Result:
| Field | Type | Description |
|---|---|---|
clsName | String | Category name; null means an exclusion matched; "ignore" means below threshold; "failed" means failure |
score | float | Similarity score (0–1, normalized cosine similarity) |
isNegative | boolean | true = the result should be ignored (exclusion / below threshold); the UI should filter it and draw no box |
4.4 Category / exclusion management
// Add a category (feature is 512-dim; pass null to generate a placeholder feature)
boolean ok = clipHelper.addTextCategory("Braised pork", false, feature); // positive sample
boolean ok2 = clipHelper.addTextCategory("Plate", true, null); // exclusion
// Delete / toggle exclusion state
clipHelper.removeCategory("Braised pork");
clipHelper.toggleExcludeStatus("Plate"); // positive <-> exclusion
// Query
Map<String, Boolean> all = clipHelper.getAllCategories(); // label -> isExclude
Map<String, Boolean> pos = clipHelper.getPositiveCategories();
Map<String, Boolean> map = clipHelper.getCategoryMap();
List<String> excludes = clipHelper.getExcludeList();
boolean isExclude = clipHelper.isExclude("Plate");
float[] feat = clipHelper.getFeature("Braised pork");
int count = clipHelper.getCategoryCount();
float[] placeholder = clipHelper.generatePlaceholderFeature("New category");| Method | Description |
|---|---|
addTextCategory(String label, boolean isExclude, float[] feature) | Adds a category; isExclude=true marks it as an exclusion. |
removeCategory(String label) | Deletes a category. |
toggleExcludeStatus(String label) | Switches between positive sample and exclusion. |
getAllCategories() / getPositiveCategories() / getCategoryMap() | All / positive-only / category map (label -> excluded). |
getExcludeList() / isExclude(String) | Exclusion list / whether a label is an exclusion. |
getFeature(String label) / getCategoryCount() | Category feature / total category count. |
4.5 Persistence and local loading
// Write locally: filesDir/text_features.bin + categories.json
clipHelper.saveFeaturesToFile();
// Load / refresh from local files
clipHelper.loadCategoriesFromFiles();
clipHelper.refreshCategoriesFromFiles();
clipHelper.forceReloadFeatures();
clipHelper.reloadFeatures();4.6 Threshold and stabilization
float threshold = clipHelper.getThreshold(); // Default 0.6
clipHelper.setThreshold(0.65f); // Range 0.3 ~ 0.9
clipHelper.clearStableCache(trackId); // Clear the stability cache for one target
clipHelper.clearAllStableCache(); // Clear all stability caches4.7 Release
clipHelper.release(); // Releases the image model and stability cache (call resetInstance to null the singleton)5. YOLO Object Detection (InferenceWrapper)
Prerequisite: activation completed. When not activated,initModelFromAssets()throwsLicenseNotActivatedExceptionand the model is not loaded.
The YOLO model best.rknn is bundled in the AAR and supports two initialization approaches. Singleton.
5.1 Initialization
Option 1 (recommended): load from the AAR assets
import com.rockchip.gpadc.demo.yolo.InferenceWrapper;
InferenceWrapper yolo = InferenceWrapper.getInstance();
// Automatically copies assets/best.rknn to the cache and initializes
yolo.initModelFromAssets(context, 640, 640, 3);
boolean ready = yolo.isInitialized();Option 2: host supplies a custom model path
InferenceWrapper yolo = InferenceWrapper.getInstance();
yolo.initModel(640, 640, 3, "/data/user/0/" + context.getPackageName() + "/files/best.rknn");initModelFromAssets(Context, im_height, im_width, im_channel): automatically copiesbest.rknntocontext.getCacheDir()/best.rknnand reuses it when the cached file already exists and is larger than 1 MB; then callsinitModel()to finish NPU initialization. Returns 0 on success and non-zero on failure; throwsLicenseNotActivatedExceptionwhen not activated.
5.2 Inference
run takes an NPU image buffer handle (from ImageBufferQueue) and returns the raw outputs of the three grid scales:
ImageBufferQueue queue = new ImageBufferQueue(3, previewW, previewH);
ImageBufferQueue.ImageBuffer buf = queue.getFreeBuffer();
// ... convert the camera frame through RGA into the NPU buffer (see section 8)
InferenceResult.OutputBuffer out = yolo.run(buf.mImage_handle, previewW, previewH);5.3 Post-processing
ArrayList<InferenceResult.Recognition> list = yolo.postProcess(out);5.4 Release
yolo.deinit();6. Inference Result Containers (InferenceResult)
6.1 Recognition
| Method | Description |
|---|---|
int getId() | Class id |
Float getConfidence() | Confidence (0–1) |
RectF getLocation() | Normalized target box (0–1, returns a copy) |
int getTrackId() | Track id |
void setLocation(RectF) / void setTrackId(int) | Set coordinates / track id |
6.2 OutputBuffer
| Field | Type | Description |
|---|---|---|
mGrid0Out / mGrid1Out / mGrid2Out | byte[] | Raw outputs of the three YOLO scales |
floatOutput | float[] | CLIP image feature output (512-dim) |
6.3 DetectResultGroup
Grouped result container with fields: count, ids[], scores[], boxes[].
6.4 DetectionResult (Parcelable, cross-process)
| Field | Type | Description |
|---|---|---|
id | int | Class id |
confidence | float | Confidence |
left / top / right / bottom | float | Normalized coordinates |
trackId | int | Track id |
label | String | Category name |
7. Object Tracking (ObjectTracker)
import com.rockchip.gpadc.demo.tracker.ObjectTracker;
ObjectTracker tracker = new ObjectTracker(previewWidth, previewHeight, maxTrackLifetime /* e.g. 4 */);
ArrayList<InferenceResult.Recognition> tracked = tracker.tracker(recognitions);
// Each returned Recognition carries a trackId and normalized coordinates| Method | Description |
|---|---|
ObjectTracker(int width, int height, int maxTrackLifetime) | Constructor: preview width/height and maximum number of frames a track survives. |
ArrayList<Recognition> tracker(ArrayList<Recognition> recognitions) | Assigns/continues track ids for detections and returns them. |
8. NPU Image Buffers (ImageBufferQueue)
Allocates/reuses NPU image buffers (targets of RGA conversion).
ImageBufferQueue queue = new ImageBufferQueue(3, width, height);
ImageBufferQueue.ImageBuffer buf = queue.getFreeBuffer(); // Take a free buffer
queue.postBuffer(buf); // Mark ready after filling
ImageBufferQueue.ImageBuffer ready = queue.getReadyBuffer(); // Take a ready buffer for inference
queue.releaseBuffer(ready); // Release after use
queue.release(); // Release everything (onDestroy)| Method / field | Description |
|---|---|
static boolean isNPUAvailable() | Whether the NPU is available (static). |
boolean isNpuAvailable() | Instance-level NPU availability check. |
ImageBuffer getFreeBuffer() | Takes a free buffer. |
void postBuffer(ImageBuffer) | Marks a filled buffer as ready. |
ImageBuffer getReadyBuffer() | Takes a ready buffer. |
void releaseBuffer(ImageBuffer) | Returns a single buffer. |
void release() | Releases all buffers. |
ImageBuffer.mImage_handle | NPU buffer handle (passed to InferenceWrapper.run / RGA.colorConvertAndFlip). |
ImageBuffer.mStatus / mWidth / mHeight / mBufferSize | Status / width / height / buffer size. |
9. RGA Color Conversion (RGA / HALDefine)
import com.rockchip.gpadc.demo.rga.RGA;
import static com.rockchip.gpadc.demo.rga.HALDefine.*;
// Convert an NV21/RGBA camera frame into the NPU buffer, optionally flipping horizontally
int ret = RGA.colorConvertAndFlip(srcBytes, RK_FORMAT_YCrCb_420_SP,
npuBuffer.mImage_handle, RK_FORMAT_RGB_888, width, height, IM_HAL_TRANSFORM_FLIP_H);
// Returns 0 on successRGA.colorConvertAndFlip(byte[] src, int srcFmt, long npuBufHandle, int dstFmt, int w, int h, int flip) is a static method.
Common format constants (HALDefine):
| Constant | Description |
|---|---|
RK_FORMAT_RGBA_8888 | RGBA |
RK_FORMAT_RGB_888 | RGB |
RK_FORMAT_YCrCb_420_SP | NV21 |
IM_HAL_TRANSFORM_FLIP_H | Horizontal flip |
10. Low-level CLIP Wrapper (ClipInferenceWrapper)
The high-level ClipHelper already wraps the common flow; to call the low-level RKNN models directly, use:
| Method | Description |
|---|---|
boolean initModel(int h, int w, int c, String modelPath) | Initializes the CLIP image model. |
InferenceResult.OutputBuffer runRawRgb(byte[] rgbData, int w, int h) | Runs image inference on RGB data. |
void deinitImage() | Releases the image model. |
boolean initTextModel(int seqLen, String modelPath) | Initializes the text model (normally unused; the precomputed text_features.bin is used by default). |
float[] runTextToken(int[] tokenIds, int[] attnMask) | Text token inference. |
void deinitText() | Releases the text model. |
11. Complete Example (YOLO detection + CLIP recognition)
public class Demo {
private InferenceWrapper mYolo;
private ClipHelper mClip;
private ImageBufferQueue mQueue;
private ObjectTracker mTracker;
public void init(Context context) {
// 0. Confirm activation (otherwise the following initializations are gated)
if (!LicenseManager.isActivated(context)) {
throw new IllegalStateException("Not activated; complete activation first");
}
// 1. Initialize YOLO (load best.rknn from the bundled assets)
mYolo = InferenceWrapper.getInstance();
mYolo.initModelFromAssets(context, 640, 640, 3);
// 2. Initialize CLIP (the singleton loads the bundled model and features)
mClip = ClipHelper.getInstance(context);
// 3. NPU buffers and tracker
mQueue = new ImageBufferQueue(3, 1024, 768);
mTracker = new ObjectTracker(1024, 768, 4);
}
public void onFrame(byte[] nv21, int w, int h) {
// 4. Color conversion into the NPU buffer
ImageBufferQueue.ImageBuffer buf = mQueue.getFreeBuffer();
RGA.colorConvertAndFlip(nv21, HALDefine.RK_FORMAT_YCrCb_420_SP,
buf.mImage_handle, HALDefine.RK_FORMAT_RGB_888, w, h, 0);
mQueue.postBuffer(buf);
// 5. YOLO inference + post-processing
InferenceResult.OutputBuffer out = mYolo.run(buf.mImage_handle, w, h);
ArrayList<InferenceResult.Recognition> dets = mYolo.postProcess(out);
// 6. Object tracking
dets = mTracker.tracker(dets);
// 7. Run CLIP recognition on each detection box
for (InferenceResult.Recognition r : dets) {
RectF loc = r.getLocation(); // Normalized coordinates
Bitmap crop = cropFromPreview(loc, w, h); // Crop from the frame (implement yourself)
ClipHelper.Result cls = mClip.clipClassify(crop, loc, r.getTrackId());
if (cls != null && !cls.isNegative) { // Filter exclusions / low confidence
Log.d("DEMO", "Detected: " + cls.clsName + " score=" + cls.score);
}
}
}
public void onDestroy() {
if (mQueue != null) mQueue.release();
if (mYolo != null) mYolo.deinit();
if (mClip != null) mClip.release();
}
}12. Project Layout and Rebuilding
sdk/
├── build.gradle # Library module (namespace: com.rockchip.gpadc.demo, depends on gson only)
├── CMakeLists.txt # Builds librknn4j.so (C++ sources)
├── proguard-rules.pro
└── src/main/
├── AndroidManifest.xml # CAMERA + storage permissions only (no network permissions)
├── assets/ # best.rknn + clip_vision_finetuned.rknn + labels + features + tokenizer
├── cpp/ # native-lib / post_process / yolo_image / object_tracker / rga
├── jniLibs/arm64-v8a/ # librknnrt.so / librga.so / libopencv_java3.so / librknn4j.so
└── java/com/rockchip/gpadc/demo/
├── ClipHelper.java
├── ImageBufferQueue.java
├── InferenceResult.java
├── DetectionResult.java
├── clip/ClipInferenceWrapper.java
├── yolo/InferenceWrapper.java
├── yolo/PostProcess.java
├── tracker/ObjectTracker.java
├── rga/RGA.java
├── rga/HALDefine.java
└── license/LicenseManager.javaRebuild command (in the project root; requires JDK 17 + Android SDK with the NDK toolchain available):
gradlew.bat :sdk:assembleRelease
# Output: sdk/build/outputs/aar/sdk-release.aar13. Known Limitations and Notes
- AAR size: about 169 MB (CLIP model + YOLO model + OpenCV). To slim it down, consider removing
clip_vision_finetuned.rknn(keeping YOLO only). - Hardware dependency: must run on an RKNN platform (arm64-v8a); ordinary emulators have no NPU.
- CLIP text model:
ClipInferenceWrapperkeeps both image and text model interfaces, butClipHelperuses the precomputed text feature file (text_features.bin) by default and does not need to load the text model on-device. - Source of category features: on first use, ensure
text_features.binandcategories.jsonexist in thefiles/directory; they can be generated locally by the SDK'ssaveFeaturesToFile(). - YOLO model:
best.rknnis bundled and loads with one call toinitModelFromAssets(); to replace it, pass an external path toinitModel(). The model is single-class (food) and post-processing is compiled forOBJ_CLASS_NUM=1; do not substitute a COCO 80-class model. - Exclusion filtering: results matching an exclusion have
Result.isNegative=trueandclsName=null; the host UI should filter them out, drawing no box and adding nothing to the normal result list. - Offline behavior: this release makes no network requests; category features, sample images and verification records stay on the device. Clearing app data or switching devices requires re-collection / re-activation.
- Obfuscation: the AAR ships with
proguard-rules.prothat keeps JNI and data entity classes. If the host app is obfuscated, make sure these keep rules are preserved.