ほとんどの場合、ライブラリと同じリソースを共有できないという根本的な矛盾があるかどうかを知りたい場合は、別の方法をとる必要があります。Affdex Android SDK - CameraDetectorを保存して使用する
私の目標は、検出器のメタデータを同時に保存して低品質のビデオを作成することです。そのため、後処理やスライシングを遅延なく実行できます。
CameraDetectorDemoに基づい - 私はMediaRecorderの初期化されてきたが、私は、検出器の前にそれを起動した場合、それは黒い画面を保存し、そして私はそれを起動した場合、それは(コード-19で)起動時にクラッシュcamera detector
検出器の後に。検出器はプレビューを添付しています。おそらくそれを行うことです。
私はこれらの機能を制御するためにいくつかのボタンを追加しました:それはMediaRecorderはを制御している場合は動作するつもりはないので
protected void cameraInit() {
String state = Environment.getExternalStorageState();
if (!Environment.MEDIA_MOUNTED.equals(state)) {
Log.d(LOG_TAG, "Drive not mounted - cannot write video");
return;
}
File file = new File(getExternalFilesDir(Environment.DIRECTORY_MOVIES), "demo.gp3");
Log.d(LOG_TAG, String.format("Camera Initializing. Setting output to: %s", file.getAbsolutePath()));
// Set sources
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
// Set profile
recorder.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_LOW));
// Set output profile
recorder.setOutputFile(file.getAbsolutePath());
// Set preview output
recorder.setPreviewDisplay(cameraPreview.getHolder().getSurface());
try {
this.recorder.prepare();
} catch (IOException e) {
Log.e(LOG_TAG, "IO exception on camera Initialization");
e.printStackTrace();
} catch (IllegalStateException e) {
// This is thrown if the previous calls are not called with the
// proper order
Log.e(LOG_TAG, "Failed to initialize things properly :( ");
e.printStackTrace();
}
}
protected void cameraStart() {
Log.d(LOG_TAG, "Camera Start");
this.recorder.start();
}
protected void cameraStop() {
Log.d(LOG_TAG, "Camera Stop");
this.recorder.stop();
}
私はCameraDetectorと同じサーフェスを使用し、そこから記録するようにメディアコードを設定できるのでしょうか? – exrhizo
私はそう思いませんが、私が思い出したように、MediaRecorderが録音を開始すると、カメラを制御するので、CameraDetectorはそのポイントの後にプレビューフレームを取得しません。 –