JavaCV Error in Android

 ̄綄美尐妖づ 提交于 2019-12-11 12:10:02

问题


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.

来源:https://stackoverflow.com/questions/30917407/javacv-error-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!