我正在使用Android Studio,OpenCV和JavaCameraView来显示相机的框架。我想创建一个简单的Mat帧记录器。例如,我要保存100个最后一帧,然后在JavaCameraView中显示它。
我记录了矢量用于存储Mat帧的CameraFrames。在功能onCameraFrame中,我有...
@Override
public Mat onCameraFrame(CameraBridgeViewBase.CvCameraViewFrame cameraFrame) {
colorMat = cameraFrame.rgba();
if(frameCountForRecording < 100){
recordedCameraFrames.add(colorMat);
frameCountForRecording++;
}
else {
isRecordedFramesReadyToPlay = true;
recordedCameraFrames.remove(0);
recordedCameraFrames.add(colorMat);
}
然后当我激活PLAY_DETECTED_FRAMES_VIEW_MODE时,我要播放录制的帧...
case PLAY_DETECTED_FRAMES_VIEW_MODE:
if(isRecordedFramesReadyToPlay == true && canPlayRecordedFrames == true) {
if (indexOfRecordedFrame == 99) {
indexOfRecordedFrame = 0;
}
indexOfRecordedFrame++;
colorMat = recordedCameraFrames.get(indexOfRecordedFrame).clone();
}
break;