コード例 #1
0
  def process(self, stream):
    start_time = time.time()
    image = cv2.imdecode(np.fromstring(stream.getvalue(), dtype=np.uint8), 1)

    if(self.sizes_calculated == False):
      self.calculate_sizes(image)

    faceRects = self.faces(image)
    for (x, y, w, h) in faceRects:
      cv2.rectangle(image, (x, y), (x + w, y + h), (0, 255, 0), 2)

    if (len(faceRects) > 0):
      (x, y, w, h) = faceRects[0]
      self.move(x + (w/2))
    else:
      print("no faces found")
      gopigo.stop()

    print(time.time() - start_time)
    #pdb.set_trace()

    cv2.line(image, (self.segment_detector.left_cutoff, 0), (self.segment_detector.left_cutoff, self.height), (255, 0, 0), 1)
    cv2.line(image, (self.segment_detector.right_cutoff, 0), (self.segment_detector.right_cutoff, self.height), (255, 0, 0), 1)

    return cv2.imencode('.jpg', image)[1].tostring()
コード例 #2
0
 def test_stop(self):
     gopigo.stop()