So I'm trying to use the calcCopticalFlowPyrLK
method and it keeps throwing an assertion fail:
OpenCV Error: Assertion failed ((npoints = prevPtsMat.checkVector(2, CV_32F, true)) >= 0)
And checkVector checks that the input Matrix is 2 channel and has a color depth of CV_32F. My input is a Mat with 4 channels and a color depth of CV_8U. When I try to convert it it fails to change every time. I used
Mat prevFrame; // The input Mat. Grabbed from CvCameraViewFrame. Converted to rgb
Mat prev = new Mat(rows,cols, CvType.CV_32F);
Imgproc.cvtColor(prevFrame, prev, Imgproc.COLOR_BGRA2GRAY);
prev.convertTo(prev, CvType.CV_32F);
But when I check the afterward prev has the correct depth (CV_32F) but only 1 element channel. I've been struggling with this for hours and I can't figure out what the issue is