Get the raw texture from a source in python

cboittin

New Member
Hello,

I'm trying to write a python script which needs to get the raw texture data from a WindowCapture source, after all existing filters have been applied, in order to check the average color at several locations of the texture, and do that every few seconds. I could find an example script with a timer and the functions to get the source i'm looking for, but i'm really not sure how to get the texture from that source.

I've seen that Jim advised other people to use an async filter to do that operation, but since the filter is also of type obs_source_t, i still don't know how to extract the texture.
 

Lain

Forum Admin
Lain
Forum Moderator
Developer
I generally would not recommend getting pixel data because it's going to be a drag on performance. Any time you download data off the GPU, especially texture data, it's a drag on performance. I especially would not recommend doing this with python due to python's global lock. I'd probably say lua would be best.

I don't think you can currently access pixel/audio data via python/lua at the moment. It's something I'll have to look in to for the next patch or so (probably not the next minor/hotfix update though). It certainly would be useful for audio data, as it would be nice to write audio filters via lua.

It certainly is possible to download and analyze texture data, though again it's generally not something I recommend. It is the least optimal way to automate things, even if it would be convenient.

If it were currently possible to access the pixel data, typically you'd have to stage the render and download the data manually. For example, you'd create staging textures, then in some timer you'd copy the source texture on to those staging textures, call map on them to get the pixel data, then do your analysis that way.
 

cboittin

New Member
Alright, i guess i'll go with a screen capture module in python instead of going through OBS then, although it feels like i'm doing the same thing twice.

Thanks for your answer !
 
Top