Skip to content

Commit

Permalink
[android] fix djl version for android
Browse files Browse the repository at this point in the history
  • Loading branch information
siddvenk committed Nov 15, 2024
1 parent 7bc81e5 commit d64fb6f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,35 @@ public void drawBoundingBoxes(DetectedObjects detections, float opacity) {
oldBitmap.recycle();
}

/** {@inheritDoc} */
@Override
public void drawRectangle(Rectangle rect, int rgb, int thickness) {
Bitmap mutableBitmap = bitmap.copy(Bitmap.Config.ARGB_8888, true);
Canvas canvas = new Canvas(mutableBitmap);
int color = darker(rgb);

// set the paint configure
Paint paint = new Paint();
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth(thickness);
paint.setAntiAlias(true);
paint.setColor(color);

int imageWidth = mutableBitmap.getWidth();
int imageHeight = mutableBitmap.getHeight();
int x = (int) (rect.getX() * imageWidth);
int y = (int) (rect.getY() * imageHeight);
canvas.drawRect(
x,
y,
x + (int) (rect.getWidth() * imageWidth),
y + (int) (rect.getHeight() * imageHeight),
paint);
Bitmap oldBitmap = bitmap;
bitmap = mutableBitmap;
oldBitmap.recycle();
}

/** {@inheritDoc} */
@Override
public void drawMarks(List<Point> points, int radius) {
Expand Down
4 changes: 2 additions & 2 deletions android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ org.gradle.jvmargs=-Xmx1536m
android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true
djl_version=0.30.0
pytorch_version=2.4.0
djl_version=0.31.0
pytorch_version=2.5.1

0 comments on commit d64fb6f

Please sign in to comment.