Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / External image comparison on screen with image database

Author
Message
Alesalad
3
Years of Service
User Offline
Joined: 3rd Jun 2016
Location:
Posted: 6th Jun 2016 15:29
Hi All!

I've been a long time on-and-off user of DB and DBPro and recently I've come back to play around a bit more - awesome!

Anyway, as part of my PhD research I also have to sift through data and in this case the software I am using is outputting a certain image (from a database) based on the result of a simulation. I would now like use each output as in input to another simulation without having to record each one individually manually (basically, the simulation outputs me an image symbolising one of the 12 different possible outcomes and I then want to compare this output back to the database as a way to extract a "value" from it and use it).

Ideally this should be in rapid succession as I have thousands of data-points and without the need to save the image that is on my screen and load it into the DBPro exe. Is there any way I can 'extract' an image in a known position on my screen and then, by comparing it to my database of images, save a variable value somewhere?

If not, can someone direct me to some help files or functions I could use in C++?

Thanks!

Ale+
Van B
Moderator
16
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 6th Jun 2016 16:06
You can do a lot of memblock images - like take an image as a file, load it as an image, then convert to a memblock - then you have direct access to the image pixels. With this, it would be quite easy to make a checksum function for example... although I'm not sure how dangerous that could be. For example, 2 images might be completely different, but still return the same checksum value - typically checksums are there to confirm that data is sent successfully, they don't guarantee uniqueness. So you'd probably need a non-standard, elaborate checksum, using several parts (maybe separate colour channels and quadrants would be enough). Like if you divide the screen into 4, analyse the data for each quadrant separately, and store a checksum based on each colour channel. If the image isn't transparent, then that means 3 channels x 4 quadrants, or 12 checksum values per image.

Personally, I'd use a system where the program exports the image, DBPro program loads it up and generates checksums, then moves it somewhere for safe keeping with an ID stamp of some sort added to the filename. Then your generator program can just wait until the exported file is moved before starting the next.
smerf
14
Years of Service
User Offline
Joined: 24th Feb 2005
Location: nm usa
Posted: 8th Jun 2016 20:23
there is a small 43kb.exe file from nirsoft.com called nircmd. its very useful and in fact could make a very nice addition to dark basic with a few scripts and keywords, you can pass parameters to the command window
something simple like this can let you take a screen shot and save it. or you can specify x and y cords on screen can copy it to windows clip board as well. nircmd can do thousands of handy commands.
directory$ =get dir$()
cmdline$="savescreenshot " + directory$+"\temp.bmp"
execute file "n.exe",cmdline$,directory$
A child's dream never dies.
Mage
12
Years of Service
User Offline
Joined: 3rd Feb 2007
Location: Canada
Posted: 21st Aug 2016 23:29
Quote: " Is there any way I can 'extract' an image in a known position on my screen and then, by comparing it to my database of images, save a variable value somewhere?"


This is not possible without adding a plugin to DB Pro.

You are asking for DB Pro to copy or process part of the screen outside of a DBPro window.
DB Pro can only access pixels inside of its own window.
Latch
13
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 23rd Aug 2016 01:54
Quote: "Anyway, as part of my PhD research I also have to sift through data and in this case the software I am using is outputting a certain image (from a database) based on the result of a simulation. I would now like use each output as in input to another simulation without having to record each one individually manually (basically, the simulation outputs me an image symbolising one of the 12 different possible outcomes... "


Well, if the image is actually being extracted (output) from a database, then it has an index of some sort. This index would be your identifier of the image that you could feed back into the other simulation.

pseudo code for a random selection of images:



The databases can be simple delimited text files. The actual images are already stored on disk. You reference everything through DB pro, pulling an image number and file name reference from database 1 and saving that to database 2 in a similar convention.

Just a thought
Enjoy your day.

Login to post a reply

Server time is: 2019-08-26 09:13:56
Your offset time is: 2019-08-26 09:13:56