It is currently Sat Apr 27, 2024 3:13 am

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
Offline
 Post subject: Quick tool to convert EidoGo to [go] diagram
Post #1 Posted: Wed Mar 19, 2014 7:36 am 
Lives in gote
User avatar

Posts: 699
Location: Switzerland
Liked others: 485
Was liked: 166
Rank: DDK
KGS: aco
IGS: oca
OGS: oca
Hello,

Just wanted to share with you a quick tool I did to convert an EidoGo board to a [go] "text" diagram

The tool is a java application that you start and that will do a copy of the screen and then processes the image to find the goban and render it as text.

Once that done, the "text" is placed into the clipboard ready to be paste where you want, and finally a dialog
is shown to show what as been found.

here is a screenshoot.

Image

To use it, you need java to be on your computer, and you need to download the program "DiagToTxt.jar"
(jar stands for Java ARchive).

The file is available here :
http://picshell.ovh.org/go

and download "diagtotxt.jar"

to execute the programme, you need to type the following command (or put it in a .bat file which must be in the smae folder as diagtotxt.jar)

Code:
start javaw -cp diagtotxt.jar oca.DiagToTxt


It's really important to start it that way so that no java console is displayed (if the console is displayed,
it may comes in front of the Eidigo diagram and the console will be present in the image...)

Limitation : only work with 19x19 boards.

Enyoy.

for whose who want to see the java code :
Code:
package oca;

import java.awt.Font;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
import java.awt.image.BufferedImage;
import java.io.File;

import javax.imageio.ImageIO;
import javax.swing.JOptionPane;
import javax.swing.plaf.FontUIResource;

public class DiagToTxt {
   public static void main(String[] args) throws Exception {

      BufferedImage image;

      Robot robot = new Robot();
      image = robot.createScreenCapture(new Rectangle(Toolkit
            .getDefaultToolkit().getScreenSize()));
      // String format ="PNG" ;
      // ImageIO.write(image, format, new File("screenShot."+format));
      // image = ImageIO.read(new File("screenShot."+format));

      int startPosY = -1;
      int startPosX = -1;
      /*
       * Find starting point
       */
      for (int y = 0; y < image.getHeight(); y++) {
         StringBuffer line = new StringBuffer();
         for (int x = 0; x < image.getWidth(); x++) {
            int clr = image.getRGB(x, y);
            if (clr == -2245525) { // = background color "DDBC6B"
               line.append("_");
            } else {
               line.append("X");
            }
         }
         int tmp = line
               .toString()
               .indexOf(
                     "___________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________");
         if (tmp > -1) {
            startPosY = y;
            startPosX = tmp;
            break;
         }
      }
      int margin = 14;
      int nbPixPerSquare = 19;
      int py = 0;

      StringBuffer goban = new StringBuffer();
      goban.append("[go]$$\n");
      goban.append("$$ ----------------------------------------\n");

      for (int y = startPosY + margin; y < (startPosY + margin + 18
            * nbPixPerSquare + 1); y += nbPixPerSquare) {
         py++;
         goban.append("$$ | ");
         for (int x = startPosX + margin; x < (startPosX + margin + 18
               * nbPixPerSquare + 1); x += nbPixPerSquare) {
            int clr = image.getRGB(x, y - 6);
            int red = (clr & 0x00ff0000) >> 16;
            int green = (clr & 0x0000ff00) >> 8;
            int blue = clr & 0x000000ff;
            String r = String.format("%02X%02X%02X", red, green, blue);
            int clrCenter = image.getRGB(x, y );

            String car = ".";
            if (clrCenter==-9412810) {
               car = ",";
            } else if (r.equals("383838")) {
               car = "X";
            } else if (r.equals("FEFEFE")) {
               car = "O";
            }
            goban.append(car + " ");
         }
         goban.append("|\n");
      }
      goban.append("$$ ----------------------------------------[/go]\n");

      StringSelection selection = new StringSelection(goban.toString());
      Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
      clipboard.setContents(selection, selection);
      javax.swing.UIManager.put("OptionPane.messageFont", new FontUIResource(
            new Font("Courier", Font.PLAIN, 12)));
      JOptionPane.showMessageDialog(null,
            "DiagToTxt 1.0 by oca\nClipboard content :\n" + goban.toString());
   }
}


_________________
Converting the book Shape UP! by Charles Matthews/Seong-June Kim
to the gobook format. last updated april 2015 - Index of shapes, p.211 / 216


This post by oca was liked by 2 people: Bonobo, macelee
Top
 Profile  
 
Offline
 Post subject: Re: Quick tool to convert EidoGo to [go] diagram
Post #2 Posted: Wed Mar 19, 2014 9:10 am 
Oza

Posts: 2180
Location: ʍoquıɐɹ ǝɥʇ ɹǝʌo 'ǝɹǝɥʍǝɯos
Liked others: 237
Was liked: 662
Rank: AGA 5d
GD Posts: 4312
Online playing schedule: Every tenth February 29th from 20:00-20:01 (if time permits)
Well, very nice. But I cannot quite see why the go format would be preferred over the eidogo format.

_________________
Still officially AGA 5d but I play so irregularly these days that I am probably only 3d or 4d over the board (but hopefully still 5d in terms of knowledge, theory and the ability to contribute).

Top
 Profile  
 
Offline
 Post subject: Re: Quick tool to convert EidoGo to [go] diagram
Post #3 Posted: Wed Mar 19, 2014 10:50 am 
Gosei
User avatar

Posts: 1585
Location: Barcelona, Spain (GMT+1)
Liked others: 577
Was liked: 298
Rank: KGS 5k
KGS: RBerenguel
Tygem: rberenguel
Wbaduk: JohnKeats
Kaya handle: RBerenguel
Online playing schedule: KGS on Saturday I use to be online, but I can be if needed from 20-23 GMT+1
DrStraw wrote:
Well, very nice. But I cannot quite see why the go format would be preferred over the eidogo format.


For pasting specific positions or areas here, in this same forum or in Sensei's library. For example.

_________________
Geek of all trades, master of none: the motto for my blog mostlymaths.net

Top
 Profile  
 
Offline
 Post subject: Re: Quick tool to convert EidoGo to [go] diagram
Post #4 Posted: Wed Mar 19, 2014 11:37 pm 
Lives in gote
User avatar

Posts: 699
Location: Switzerland
Liked others: 485
Was liked: 166
Rank: DDK
KGS: aco
IGS: oca
OGS: oca
DrStraw wrote:
Well, very nice. But I cannot quite see why the go format would be preferred over the eidogo format.

Yes, you right, there is not that much usage for it... so I don't excpect it to win the "2014 Most downloaded go program award" :D
I still missed that kind of tool in a few occasions,for taking a "snapshoot" of the game to talk about a specific position. For that purpose, I prefer the [go] tag.

_________________
Converting the book Shape UP! by Charles Matthews/Seong-June Kim
to the gobook format. last updated april 2015 - Index of shapes, p.211 / 216


This post by oca was liked by: Bonobo
Top
 Profile  
 
Offline
 Post subject: Re: Quick tool to convert EidoGo to [go] diagram
Post #5 Posted: Thu Mar 20, 2014 6:00 am 
Oza

Posts: 2180
Location: ʍoquıɐɹ ǝɥʇ ɹǝʌo 'ǝɹǝɥʍǝɯos
Liked others: 237
Was liked: 662
Rank: AGA 5d
GD Posts: 4312
Online playing schedule: Every tenth February 29th from 20:00-20:01 (if time permits)
RBerenguel wrote:
DrStraw wrote:
Well, very nice. But I cannot quite see why the go format would be preferred over the eidogo format.


For pasting specific positions or areas here, in this same forum or in Sensei's library. For example.


oh, yeah. I tend to forget about SL.

_________________
Still officially AGA 5d but I play so irregularly these days that I am probably only 3d or 4d over the board (but hopefully still 5d in terms of knowledge, theory and the ability to contribute).

Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group