CaladanBrood
CaladanBrood

Reputation: 192

Converting MTLTexture of 16-bit Floating point to cv::Mat 32-bit Floating point type

I have encountered a problem in converting the floating point MTLTexture back to a floating point cv::Mat.

Ordinarily this wouldn't be a problem, but the standard 32-bit texture floating point is unwritable in Metal. I have to work with the read/writable 16-bit/channel float textures; once I get the 16-bit texture data, I cannot access each channel individually as the native float is 32-bits long and pointer arithmetic with 16-bit data would be faulty.

I considered predefining my own 16-bit floats, but I wanted to check if there were other easier methods to accomplish this.

Upvotes: 0

Views: 822

Answers (1)

aledalgrande
aledalgrande

Reputation: 5227

iOS supports the float16 type, have you tried that to extract half values and cast to float32?

I had the same problem with writing to float textures, so I just used a buffer, which is fine if you don't need sampling.

Lately Apple might have changed something, as I am able to write to float textures. Make sure you have the latest release.

Upvotes: 1

Related Questions