I try to pass a Mat_<float> as the destination for cv::projectPoints. Whenever I do this at runtime _OutputArray::create complains, that the type is fixed (fixedType() and fixedSize()).
Sadly the doc does not really explain these notions let alone describe what obstacles one has to jump over to use instantiate OutputArray (which is a highly problematic converter class).
Could someone shed some light about the antics of OpenCV and how to get it working?
The
OutputArrayconstructor that takes aMat_<T>sets theFIXED_TYPEflag, since it is predetermined (it’sfloatin your case). Since that implies a single-channel matrix andprojectPointswants to create a two-channel output, it fails. UseMat_<Vec2f>or something equivalent.Contrary to what vasile said, you can use
Mat_<T>and alsoMatx(which has both fixed size and type) as an OutputArray (there are explicit constructors forMatxandMat_, it’s just that those constructors set flags that some things can’t be changed, so functions that do try to change them will fail).