Go image recognition.


Main function of the program.


Hough transform module.

class hough.Hough(size, dt, init_angle)[source]

Hough transform.

This class stores the parameters of the transformation.


Take a point from the transformed image and return the corresponding line in the original as (angle, distance) tuple.

classmethod default(image)[source]

Default parameters for Hough transform of the image.


Take a list of transformed points and return a list of corresponding lines as (angle, distance) tuples.

RANSAC estimation.

class ransac.Linear_model(data)[source]

Linear model for RANSAC.

ransac.estimate(data, dist, k, modelClass=<class ransac.Linear_model at 0x38f3870>, model=None)[source]

Estimate model from data with RANSAC.

ransac.filter_near(data, line, distance)[source]

Find points in data that are closer than distance to line.


The least squares method.

ransac.points_to_line((x1, y1), (x2, y2))[source]

Take two points, return coefficitiens for line that connects them.


Imago geometry module.

class geometry.V(x, y)[source]

Class for vector manipulation.

geometry.intersection(p, q)[source]

Return intersection of two lines.

geometry.l2ad((a, b), size)[source]

Represent line as (angle, distance).

Take a line (represented by two points) and image size. Return the line represented by its angle and distance from the center of the image.

geometry.line(x, y)[source]

Return parametric representation of line.


Image filters module.

All filters return a filtered copy of the image, the original image is preserved.


Stretch all color channels to their full range.

filters.components(image, diameter)[source]

Reduce each conected component to one point.


Edge detection (on BW images).

filters.high_pass(image, height)[source]

High pass filter (on BW images).


Peak filter (on BW images).


Lines finding module.

linef.find_lines(image, show_image, logger)[source]

Find lines in the image.

linef.line_from_angl_dist((angle, distance), size)[source]

Take angle and distance (from the center of the image) of a line and size of the image. Return the line represented by two points.

linef.prepare(image, show_image, logger)[source]

Return preproccessed image.


Run RANSAC on the image.

linef.transform(image, hough, show_image)[source]

Return Hough transform of the image.


Imago grid fitting module

RANSAC inspired method.

class gridf_new.Diagonal_model(data)[source]

Ransac model for finding diagonals.

class gridf_new.Line((a, b, c))[source]

Line with a list of important points that lie on it.

This and the Point class in this module serves to implement a model of perspective plain – a line has a list of intersections with other lines and each intersection has two lines that go through it.

class gridf_new.Point((x, y))[source]

Class that represents a point in 2D.

gridf_new.dst(p, l)[source]

Distance from a point to a line.

gridf_new.find(lines, size, l1, l2, bounds, hough, show_all, do_something, logger)[source]

Find the best grid given the lines and size of the image.

Last three parameters serves for debugging, l1, l2, bounds and hough are here for compatibility with older version of gridf, so they can be easily exchanged, tested and compared.

gridf_new.gen_corners(d1, d2, min_size)[source]

Generate candidates on corner positions from the diagonals.

gridf_new.intersection((a1, b1, c1), (a2, b2, c2))[source]

Intersection of two lines, given by coefficients in their equations.

gridf_new.plot_line(line, c, size)[source]

Plot a line with pyplot.

gridf_new.score(lines, points)[source]

Score the candidate for a grid.


Imago intersections module.

intrsc.b_intersects(image, lines, show_all, do_something, logger)[source]

Compute intersections.

intrsc.board(image, intersections, show_all, do_something, logger)[source]

Find stone colors and return board situation.


Return normalized line.


Return lines sorted by distance.

intrsc.intersections_from_angl_dist(lines, size, get_all=True)[source]

Take grid-lines and size of the image. Return intersections.


Return mean luminanace of the cluster of points.


Convert RGB to luminance and HSI model saturation.

intrsc.stone_color_raw(image, (x, y))[source]

Given image and coordinates, return stone color.

intrsc.to_general(line, size)[source]

Convert line from (angle, distance) to (a, b, c).


K-means module.


Find the centroid of the cluster.

k_means.cluster(k, d, data, i_centers=None)[source]

Find k clusters on d dimensional data., c2)[source]

Find the absolute distance between two lists of points.

k_means.nearest(centers, point)[source]

Find the nearest cluster center for point.

k_means.next_step(centers, data)[source]

Compute new clusters and centers.


Manual grid selection module


Run the GUI.


Imago output module.

class output.Board(size, stones)[source]

Represents the state of the board.


Add move to the board.


Returns SGF (set position) representation of the position.


Take the next board in game and return a list of moves that are new.

class output.Game(size, board=None, debug=True)[source]

Represents a game.


Add next move to the game.


Return the game representation as SGF string.

class output.Move(color, y, x, comment=None)[source]

Repsresents a move.


Return coordinates of the move in SGF.


Debugging image display.

This is a simple module that shows images on screen using PyGame. It is not used anywhere in the standard UI, serves only for debugging., caption='', name=None)[source]

Initialize PyGame and show the image.


Camera module.

This module handles various backends (different for every OS) for streaming the video from a (web)camera.

class camera.Camera(vid=0, res=None)[source]

Implement basic camera capabilities

This class has different implementations for different OS. On posix systems it calls to opencv, on Windows to VideoCapture.


Get a new image from the camera.


Go image capture.

This module defines a UI for capturing images with a (web)camera and imediately proccessing them with Imago.

class capture.Capture(device, res)[source]

This object maintains communication between the camera, the PyGame screen and Imago.


Take new image every interval seconds.


Run live preview on the screen.


Take images manualy by pressing a key.


Take a new image from the camera.

class capture.Screen(res)[source]

Basic PyGame setup.


Display image on PyGame screen.


Parse the argument and setup the UI.


Go timer.

This module defines a UI that combines game clock with automatic game recording. When player presses the clock, an image of the board is taken. The sequence of images can later be analysed by Imago to produce a game record in abstract notation.

class timer.Timer(main_time, byop, byot)[source]

Keeps track of time remaining one player.


Return string representation of remaining time.


Return True if the clock is running.


Start the clock.


Stop the clock.


Parse the arguments and run the clock.

Table Of Contents

Previous topic


This Page