Ask Your Question
0

Cast CvCameraViewFrame to Mat throws Error. What to do instead?

asked 2018-08-16 23:39:47 -0500

cellurl gravatar image
public Mat onCameraFrame(CvCameraViewFrame inputFrame) {              
    Imgproc.cvtColor((Mat)inputFrame, grayscaleImage, Imgproc.COLOR_RGBA2RGB);



E/AndroidRuntime: FATAL EXCEPTION: Thread-2912
              java.lang.ClassCastException: org.opencv.android.JavaCameraView$JavaCameraFrame cannot be cast to org.opencv.core.Mat
                  at mzx.chn.lanedetection.LaneDetectActivity.onCameraFrame(LaneDetectActivity.java:242)
                  at org.opencv.android.CameraBridgeViewBase.deliverAndDrawFrame(CameraBridgeViewBase.java:391)
                  at org.opencv.android.JavaCameraView$CameraWorker.run(JavaCameraView.java:350)
                  at java.lang.Thread.run(Thread.java:856)
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2018-08-16 23:48:58 -0500

berak gravatar image

CvCameraViewFrame is not an image, but a class with means to retrieve one like:

Mat rgba = inputFrame.rgba();
Mat gray = inputFrame.gray();

see sample code

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2018-08-16 23:39:47 -0500

Seen: 35 times

Last updated: Aug 16 '18