我知道它的後期來回答這個問題。但我終於找到了解決方案,它不會使相機框架緩慢。
您必須對默認的opencv類進行更改。 按照此步驟:1)在CameraBridgeViewBase類添加以下代碼
Matrix matrix = new Matrix();
matrix.setRotate(90f);
Bitmap bitmap = Bitmap.createBitmap(mCacheBitmap, 0, 0, mCacheBitmap.getWidth(), mCacheBitmap.getHeight(), matrix, true);
2)現在在drawbitmap方法代替上面mCacheBitmap位圖,如像現在下面
if (mScale != 0) {
canvas.drawBitmap(bitmap, new Rect(0,0,bitmap.getWidth(), bitmap.getHeight()),
new Rect((int)((canvas.getWidth() - mScale*bitmap.getWidth())/2),
(int)((canvas.getHeight() - mScale*bitmap.getHeight())/2),
(int)((canvas.getWidth() - mScale*bitmap.getWidth())/2 + mScale*bitmap.getWidth()),
(int)((canvas.getHeight() - mScale*bitmap.getHeight())/2 + mScale*bitmap.getHeight())), null);
} else {
canvas.drawBitmap(bitmap, new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight()),
new Rect((canvas.getWidth() - bitmap.getWidth())/2,
(canvas.getHeight() - bitmap.getHeight())/2,
(canvas.getWidth() - bitmap.getWidth())/2 + bitmap.getWidth(),
(canvas.getHeight() - bitmap.getHeight())/2 + bitmap.getHeight()), null);
}
3) ,在你JavaCameraView類取代initializeCamera方法下面的代碼(改變高度,寬度爲人像模式)
if ((getLayoutParams().width == ActionBar.LayoutParams.MATCH_PARENT) && (getLayoutParams().height == ActionBar.LayoutParams.MATCH_PARENT))
mScale = Math.min(((float)height)/mFrameWidth, ((float)width)/mFrameHeight);
else
mScale = 0;
你就完成了!希望它有幫助..
你有沒有找到任何解決方案?如果您有任何解決方案以縱向模式顯示預覽,請發佈答案。 – IshRoid
現在沒有找到解決方案。 – Inconsapevole