Example #1
0
  def callback(self,data):
    try:
      cv_image = cv.GetImage(self.bridge.imgmsg_to_cv(data, "mono8")) 

      koki = PyKoki()

      params = CameraParams(Point2Df( cv_image.width/2, cv_image.height/2 ),
                          Point2Df(571, 571),
                          Point2Di( cv_image.width, cv_image.height ))

      markers = koki.find_markers( cv_image, 0.1, params )

      seencodes=[]
      seenmarkers=[]
      #rospy.logwarn(markers)
      for m in markers:
	  markerinfo=Kokimarker()
          rospy.loginfo("Code: " + str(m.code))
          rospy.loginfo("Bearing: " + str(m.bearing))
          rospy.loginfo("distance: " + str(m.distance))
          seencodes.append(m.code)
	  markerinfo.ID = m.code
          markerinfo.bearing = m.bearing
          markerinfo.distance = m.distance
          seenmarkers.append(markerinfo)
          

    except CvBridgeError, e:
      rospy.logwarn(str(e))
      """print 'did not get image'"""
#!/usr/bin/env python
from pykoki import PyKoki, Point2Di, Point2Df, CameraParams
import cv, cv2
import sys

if len(sys.argv) != 2:
    print >> sys.stderr, "opencv_example.py IMG_FILE"
    exit(1)

img = cv.LoadImage(sys.argv[1], cv.CV_LOAD_IMAGE_GRAYSCALE)

koki = PyKoki()

params = CameraParams(Point2Df(img.width / 2, img.height / 2),
                      Point2Df(571, 571), Point2Di(img.width, img.height))

print koki.find_markers(img, 0.1, params)
#!/usr/bin/env python
from pykoki import PyKoki, Point2Di, Point2Df, CameraParams
import cv, cv2
import sys

if len(sys.argv) != 2:
    print >>sys.stderr, "opencv_example.py IMG_FILE"
    exit(1)

img = cv.LoadImage( sys.argv[1], cv.CV_LOAD_IMAGE_GRAYSCALE )

koki = PyKoki()

params = CameraParams(Point2Df( img.width/2, img.height/2 ),
                      Point2Df(571, 571),
                      Point2Di( img.width, img.height ))

print koki.find_markers( img, 0.1, params )