It may be a previously asked related issue regarding JavaCV on Android.My main objective is to apply grayscale/other image effect on video.
File sourceFile = new File(Environment.getExternalStorageDirectory()
+ File.separator + "test.mp4");
FFmpegFrameGrabber ffg = new FFmpegFrameGrabber(sourceFile);
OpenCVFrameConverter.ToIplImage converter = new OpenCVFrameConverter.ToIplImage();
try {
ffg.start();
int count = 0;
while (true) {
Log.d("JAVA_CV", "Counting . . . " + count);
Frame original_frame = ffg.grab();
if (original_frame == null) {
Log.d("JAVA_CV", "original_frame is NULL at" + count);
break;
} else {
Log.d("JAVA_CV", "original_frame is NOT_NULL at" + count);
opencv_core.IplImage frame1 = converter.convert(original_frame);
opencv_core.IplImage frame2 = opencv_core.IplImage.create(original_frame.imageWidth, original_frame.imageHeight, opencv_core.IPL_DEPTH_8U, 1);
opencv_imgproc.cvCvtColor(frame1, frame2, opencv_imgproc.COLOR_RGB2GRAY);
}
count++;
}
} catch (FrameGrabber.Exception fe) {
fe.printStackTrace();
System.out.println(fe.getMessage());
} catch (Exception e) {
e.printStackTrace();
System.out.println(e.getMessage());
}
}
The exception has occured at line
opencv_imgproc.cvCvtColor(frame1, frame2, opencv_imgproc.COLOR_RGB2GRAY);
Exception Stack is showing :
OpenCV Error: Assertion failed (scn == 3 || scn == 4) in void cv::cvtColor(cv::InputArray, cv::OutputArray, int, int), file /home/saudet/projects/bytedeco/javacpp-presets/opencv/cppbuild/android-arm/opencv-2.4.11/modules/imgproc/src/color.cpp, line 3739
My research states that the issue is with channels and target color, as stated here.Please tell me the where can I get color-channel sheet ? or some other alternate solution.