Need some help

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
hobbits1982
Newbie
Posts: 5
Joined: Tue Feb 21, 2006 3:34 pm

Need some help

Post by hobbits1982 » Fri Jun 02, 2006 5:21 am

Sorry for repost the same question I asked before but I really need help in doing my project.

I want to get the value which is displaying from a program and copy it into a text,for example the value 7.4(see the printscreen) that was displaying in a software.(I using a pH meter that can directly connected to computer, and the software used will display the value of the pH value), can this be done??
I am using Visual Basic 6.0, and I want to retrieve the pH value 7.4 from the text.(Since I fail to retrieve from serial port directly, so I think maybe can use MacroSchduler retrieve the value and copy to text, then I can use VB to get the value from text.) Anyone know about this?Or if got another way please tell me.


Image

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Fri Jun 02, 2006 6:36 am

Unfortunately, this value is not text, it is a graphic. The only way I can think of doing this is using an optical character recognition approach. Two possible solutions:

1. Using the image recognition library take samples of each of the numbers displayed by this program. Extract images showing values 1 to 9. Then you can write a script that looks for each of these on the screen. When it finds a match it knows what number it found and its relative position and therefore a routine can be written to determine the number on the screen.
http://www.mjtnet.com/imagerecognition.htm

2. Download Textract:
http://www.structurise.com/textract/
Also download our wrapper DLL:
ftp://ftp.mjtnet.com/pub/doTextract.zip
See example and readme in the zip file

Textract uses OCR to scan a screen graphic and extract the text it detects. The text is extracted to a file and can then be parsed.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

User avatar
pgriffin
Automation Wizard
Posts: 460
Joined: Wed Apr 06, 2005 5:56 pm
Location: US and Europe

Post by pgriffin » Fri Jun 02, 2006 2:12 pm

I researched your software a bit and was able to find (from their tech support) that Turtle writes to a file called VAL.ini. You might (only MIGHT) be able to read the INI file with:

ReadIniFile>c:\some path\VAL.ini,section,entry,Result

where you replace the values (after opening the VAL.ini to see what the setting should be) with your own values for path, section and entry.

If you send a copy of the VAL.ini file I could help you set up the ReadIniFile> code ......

User avatar
pgriffin
Automation Wizard
Posts: 460
Joined: Wed Apr 06, 2005 5:56 pm
Location: US and Europe

Post by pgriffin » Fri Jun 02, 2006 2:14 pm

My point in the earlier post was that you might be able to read the Ini file INSTEAD of reading from the screen.

What is it you intend to do with the data? Give me an idea of the complete application and I'll do what I can.

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Fri Jun 02, 2006 3:16 pm

If you do have to go the screen reading route I don't think you have do the full image recognition thing. It should be possible to decode the number by getting the pixel color from maybe 6 or 7 positions for each digit. I think this would be a lot faster. If it was a 7 segment style font then it would be very easy to do this, just grab the pixel color from the mid position of each segment. It will be a bit more of a challenge to chose the sample locations with this font, but there are probably unique pixels for several of the digits which could make the decoding easier.

User avatar
pgriffin
Automation Wizard
Posts: 460
Joined: Wed Apr 06, 2005 5:56 pm
Location: US and Europe

Post by pgriffin » Fri Jun 02, 2006 3:21 pm

I agree with the checking of limited pixels if the Val.ini file proves useless. I use a method I wrote called "fingerprinting" which is very quick and dependable.

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Fri Jun 02, 2006 3:44 pm

Agreed, it's definitely option #3 after reading the serial data, and reading a file.

hobbits1982
Newbie
Posts: 5
Joined: Tue Feb 21, 2006 3:34 pm

Post by hobbits1982 » Sat Jun 03, 2006 3:14 am

Thank you for replying me.
Actually the purpose of I retrieving the pH value is to put into Visual Basic for calculation,(eg change the pH value back to concertration value), and display in VB interface.

Can teach me how to do the checking of limited pixels use "fingerprinting"?
I will first try to retrieve the data from val.ini. If useless then I will have to try fingerprinting.

Inside val.ini I only see

[value]
pH=7.4

if like that how I read it??

hobbits1982
Newbie
Posts: 5
Joined: Tue Feb 21, 2006 3:34 pm

Post by hobbits1982 » Sat Jun 03, 2006 3:31 am

[quote="hobbits1982"]Thank you for replying me.
Actually the purpose of I retrieving the pH value is to put into Visual Basic for calculation,(eg change the pH value back to concertration value), and display in VB interface.

Can teach me how to do the checking of limited pixels use "fingerprinting"?
I will first try to retrieve the data from val.ini. If useless then I will have to try fingerprinting.

P/S
Inside val.ini can see

[value]
pH=7.4

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Sat Jun 03, 2006 7:22 am

P/S
Inside val.ini can see

[value]
pH=7.4
ReadIniFile>c:\bla\inifile.ini,value,pH,pH
MessageModal>Value is %pH%
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Tue Jun 06, 2006 10:30 am

As a follow up to my previous post about using Textract to perform OCR on the screen, I have since realised that Textract offers a simpler command line interface. It is simpler to use than I previously suggested. I have provided an example on my blog:

http://www.mjtnet.com/blog/2006/06/06/s ... ical-text/

Perhaps not required after all in this context but worth remembering in future as it is an excellent way to scan the screen, or a portion of the screen, for text.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts