Exemplo n.º 1
0
def main():
  """The main entry point of the program."""

  # Check the command-line arcuments.
  if len(sys.argv) < 2:
    print('usage: aruco.py input.png')
    sys.exit(1)

  cv.NamedWindow("test",cv.CV_WINDOW_AUTOSIZE)
  
  # Load image into required formats
  #im = PImage.open(sys.argv[1]).convert('RGB')
  cv_im = cv.LoadImage(sys.argv[1])
  im = PImage.fromstring('RGB',cv.GetSize(cv_im),cv_im.tostring())
  
  # Find midpoint of image
  cv_im_size = cv.GetSize(cv_im)
  cv_im_midp = (cv_im_size[0]/2,cv_im_size[1]/2)
  print cv_im_midp

  #arr = array(im) #will need this if wanting to draw onto image
  
  # Detect markers and draw a line from the frame center to the marker center
  for m in detect_markers(im):
	  coord = (m.centroid_x(), m.centroid_y())
	  print coord
	  print m.id()
	  cv.Line(cv_im,cv_im_midp,coord,cv.Scalar(200,200,200))

  cv.ShowImage("test",cv_im)
  
  cv.WaitKey()
Exemplo n.º 2
0
def main():
  """The main entry point of the program."""

  # Check the command-line arcuments.
  if len(sys.argv) < 3:
    print('usage: aruco.py input.png output.png')
    sys.exit(1)

  # This is probably the simplest possible example.
  im = Image.open(sys.argv[1]).convert('RGB')
  arr = array(im)
  [m.draw(arr) for m in detect_markers(im)]
  Image.fromarray(arr).save(sys.argv[2], 'PNG')