Skip to content

Instantly share code, notes, and snippets.

@jasonmarziani
Created February 8, 2019 04:19
Show Gist options
  • Save jasonmarziani/f210d6c5d0f7ac5e0c92b04d799f966b to your computer and use it in GitHub Desktop.
Save jasonmarziani/f210d6c5d0f7ac5e0c92b04d799f966b to your computer and use it in GitHub Desktop.
boost performance for opencv camera
// Around line 435, replace the block with this code
if (bmpValid && mCacheBitmap != null) {
Canvas canvas = getHolder().lockCanvas();
if (canvas != null)
{
canvas.rotate(90f, canvas.getWidth()/2, canvas.getHeight()/2);
canvas.drawColor(0, android.graphics.PorterDuff.Mode.CLEAR);
//Log.d(TAG, String.format("scale: %f, canvas width x height: %d x %d, bitmap width x height:%d x %d ", mScale, canvas.getWidth(), canvas.getHeight(), mCacheBitmap.getWidth(), mCacheBitmap.getHeight()));
Rect dstRect = new Rect();
canvas.getClipBounds(dstRect);
canvas.drawBitmap(mCacheBitmap,
new Rect(0, 0, mCacheBitmap.getWidth(), mCacheBitmap.getHeight()),
dstRect,
null);
if (mFpsMeter != null)
{
mFpsMeter.measure();
mFpsMeter.draw(canvas, 20, 30);
}
getHolder().unlockCanvasAndPost(canvas);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment