File: classifier.py

package info (click to toggle)
gamera 3.4.1%2Bsvn1423-4
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 22,292 kB
  • ctags: 25,015
  • sloc: xml: 122,324; ansic: 50,812; cpp: 50,489; python: 34,987; makefile: 119; sh: 101
file content (31 lines) | stat: -rw-r--r-- 716 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import sys

def my_application():
   global ccs

   # Load the image
   image = load_image(sys.argv[-1])
   onebit = image.to_onebit()
   # Get the connected components from the image
   ccs = onebit.cc_analysis()
   # Classify the cc's
   classifier.classify_list_automatic(ccs)

   # Display the ccs to show their classification
   display_multi(ccs)

# Import the Gamera core and initialise it
from gamera.core import *
init_gamera()

# Import the classifier module
from gamera import knn
# Create a new classifier
classifier = knn.kNNInteractive()
# Load some training data
classifier.from_xml_filename("training.xml")

# Import the Gamera GUI and start it   
from gamera.gui import gui
gui.run(my_application)