Javadoc link

TopCodes service allows to recognize a special code. You can print these codes using the attached topcodes.pdf.

The service gives back the following information :

  • Number of the code recognized
  • Coordinates of the center of the code (x,y)
  • Diameter of the code (which can be used to find distance)
  • Angular rotation of the code

​THERE ARE 99 DIFFERENT CODES.

CAMERA SHOULD BE AS PERPENDICULAR AS POSSIBLE TO THE CODE, IN ORDER TO WORK WELL.

References :

[[/service/TopCodes.py]]

Example code (from branch develop):
from org.myrobotlab.opencv import OpenCVData
from org.myrobotlab.service import OpenCV
 
opencv = Runtime.create("opencv","OpenCV")
topcodes = runtime.start("topcodes","TopCodes")
opencv.startService()
opencv.addFilter("PyramidDown1", "PyramidDown")
 
def input(data) :
 simage = opencv.getDisplay()
 codes = topcodes.scan(simage.getImage())
 limit = codes.size()
 for x in range(limit) :
    code = codes.get(x)
    print 'code number' , x ,'=', code.getCode()
# other information could be provided
    #print 'diameter' , x , 'is' , code.getDiameter()
    #print 'x of center' , x , 'is' , code.getCenterX()
    #print 'y of center' , x , 'is' , code.getCenterY()
    #print 'rotation' , x , 'is' , code.getOrientation() , 'radians'
opencv.addListener("publishOpenCVData", python.name, "input");
opencv.setCameraIndex(0)
opencv.capture()
Example configuration (from branch develop):
!!org.myrobotlab.service.config.ServiceConfig
listeners: null
peers: null
type: TopCodes