Why I Get error like "BufferOverflowException" on IplImage.getByteBuffer().put(data);
Hello, Eagerly waiting for you reply. I am trying to capture video through javaCameraView. I am getting this type of error when videoImage.getByteBuffer.put(data);
This is Error
04-24 12:13:33.530: E/AndroidRuntime(21655): FATAL EXCEPTION: Thread-19129 04-24 12:13:33.530: E/AndroidRuntime(21655): java.nio.BufferOverflowException 04-24 12:13:33.530: E/AndroidRuntime(21655): at java.nio.Buffer.checkPutBounds(Buffer.java:189) 04-24 12:13:33.530: E/AndroidRuntime(21655): at java.nio.DirectByteBuffer.put(DirectByteBuffer.java:307) 04-24 12:13:33.530: E/AndroidRuntime(21655): at java.nio.ByteBuffer.put(ByteBuffer.java:704) 04-24 12:13:33.530: E/AndroidRuntime(21655): at com.opencameravideo.VideoMainActivity.onFrame(VideoMainActivity.java:322) 04-24 12:13:33.530: E/AndroidRuntime(21655): at com.opencameravideo.VideoMainActivity.onCameraFrame(VideoMainActivity.java:258) 04-24 12:13:33.530: E/AndroidRuntime(21655): at org.opencv.android.CameraBridgeViewBase.deliverAndDrawFrame(CameraBridgeViewBase.java:387) 04-24 12:13:33.530: E/AndroidRuntime(21655): at org.opencv.android.JavaCameraView$CameraWorker.run(JavaCameraView.java:346) 04-24 12:13:33.530: E/AndroidRuntime(21655): at java.lang.Thread.run(Thread.java:841)
This is my code:
package com.opencameravideo;
import static org.bytedeco.javacpp.opencv_core.IPL_DEPTH_8U; import static org.bytedeco.javacpp.opencv_core.CV_8UC1;
import java.io.File; import java.io.IOException; import java.nio.ShortBuffer; import java.util.List;
import org.bytedeco.javacpp.BytePointer; import org.bytedeco.javacpp.opencv_core; import org.bytedeco.javacpp.opencv_core.IplImage; import org.bytedeco.javacv.FFmpegFrameRecorder; import org.bytedeco.javacv.Frame; import org.opencv.android.BaseLoaderCallback; import org.opencv.android.CameraBridgeViewBase.CvCameraViewFrame; import org.opencv.android.CameraBridgeViewBase.CvCameraViewListener2; import org.opencv.android.LoaderCallbackInterface; import org.opencv.android.OpenCVLoader; import org.opencv.core.Mat; import org.opencv.core.Scalar; import org.opencv.imgproc.Imgproc;
import android.app.Activity; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.hardware.Camera; import android.hardware.Camera.PictureCallback; import android.media.AudioFormat; import android.media.AudioRecord; import android.media.MediaRecorder; import android.media.MediaScannerConnection; import android.os.Bundle; import android.support.v4.content.LocalBroadcastManager; import android.util.Log; import android.view.SurfaceView; import android.view.View; import android.view.View.OnClickListener; import android.view.WindowManager; import android.widget.Button; import android.widget.Toast;
public class VideoMainActivity extends Activity implements CvCameraViewListener2 { // , PictureCallback {
private JavaOpenCvCameraView javaOpenCvCameraView; private Mat edgesMat; private final Scalar greenScalar = new Scalar(0, 255, 0); private int resolutionIndex = 0; Button startVideo, stopVideo;
private opencv_core.IplImage videoImage = null;
boolean recording = false; private volatile FFmpegFrameRecorder recorder;
// default // private int sampleAudioRateInHz = 44100; // private int imageWidth = 320; // private int imageHeight = 240; // private int frameRate = 30; private int sampleAudioRateInHz = 44100; private int imageWidth = 320; private int imageHeight = 240; private int frameRate = 60; private String RECIEVE_BYTE_BUFFER = ""; private Thread audioThread; volatile boolean runAudioThread = true; private AudioRecord audioRecord; private AudioRecordRunnable audioRecordRunnable;
private String ffmpeg_link;
long startTime = 0;
private String LOG_TAG = "VideoTest";
private BaseLoaderCallback mLoaderCallback = new BaseLoaderCallback(this) { @Override public void onManagerConnected(int status) { switch (status) { case LoaderCallbackInterface.SUCCESS: Log.i("VideoTest", "OpenCV loaded successfully"); javaOpenCvCameraView.enableView(); break; default: super ...
sorry, but we can't help you with problems specific to javacv (3rd party wrapper)