[Rotate image 90 Degrees] Strange color after using cvTranspose
Hi,
I'm testing the Camera record by using FFmpegFrameRecorder, but the video always in landscape. When I use cvTranspose to rotate image to portrait, the result image have strange color.
Could anybody tell my how to correct this?
Many thanks,
Init recorder code:
if (yuvIplimage == null) { yuvIplimage = IplImage.create(imageWidth, imageHeight, IPL_DEPTH_8U, 2); yuvIplimage2 = IplImage.create(imageHeight, imageWidth, IPL_DEPTH_8U, 2);
} Log.i(LOG_TAG, "ffmpeg_url: " + ffmpeg_link); recorder = new FFmpegFrameRecorder(ffmpeg_link, imageWidth, imageHeight, 1); // recorder.setSampleRate(sampleAudioRateInHz); recorder.setAudioCodec(avcodec.AV_CODEC_ID_AAC); recorder.setAudioChannels(1); recorder.setAudioBitrate(audioBitrate); recorder.setVideoCodec(avcodec.AV_CODEC_ID_FLV1); // Set in the surface changed method recorder.setFrameRate(frameRate); recorder.setPixelFormat(avutil.AV_PIX_FMT_YUV420P); recorder.setFormat("flv");Log.i(LOG_TAG, "create yuvIplimage");
OnPreviewFrame function:
public void onPreviewFrame(byte[] data, Camera camera) { /* get video data */ if (yuvIplimage != null && recording) {
yuvIplimage.getByteBuffer().put(data);
opencv_core.cvTranspose(yuvIplimage, yuvIplimage2);
opencv_core.cvFlip(yuvIplimage2, null, 1);
Log.v(LOG_TAG,"Writing Frame");
try {
recorder.setTimestamp(1000 * (System.currentTimeMillis() - startTime));
recorder.record(yuvIplimage2);
} catch (FFmpegFrameRecorder.Exception e) {
Log.v(LOG_TAG,e.getMessage());
e.printStackTrace();
}
}
}