开发者

How to serve an image of the screen as an input to a program, in Haskell

开发者 https://www.devze.com 2023-03-13 03:06 出处:网络
I\'d like to write a function (I\'m using Haskell) that\'s capable of retrieving the actual content of the screen, as viewed by the user, in order to pre-elaborate (grayscaling and/or some stencil con

I'd like to write a function (I'm using Haskell) that's capable of retrieving the actual content of the screen, as viewed by the user, in order to pre-elaborate (grayscaling and/or some stencil con开发者_C百科volution through the repa package) and feed it to a neural network or some other AI architecture.

The type would be something like watch :: IO img Is there a library that provides functions like this? And if I needed not the entire screen but only the visual output of a program, is there other way than hand-cutting the image?


Grabbing the screen is platform dependant. And you'll need to find a C library that does this, then write a Haskell binding to that low level functionality. On some systems you may be able to open the frame buffer as a file as grab the image.

So, the answer is the same as for C, but you write a binding from Haskell to that function.


Maybe you can have a look at the source code of scrot

0

精彩评论

暂无评论...
验证码 换一张
取 消