Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
91 views
in Technique[技术] by (71.8m points)

c++ - Modern WinRT bitmap class suitable for efficient re-use

I need to do image processing work as fast as possible - milliseconds matter in my context. And I want to make use of modern image recognition techniques such as neural networks. Most of the examples I have looked at in Windows assume I am going to load one image once from one file and do one thing with it - not very useful :-( Either that or they are the Yolo example which is a mixture of rocket science and techniques above my pay grade :-(

My simple problem is this: take a bitmap that is already in memory (e.g. HBITMAP, ATL::CImage, etc) and (ideally) have a SoftwareBitmap point to that data, or at least copy that data into a SoftwareBitmap. After that, following this Windows ML tutorial I want to convert the image to a tensor, send it to my GPU, get results, and repeat millions of times over with as few overheads as possible.

So far I cannot find anything that allows me to point the bitmap buffer to a pre-existing in-memory bitmap.

If I'm forced to copy the entire bitmap each time, the obvious thing to try is to use SoftwareBitmap.LockBuffer() to obtain access to the pixel data, which I can then modify. But the documentation tells me I'm not allowed to hold such a lock indefinitely, meaning I need to release it. The trouble is there is no way to unlock it without destroying the buffer, and no obvious way to use the buffer beyond the scope so long as the lock is held. That makes it impossible to get my data to the GPU :-(

WriteableBitmap seems like it may be a useful class to consider, but the documentation and examples for it are sparse to say the least. So far it has not got me any closer to my goal, including by trying variations on this theme :-(

It seems weird that there is not a direct and obvious way to set up a bitmap (or set of bitmaps in a circular buffer) and re-use them over and over for real-time image processing. What am I missing? Is it there, but just not documented, or in any obvious example?

question from:https://stackoverflow.com/questions/65895770/modern-winrt-bitmap-class-suitable-for-efficient-re-use

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...