GPUImage: Detect the average brightness of several rectangular subregions

I use GPUImage to process the incoming video, and each frame I would like to determine the average brightness of many rectangular sub-regions of the incoming image for the purpose of detecting hits in the game, but I am having problems with what does not kill FPS.

My current situation is to iterate over the fields of interest, crop the frame of the mentioned boxes using GPUImageCropFilter, make the average brightness in the cropped area and in the method to end the lock call on the main thread if the brightness is high enough. This works fine if there are only a few hits, but for the project I'm working on, there may be dozens at a time, which kills FPS.

Are there any recommended ways to modify the above approach to improve performance? I think it would be possible to do this by creating a new filter with a custom shader that performs a kind of localized pixelation effect (the pixels of the rectangles of interest, so I can just check any pixel in this area for luminosity), but I'm not sure if pass an array of areas of interest like this to a filter / shader. Thanks.

+4
source share

Source: https://habr.com/ru/post/1485723/


All Articles