abergmeier
abergmeier

Reputation: 14042

Mat_<float> to OutputArray

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?

Upvotes: 1

Views: 955

Answers (1)

etarion
etarion

Reputation: 17131

The OutputArray constructor that takes a Mat_<T> sets the FIXED_TYPE flag, since it is predetermined (it's float in your case). Since that implies a single-channel matrix and projectPoints wants to create a two-channel output, it fails. Use Mat_<Vec2f> or something equivalent.

Contrary to what vasile said, you can use Mat_<T> and also Matx (which has both fixed size and type) as an OutputArray (there are explicit constructors for Matx and Mat_, 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).

Upvotes: 1

Related Questions