Author Topic: OCR Explaination and help...Images and long post.  (Read 2102 times)

0 Members and 1 Guest are viewing this topic.

Offline CoraginTopic starter

  • Wacko in Pajama's
  • Elite
  • *
  • *
  • Posts: 1641
  • Activity:
    0%
  • Reputation Power: 23
  • Coragin might someday be someone...Coragin might someday be someone...Coragin might someday be someone...Coragin might someday be someone...
  • Gender: Male
  • It Is What It Is.
  • Respect: +57
  • Referrals: 1
    • View Profile
OCR Explaination and help...Images and long post.
« on: January 25, 2010, 12:00:33 AM »
0
If you are an elite you can read about this in the hort threat in special projects e.

If not, I can really use some help in how to do this...see the attached images.

Main plant gump window size 263x231
Seed/Resource gump window size 255x231


This is the image of the plant gump.

Now a couple icons are missing from my gump because I take some things out of the world and it just so happens these images also share with this gump.  But it wont make a difference either way.

You will notice there is a yellow + that indicates you need to add 1 dose of cure, if it needed 2 doeses it would be a red +.  This will go on the left side for all the potions needed, yellow for 1 red for 2 nothing if there is nothing to be added.

For water it will be right next to the water pic, again yellow or red or nothing.

While this character will always be a plus....seeds will not.  it will be a 0-8/8  Example if three seeds are available it would be 3/8 and if those three are taken it will change to 0/5 and everytime it bears a seed the second number will lower.  These colors of the numbers will change, but that is of no matter, we will be collecting all seeds no matter the color.

If there is another way to do this besides ocr, I would love to know.  also if you see the number in the upper left hand corner.  That is how many days the plant has grown.  If it is over say 16 days and you have harvested all the seeds and resources, it would be good to set it to deco mode.

So we need a way to find out if there are no more seeds and resources that will ever come from the plant.  If both seeds and resources get to 0/0 time to set the plant to deco and move it to secure.

What we need to determine in the case of just tending plants and not collecting resources at all.

1.  if there is a "+" by any of the potion locations
2. if there is a "+" what color is it?  Yellow or Red?
3. If there is a "+" on the left we need to determine if there is a 0, 1, or 2 on the right side. (this lets us know how many if any potions we need to pour)
4. If it is a yellow "+" and there is a "0" on the right, we need to pour 1 of that potion type.
5. If there is a red "+" and there is a "0" on the right we need to pour 2 potions of that type.
6. If there is a yellow "+" and a 1 on the right, we dont need to pour any potions.
7. If there is a red "+" and a 1 on the right, we need to pour 1 potion of that type.
8. if there is a red "+" and a 2 on the right we dont need to pour any potions.

That is it in a nutshell for tending.  For gathering, we need to determine...

1. If there are resources available seeds or petals, thorns ect.
2. This will be in the middle on the right where the purple number are for seeds.
3. This will be in the middle on the left where they yellow "-" is.  If resources are available, it will be numbered just like the seeds.

So we have two numbers to determine for either....

1. if a number exists (some plants wont produce a seed or resource, white and black)
2. if a number exists, we need to determine the first and second number. 
3. if the first number is anything other than a "0" it has resources, seeds or petals ect.
4. if the second number is a "0" it is done giving resources or seeds.
5. if the plant is done giving resources AND seeds AND the plant is 9 days old (number in the upper left hand corner of the gump), we can set it to retire and move to secure to clip it up for dyes.

This is why I think we need OCR, but if there is another way, please by all means let me know.

There are 2 attachment(s) in this post. You must register and post an acceptable introduction to download
plantgump1.bmp
plantgump2.bmp
Coragin

My Facebook
And now I'm better at doing what ever it is Wolverine does!

Offline CoraginTopic starter

  • Wacko in Pajama's
  • Elite
  • *
  • *
  • Posts: 1641
  • Activity:
    0%
  • Reputation Power: 23
  • Coragin might someday be someone...Coragin might someday be someone...Coragin might someday be someone...Coragin might someday be someone...
  • Gender: Male
  • It Is What It Is.
  • Respect: +57
  • Referrals: 1
    • View Profile
Re: OCR Explaination and help...Images and long post.
« Reply #1 on: January 25, 2010, 12:04:40 AM »
0
On a side note, if someone can help me with this one part, I can get this script out with the help of others pretty darn quick.
Coragin

My Facebook
And now I'm better at doing what ever it is Wolverine does!

Offline CoraginTopic starter

  • Wacko in Pajama's
  • Elite
  • *
  • *
  • Posts: 1641
  • Activity:
    0%
  • Reputation Power: 23
  • Coragin might someday be someone...Coragin might someday be someone...Coragin might someday be someone...Coragin might someday be someone...
  • Gender: Male
  • It Is What It Is.
  • Respect: +57
  • Referrals: 1
    • View Profile
Re: OCR Explaination and help...Images and long post.
« Reply #2 on: January 25, 2010, 02:38:09 AM »
0
Figured out finding the color of +/-, that is done almost. 

All left to do now is find the number "9" in the upper left corner of image 2.  And finding if you can get seeds or resources.  That can be doen via journal as an easy fix for now.  But if you know a better way, please tell me.
Coragin

My Facebook
And now I'm better at doing what ever it is Wolverine does!

Offline captainsparrow1882

  • Jr. Member
  • **
  • Posts: 26
  • Activity:
    0%
  • Reputation Power: 0
  • captainsparrow1882 has no influence.
  • Respect: +2
  • Referrals: 0
    • View Profile
Re: OCR Explaination and help...Images and long post.
« Reply #3 on: January 26, 2010, 11:27:23 AM »
0
Since we are mostly interested in numbers, + and - I have come up with this (just snippets).
I basically scan only the third vertical scanline (10 pixels) of a char and try to determine the number or sign based on that value.

Code: [Select]
;**********
; ScanVerticalLine
; %1 x
; %2 y
; %3 colors
; %4 length
;**********
sub ScanVerticalLine
  namespace push
  namespace local ScanVerticalLine

  set !LPC #LPC
  set #LPC 1000000
  
  set !X %1
  set !Y %2
  set !Colors %3
  set !Length %4

  set #Result 0
  for !i 1 !length
  {
    savepix !X !Y 1
    set #Result #Result * 2
    if #PixCol in !Colors
      set #Result #Result + 1
    set !Y !Y + 1
  }

  set #LPC !LPC
  namespace pop
return #Result
Code: [Select]
;**********
; ScanCharacter ; numbers, + and - actually
; %1 x
; %2 y
; %3 colors
;**********
sub ScanCharacter
  namespace push
  namespace local ScanCharacter

  if ! !Initialized
  {
     set !Character1 1023
     set !Character2 783
     set !Character3 787
     set !Character4 1016
     set !Character5 547
     set !Character6 867
     set !Character7 527
     set !Character8 625
     set !Character9 793
     set !Character0 771
     set !CharacterMinus 48
     set !CharacterPlus 252

     set !Initialized #True
  }

  set !X %1 + 2 ; vertical line to scan
  set !Y %2
  set !Colors %3

  gosub ScanVerticalLine !X !Y !Colors 10
  
  while #True
  {
    if #Result = !Character1
    {
      set #Result 1
      break
    }
    if #Result = !Character2
    {
      set #Result 2
      break
    }
    if #Result = !Character3
    {
      set #Result 3
      break
    }
    if #Result = !Character4
    {
      set #Result 4
      break
    }
    if #Result = !Character5
    {
      set #Result 5
      break
    }
    if #Result = !Character6
    {
      set #Result 6
      break
    }
    if #Result = !Character7
    {
      set #Result 7
      break
    }
    if #Result = !Character8
    {
      set #Result 8
      break
    }
    if #Result = !Character9
    {
      set #Result 9
      break
    }
    if #Result = !Character0
    {
      set #Result 0
      break
    }
    if #Result = !CharacterMinus
    {
      set #Result -
      break
    }
    if #Result = !CharacterPlus
    {
      set #Result +
      break
    }
    set #Result N/A
    break
  }
  
  namespace pop
return #Result
Code: [Select]
;**********
; GetNumber
; %1 x
; %2 y
; %3 color
;**********
sub GetNumber
  namespace push
  namespace local GetLevel
  set !LPC #LPC
  set #LPC 1000000

  set !X #ContPosX + %1
  set !Y #ContPosY + %2
  set !Colors %3
  
  gosub ScanCharacter !X !Y !Colors
  if #Result notin 0123456789
    set #Result 0

  namespace pop
return #Result
Code: [Select]
;**********
; GetLevel ; interpret +/- red/yellow
; %1 x
; %2 y
;**********
sub GetLevel
  namespace push
  namespace local GetLevel
  set !LPC #LPC
  set #LPC 1000000
  
  set !X #ContPosX + %1
  set !Y #ContPosY + %2

  while #True
  {
    gosub ScanCharacter !X !Y %YellowTextColor
    if #Result in +
    {
      set #Result 1
      break
    }
    if #Result in -
    {
      set #Result -1
      break
    }
    
    gosub ScanCharacter !X !Y %RedTextColor
    if #Result in +
    {
      set #Result 2
      break
    }
    if #Result in -
    {
      set #Result -2
      break
    }

    set #Result 0
    break
  }

  set #LPC !LPC
  namespace pop
return #Result
Code: [Select]
gosub GetNumber %PlantGumpAgeTextOffsetX %PlantGumpAgeTextOffsetY %GreyTextColor
gosub GetLevel %WaterLevelTextOffsetX %WaterLevelTextOffsetY  
gosub GetLevel %InfestationLevelTextOffsetX %InfestationLevelTextOffsetY
gosub GetNumber %GreaterPoisonPotionTextOffsetX %GreaterPoisonPotionTextOffsetY %GreyTextColor
...

Here's some of the relative pixel coordinates I found out:

Code: [Select]
set %PlantGumpSize 263_231
set %PlantGumpAgeTextOffsetX 55
set %PlantGumpAgeTextOffsetY 52
set %PlantGumpReproductionButtonOffsetX 80
set %PlantGumpReproductionButtonOffsetY 72 + 5

set %ReproductionGumpSize 255_231
set %ReproductionGumpResourceTextOffsetX 150
set %ReproductionGumpResourceTextOffsetY 121
set %ReproductionGumpResourceButtonOffsetX 146
set %ReproductionGumpResourceButtonOffsetY 172
set %ReproductionGumpSeedTextOffsetX 200
set %ReproductionGumpSeedTextOffsetY 121
set %ReproductionGumpSeedButtonOffsetX 220
set %ReproductionGumpSeedButtonOffsetY 172
set %ReproductionGumpRetirementButtonOffsetX 220
set %ReproductionGumpRetirementButtonOffsetY 75


set %RetirementGumpSize 271_231
set %RetirementGumpRetireButtonOffsetX 180
set %RetirementGumpRetireButtonOffsetY 150

set %GlassPitcherType WYF
set %WaterTroughType QEE_TEE_VEE_WEE
set %EmptyBottleType WUF
set %PitcherOfWaterType VBM
set %WaterLevelTextOffsetX 197
set %WaterLevelTextOffsetY 72
set %WaterLevelButtonOffsetX 218
set %WaterLevelButtonOffsetY 72 + 5

set %GreaterPoisonPotionType AVF
set %GreaterPoisonPotionTextOffsetX 197
set %GreaterPoisonPotionTextOffsetY 96
set %GreaterPoisonPotionButtonOffsetX 218
set %GreaterPoisonPotionButtonOffsetY 96 + 5

set %GreaterCurePotionType NUF
set %GreaterCurePotionTextOffsetX 197
set %GreaterCurePotionTextOffsetY 120
set %GreaterCurePotionButtonOffsetX 218
set %GreaterCurePotionButtonOffsetY 120 + 5

set %GreaterHealPotionType UUF
set %GreaterHealPotionTextOffsetX 197
set %GreaterHealPotionTextOffsetY 144
set %GreaterHealPotionButtonOffsetX 218
set %GreaterHealPotionButtonOffsetY 144 + 5

set %GreaterStrengthPotionType XUF
set %GreaterStrengthPotionTextOffsetX 197
set %GreaterStrengthPotionTextOffsetY 168
set %GreaterStrengthPotionButtonOffsetX 218
set %GreaterStrengthPotionButtonOffsetY 168 + 5


set %InfestationLevelTextOffsetX 96
set %InfestationLevelTextOffsetY 96 + 1

set %FungusLevelTextOffsetX 96
set %FungusLevelTextOffsetY 120 + 1

set %PoisonLevelTextOffsetX 96
set %PoisonLevelTextOffsetY 144 + 1

set %DiseaseLevelTextOffsetX 96
set %DiseaseLevelTextOffsetY 168 + 1

and some colors

Code: [Select]
; plant gump
set %GreyTextColor _13024701_
set %YellowTextColor _3270631_
set %RedTextColor _5911015_

; reproduction gump
set %TextColorCount 8
set %TextColor1 11862073 ; blue
set %TextColor2 4277 ; dark red
set %TextColor3 13024701 ; white
set %TextColor4 46468 ; yellow
set %TextColor5 3245287 ; bright orange
set %TextColor6 33973
set %TextColor7 46352
set %TextColor8 11862181

I was thinking about using TM's TM_NewSampleArea sub for scanning but I couldn't figure out how the algorithm (checksum) and how well it spreads the results. :(
« Last Edit: January 26, 2010, 11:30:45 AM by captainsparrow1882 »

Scrripty

  • Guest
Re: OCR Explaination and help...Images and long post.
« Reply #4 on: January 26, 2010, 02:41:20 PM »
0
Nice work sparrow. :)

Tags: