- 純正のカメラアプリでもPORTRAITだけ対応だったりするので、回転してすぐカメラのプレビューが取れないとかはまあある話なのでは
- バッファとかの回転のマトリックスは固定値返したりとかあるみたいですね
- rotateとかtranslateの中心座標指定めっちゃ便利
- pauseからの復帰で戻ってくると
CameraDevice.StateCallback
のonErrorでエラーコード 1 = (ERROR_CAMERA_IN_USE
) を受け取る
- このエラーは優先的にCamera APIを利用してるクライアントがありますよ、と言う意味だが、もちろんいまテスト用に書いてるものしか利用してないので、そのクライアントは自分のこととなる
- 明日はあのサンプルの仰々しいロックの導入を試して見るかなー
Matrix 中心座標を入れられるの便利
private Matrix getDirectionAdjustedMatrix() {
Matrix matrix = new Matrix();
int viewCenterX = (int) (mTextureView.getX() + mTextureView.getWidth() / 2);
int viewCenterY = (int) (mTextureView.getY() + mTextureView.getHeight() / 2);
matrix.postRotate(270 , viewCenterX, viewCenterY);
matrix.postScale((1.0f * IMAGE_WIDTH / IMAGE_HEIGHT) * (mTextureView.getWidth() / mTextureView.getHeight()), (1.0f * IMAGE_HEIGHT / IMAGE_WIDTH) * (mTextureView.getWidth() / mTextureView.getHeight()),
viewCenterX, viewCenterY);
return matrix;
}
onPause -> onResumeの復帰がうまくいかない
@Override
public void onPause() {
if (mCaptureSession != null) {
mCaptureSession.close();
mCaptureSession = null;
}
if (mImageReader != null) {
mImageReader.close();
mImageReader = null;
}
super.onPause();
}
@Override
public void onResume() {
super.onResume();
if (mTextureView.isAvailable()) {
openCamera();
} else {
mTextureView.setSurfaceTextureListener(new TextureView.SurfaceTextureListener() {
@Override
public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) {
openCamera();
}
@Override
public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) {
}
@Override
public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) {
return true;
}
@Override
public void onSurfaceTextureUpdated(SurfaceTexture surface) {
}
});
}
}
public static abstract class StateCallback {
An error code that can be reported by {@link #onError}
indicating that the camera device is in use already.
<p>
</p>
@see #onError
public static final int ERROR_CAMERA_IN_USE = 1;
- [既存課題]縦向きの場合と横向きの場合でちょうどいいrotationのMatrixを見つける
- [休止][既存課題]縦向きの場合と横向きの場合でそれぞれちょうどよくCameraのPreviewが表示されるようにする
- [新しい課題]Pauseからうまく復帰できない