Poker-AI.org
http://poker-ai.org/phpbb/

Fastest way to access video memory state
http://poker-ai.org/phpbb/viewtopic.php?f=26&t=2419
Page 1 of 1

Author:  Heuristics [ Wed Mar 20, 2013 7:57 pm ]
Post subject:  Fastest way to access video memory state

Hello.

I'm currently using pixel recognition with only very little OCR to read the screen. For the OCR, I use WinAPI to get a screen shot into memory. This allows me to get 80-120 pictures of the screen per second, but it uses a lot of resources I would like to free up for other parts of the application.

Is there any way to do this more efficiently, i.e. by accessing the graphics card memory directly? I do have some OpenGL programming experience, so I wouldn't shy back from some lower level stuff, as long as it pays off.

Author:  Kratt [ Thu Mar 21, 2013 12:12 am ]
Post subject:  Re: Fastest way to access video memory state

Yes, you can get better results with OpenGL. Google around if you have to. But you don't really need to do that. Because couple of frames per second is more than enough. Just keep polling few pixels to give a better response time for your bot/scraper and scrape the rest when it's really needed. If you're in hand, you can't really miss anything. When observing even 120fps will not guarantee you won't miss anything. Causes more stalls, if nothing else. It's a good amount of data to move around.

Author:  Heuristics [ Thu Mar 21, 2013 10:08 am ]
Post subject:  Re: Fastest way to access video memory state

Kratt wrote:
Yes, you can get better results with OpenGL. Google around if you have to. But you don't really need to do that. Because couple of frames per second is more than enough. Just keep polling few pixels to give a better response time for your bot/scraper and scrape the rest when it's really needed. If you're in hand, you can't really miss anything. When observing even 120fps will not guarantee you won't miss anything. Causes more stalls, if nothing else. It's a good amount of data to move around.


I don't think you can use OpenGL if there's no OpenGL app running?

Of course, I won't be polling 120 times per second, that's just meant as a measure of performance. I just want to reduce the resources used by each poll to the minimum so I can use them for something more important.

Author:  Coffee4tw [ Fri Mar 22, 2013 3:56 pm ]
Post subject:  Re: Fastest way to access video memory state

Heuristics wrote:
I just want to reduce the resources used by each poll to the minimum so I can use them for something more important.

Then focus on more important (smaller) parts of the picture, as Kratt suggested. No need to take a screenshot of the whole screen if you are just trying to watch one table. No need to capture the whole table if you are just polling if the dealer button moved, etc.

Author:  Heuristics [ Fri Mar 22, 2013 4:09 pm ]
Post subject:  Re: Fastest way to access video memory state

Coffee4tw wrote:
Heuristics wrote:
I just want to reduce the resources used by each poll to the minimum so I can use them for something more important.

Then focus on more important (smaller) parts of the picture, as Kratt suggested. No need to take a screenshot of the whole screen if you are just trying to watch one table. No need to capture the whole table if you are just polling if the dealer button moved, etc.


That's not the point of this thread. I am currently using single pixel polling for all of those things.

I however ALSO want to have a way of accessing the WHOLE screen directly in the video memory in an EFFICIENT way - meaning NOT through WinAPI.

Why? Because in case the software changes graphics or moves buttons, etc. by a some pixel value, I can switch to an OCR & Computer Vision engine while rebuilding the pixel values.

Author:  Kratt [ Fri Mar 22, 2013 4:59 pm ]
Post subject:  Re: Fastest way to access video memory state

Then "I/we don't know" would be the direct answer to your question, without suggesting any alternatives. Because that's not the point of this forum, I would say. A single Google search will give you the fastest screen capturing methods available. This is a really common problem/question for various applications all around and way more critical than you "fallback" requires. Try to be practical. Start thinking about universal things like that when you've got nothing else to do anymore. Even when taking fullscreen captures, you don't need any more frames per second. OCR and fancy CV will be the bottlenecks then rather than capturing. I sincerely doubt that you have or ever will have the optimal efficiency going on in that part. Your simplest solution should be able to handle smaller shifts. If the bigger graphics changes are too much of a manual labor for you, build a tool to help you along or something.

Author:  Coffee4tw [ Fri Mar 22, 2013 7:19 pm ]
Post subject:  Re: Fastest way to access video memory state

Heuristics wrote:
That's not the point of this thread. I am currently using single pixel polling for all of those things.
I however ALSO want to have a way of accessing the WHOLE screen directly in the video memory in an EFFICIENT way - meaning NOT through WinAPI.

We used to have a couple hardware/low-level cracks on the old forum, not sure if they joined/are going to join again. You may want to search through the archive, I think there were some pretty useful discussions related to this topic on there.

Author:  Heuristics [ Fri Mar 22, 2013 8:37 pm ]
Post subject:  Re: Fastest way to access video memory state

Kratt wrote:
A single Google search will give you the fastest screen capturing methods available.


You have obviously *not* done that Google search ;).

I appreciate the thought, but there are very different people on this forum, for very different reasons. Computer Vision, Visual Processing and OCR are definitely a big part of many bot programs.

Simple things as detecting new positions or buttons are not that complicated or performance intensive. More importantly, the performance gains you can achieve by fine tuning it are usually small percentages.

Accessing the video memory directly - through a driver for instance - should however increase the performance of that part of the program by several factors. It's thus a much more sensible choice to look into.

So, as much as I appreciate your advice, I do believe there is a place for this kind of question here, and I do hope that some of the hardware/low-level cracks will get a chance to give me some guidance.

Author:  Kratt [ Fri Mar 22, 2013 10:13 pm ]
Post subject:  Re: Fastest way to access video memory state

Good point.

Don't forget to update when you find the way.

Author:  proud2bBot [ Fri Mar 22, 2013 11:12 pm ]
Post subject:  Re: Fastest way to access video memory state

I don't have any experience with the topic, but maybe open source virtualization tools like XEN might be worth looking into it - I can imagine they have a kind of abstraction layer that might be accessible.

Author:  cantina [ Sat Mar 23, 2013 7:03 am ]
Post subject:  Re: Fastest way to access video memory state

This might be useful:
http://stackoverflow.com/questions/1962 ... pplication

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/