简体   繁体   中英

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM