Code Monkey home page Code Monkey logo

lookup's Introduction

Lookup

It is a nice, simple and friendly to use library which helps you to lookup objects on a screen. Also it has a OCR functionality. Using Lookup you can do Java OCR tricks like recognizing any infromation from your Robot application. Which can be usefull for debuging or automating things.

OCR functionality

If you need to encode special symbols use UNICODE in the file name. For example if you need to have '' character (which is prohibited in the path and file name) specify %2F.png as a image symbol name.

Sometimes you need specify two different image for one symbol (if image / font symbol varry too mutch). To do so add unicode ZERO WIDTH SPACE symbol to the filename. Like that %2F%E2%80%8B.png will produce '/' symbol as well.

package com.github.axet.lookup;

import java.io.File;

import com.github.axet.lookup.common.ImageBinaryGrey;

public class OCRTest {

    static public void main(String[] args) {
        OCR l = new OCR(0.70f);

        // will go to com/github/axet/lookup/fonts folder and load all font
        // familys (here is only font_1 family in this library)
        l.loadFontsDirectory(OCRTest.class, new File("fonts"));

        // example how to load only one family
        // "com/github/axet/lookup/fonts/font_1"
        l.loadFont(OCRTest.class, new File("fonts", "font_1"));

        String str = "";

        // recognize using all familys set
        str = l.recognize(Capture.load(OCRTest.class, "test3.png"));
        System.out.println(str);

        // recognize using only one family set
        str = l.recognize(Capture.load(OCRTest.class, "test3.png"), "font_1");
        System.out.println(str);

        // recognize using only one family set and rectangle
        ImageBinaryGrey i = new ImageBinaryGrey(Capture.load(OCRTest.class, "full.png"));
        str = l.recognize(i, 1285, 654, 1343, 677, l.getSymbols("font_1"));
        System.out.println(str);
    }
}

Lookup methods

package com.github.axet.lookup;

import java.awt.Point;
import java.awt.image.BufferedImage;
import java.util.Collections;
import java.util.List;

import com.github.axet.lookup.common.GFirst;
import com.github.axet.lookup.common.GPoint;
import com.github.axet.lookup.common.ImageBinaryGreyScale;

public class SNCCTest {

    public static void main(String[] args) {
        BufferedImage image = Capture.load(OCRTest.class, "desktop.png");
        BufferedImage templateSmall = Capture.load(OCRTest.class, "desktop_feature_small.png");
        BufferedImage templateBig = Capture.load(OCRTest.class, "desktop_feature_big.png");

        LookupScale s = new LookupScale(0.2f, 10, 0.65f, 0.95f);

        ImageBinaryGreyScale si = new ImageBinaryGreyScale(image);

        ImageBinaryGreyScale stBig = new ImageBinaryGreyScale(templateBig);
        ImageBinaryGreyScale stSmall = new ImageBinaryGreyScale(templateSmall);

        Long l;

        System.out.println("big");
        l = System.currentTimeMillis();
        {
            List<GPoint> pp = s.lookupAll(si, stBig);

            Collections.sort(pp, new GFirst());

            for (GPoint p : pp) {
                System.out.println(p);
            }
        }
        System.out.println(System.currentTimeMillis() - l);

        System.out.println("small");
        l = System.currentTimeMillis();
        {
            List<GPoint> pp = s.lookupAll(si, stSmall);

            Collections.sort(pp, new GFirst());

            for (GPoint p : pp) {
                System.out.println(p);
            }
        }
        System.out.println(System.currentTimeMillis() - l);

        System.out.println("big");
        l = System.currentTimeMillis();
        {
            List<GPoint> pp = s.lookupAll(si, stBig);

            Collections.sort(pp, new GFirst());

            for (GPoint p : pp) {
                System.out.println(p);
            }
        }
        System.out.println(System.currentTimeMillis() - l);

    }
}

Central Maven Repo

    <dependency>
      <groupId>com.github.axet</groupId>
      <artifactId>lookup</artifactId>
      <version>0.1.29</version>
    </dependency>

lookup's People

Contributors

axet avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.