parameters: ()
return_statement: return s, vals
docstring: for i in np.arange(0, n_algos):
          print 'mean_err_t_' + algo_names[i] + '=', mean_err_t[i], 'median_err_t_' + algo_names[i] + '=', median_err_t[i]
          print 'mean_err_q_' + algo_names[i] + '=', mean_err_q[i], 'median_err_q_' + algo_names[i] + '=', median_err_q[i]
docstring_summary: for i in np.arange(0, n_algos):
          print 'mean_err_t_' + algo_names[i] + '=', mean_err_t[i], 'median_err_t_' + algo_names[i] + '=', median_err_t[i]
          print 'mean_err_q_' + algo_names[i] + '=', mean_err_q[i], 'median_err_q_' + algo_names[i] + '=', median_err_q[i]
docstring_tokens: for i in np . arange ( 0 n_algos ) : print mean_err_t_ + algo_names [ i ] + = mean_err_t [ i ] median_err_t_ + algo_names [ i ] + = median_err_t [ i ] print mean_err_q_ + algo_names [ i ] + = mean_err_q [ i ] median_err_q_ + algo_names [ i ] + = median_err_q [ i ]
function: def err_plot():
      # Test 1
      # Define object points and image points
  
      obj_pts = np.random.randint(-40, 40, [n, 3])
      obj_pts = obj_pts.astype(float)
      obj_pts[0, :] = [0, 0, 0]
      img_pts = np.empty([n, 3])
      img_pts[:, 2] = 1
  
      pose_est = np.empty([6, 1])
      pose_act = np.empty([6, 1])
  
      err_net_t = []
      err_net_q = []
  
      for it in np.arange(0, n_iter):
  
          # Generate random camera extrinsic matrix
          v = 2 * np.random.random([3]) - np.array([1, 1, 1])
          v = v / np.linalg.norm(v)
  
          #R=np.array([[0.841986, -0.352662, -0.408276],[0.308904,  0.935579, -0.171085],[0.442309, 0.0179335,  0.896683]])
          R = vector2RotMat(v, np.pi * 2 / 3)
          q = RotMat2quat(R)
          t = np.array([0.0, 0.0, 200.0])
  
          # Compute image points based on actual extrinsic matrix and add noise to measurements
          for i in range(0, n):
              pt = np.dot(R, obj_pts[i, :]) + t
              img_pts[i, 0:2] = np.array([pt[0] / pt[2], pt[1] / pt[2]])
  
          img_pts[:, 0:2] = img_pts[:, 0:2] + sigma * np.random.randn(n, 2)
  
          pose_act[0:3, 0] = t
          pose_act[3:6, 0] = q[1:4]
  
          # Use the c-library to compute the pose
          err_t = []
          err_q = []
          for i in np.arange(0, n_algos):
              algos[i](obj_pts, img_pts, n, cam_intrinsic, pose_est)
              e = calc_err(pose_est, pose_act)
              err_t.append(e[0])
              err_q.append(e[1])
  
              if np.isnan(e[0]) or np.isnan(e[1]):
                  print('algo=\n', algo_names[i])
                  print('err=\n', e)
  
          err_net_t.append(err_t)
          err_net_q.append(err_q)
          printProgress(it, n_iter, prefix='Test' + str(1) +
                        ' Progress:', suffix='Complete', barLength=50)
      mean_err_t = np.mean(err_net_t, axis=0)
      mean_err_q = np.mean(err_net_q, axis=0)
      median_err_t = np.median(err_net_t, axis=0)
      median_err_q = np.median(err_net_q, axis=0)
  
      vals = np.empty([7, 4])
      vals[:, 0] = mean_err_t
      vals[:, 1] = median_err_t
      vals[:, 2] = mean_err_q
      vals[:, 3] = median_err_q
      """
      for i in np.arange(0, n_algos):
          print 'mean_err_t_' + algo_names[i] + '=', mean_err_t[i], 'median_err_t_' + algo_names[i] + '=', median_err_t[i]
          print 'mean_err_q_' + algo_names[i] + '=', mean_err_q[i], 'median_err_q_' + algo_names[i] + '=', median_err_q[i]
      """
      it = np.arange(0, n_iter)
  
      err_net_t = np.array(err_net_t)
      err_net_q = np.array(err_net_q)
  
      s = '<h2> Translation error and Rotation error for 100 iterations (R - Randomly varying, t - fixed) </h2>'
  
      s1 = display_comparison_plot_mpld3(it, err_net_t, names=algo_names, line_styles=algo_ls,
                                         title='% Translation Error Plot', xtitle='Iteration', ytitle='e_t', ylim=[0, 2], figname='err_t')
      s2 = display_comparison_plot_mpld3(it, err_net_q, names=algo_names, line_styles=algo_ls,
                                         title='Rotation Error Plot (deg)', xtitle='Iteration', ytitle='e_q', ylim=[0, 1], figname='err_q')
  
      s = s + '\n <table > \n <tr > \n <td > \n' + s1 + \
          '</td > \n <td> \n' + s2 + '</td> \n </tr> \n </table> \n'
  
      return s, vals
  
      """
      comp_arr = np.zeros([n_iter,2])
      for i in np.arange(0,n_iter):
          comp_arr[i,:] = 2*mean_err_p3p
      nconv_epnp = float(np.sum(err_epnp>comp_arr))/n_iter*100
      nconv_dls  = float(np.sum(err_dls>comp_arr))/n_iter*100
      nconv_ppnp  = float(np.sum(err_ppnp>comp_arr))/n_iter*100
      nconv_posit  = float(np.sum(err_posit>comp_arr))/n_iter*100
      nconv_lhm  = float(np.sum(err_lhm>comp_arr))/n_iter*100
      nconv_p3p  = float(np.sum(err_p3p>comp_arr))/n_iter*100
      plt.figure()
      xvals = ['epnp', 'dls', 'ppnp', 'posit','lhm', 'p3p']
      xvals_int = np.arange(0,n_algos)
      yvals = [nconv_epnp, nconv_dls, nconv_ppnp, nconv_posit, nconv_lhm, nconv_p3p]
      plt.bar(xvals_int, yvals, align='center')
      plt.xticks(xvals_int, xvals)
      plt.title('%Divergence')
      plt.show()
      plt.savefig('divergence.pdf')
      """
function_tokens: def err_plot ( ) : # Test 1 # Define object points and image points obj_pts = np . random . randint ( - 40 , 40 , [ n , 3 ] ) obj_pts = obj_pts . astype ( float ) obj_pts [ 0 , : ] = [ 0 , 0 , 0 ] img_pts = np . empty ( [ n , 3 ] ) img_pts [ : , 2 ] = 1 pose_est = np . empty ( [ 6 , 1 ] ) pose_act = np . empty ( [ 6 , 1 ] ) err_net_t = [ ] err_net_q = [ ] for it in np . arange ( 0 , n_iter ) : # Generate random camera extrinsic matrix v = 2 * np . random . random ( [ 3 ] ) - np . array ( [ 1 , 1 , 1 ] ) v = v / np . linalg . norm ( v ) #R=np.array([[0.841986, -0.352662, -0.408276],[0.308904,  0.935579, -0.171085],[0.442309, 0.0179335,  0.896683]]) R = vector2RotMat ( v , np . pi * 2 / 3 ) q = RotMat2quat ( R ) t = np . array ( [ 0.0 , 0.0 , 200.0 ] ) # Compute image points based on actual extrinsic matrix and add noise to measurements for i in range ( 0 , n ) : pt = np . dot ( R , obj_pts [ i , : ] ) + t img_pts [ i , 0 : 2 ] = np . array ( [ pt [ 0 ] / pt [ 2 ] , pt [ 1 ] / pt [ 2 ] ] ) img_pts [ : , 0 : 2 ] = img_pts [ : , 0 : 2 ] + sigma * np . random . randn ( n , 2 ) pose_act [ 0 : 3 , 0 ] = t pose_act [ 3 : 6 , 0 ] = q [ 1 : 4 ] # Use the c-library to compute the pose err_t = [ ] err_q = [ ] for i in np . arange ( 0 , n_algos ) : algos [ i ] ( obj_pts , img_pts , n , cam_intrinsic , pose_est ) e = calc_err ( pose_est , pose_act ) err_t . append ( e [ 0 ] ) err_q . append ( e [ 1 ] ) if np . isnan ( e [ 0 ] ) or np . isnan ( e [ 1 ] ) : print ( 'algo=\n' , algo_names [ i ] ) print ( 'err=\n' , e ) err_net_t . append ( err_t ) err_net_q . append ( err_q ) printProgress ( it , n_iter , prefix = 'Test' + str ( 1 ) + ' Progress:' , suffix = 'Complete' , barLength = 50 ) mean_err_t = np . mean ( err_net_t , axis = 0 ) mean_err_q = np . mean ( err_net_q , axis = 0 ) median_err_t = np . median ( err_net_t , axis = 0 ) median_err_q = np . median ( err_net_q , axis = 0 ) vals = np . empty ( [ 7 , 4 ] ) vals [ : , 0 ] = mean_err_t vals [ : , 1 ] = median_err_t vals [ : , 2 ] = mean_err_q vals [ : , 3 ] = median_err_q it = np . arange ( 0 , n_iter ) err_net_t = np . array ( err_net_t ) err_net_q = np . array ( err_net_q ) s = '<h2> Translation error and Rotation error for 100 iterations (R - Randomly varying, t - fixed) </h2>' s1 = display_comparison_plot_mpld3 ( it , err_net_t , names = algo_names , line_styles = algo_ls , title = '% Translation Error Plot' , xtitle = 'Iteration' , ytitle = 'e_t' , ylim = [ 0 , 2 ] , figname = 'err_t' ) s2 = display_comparison_plot_mpld3 ( it , err_net_q , names = algo_names , line_styles = algo_ls , title = 'Rotation Error Plot (deg)' , xtitle = 'Iteration' , ytitle = 'e_q' , ylim = [ 0 , 1 ] , figname = 'err_q' ) s = s + '\n <table > \n <tr > \n <td > \n' + s1 + '</td > \n <td> \n' + s2 + '</td> \n </tr> \n </table> \n' return s , vals """
      comp_arr = np.zeros([n_iter,2])
      for i in np.arange(0,n_iter):
          comp_arr[i,:] = 2*mean_err_p3p
      nconv_epnp = float(np.sum(err_epnp>comp_arr))/n_iter*100
      nconv_dls  = float(np.sum(err_dls>comp_arr))/n_iter*100
      nconv_ppnp  = float(np.sum(err_ppnp>comp_arr))/n_iter*100
      nconv_posit  = float(np.sum(err_posit>comp_arr))/n_iter*100
      nconv_lhm  = float(np.sum(err_lhm>comp_arr))/n_iter*100
      nconv_p3p  = float(np.sum(err_p3p>comp_arr))/n_iter*100
      plt.figure()
      xvals = ['epnp', 'dls', 'ppnp', 'posit','lhm', 'p3p']
      xvals_int = np.arange(0,n_algos)
      yvals = [nconv_epnp, nconv_dls, nconv_ppnp, nconv_posit, nconv_lhm, nconv_p3p]
      plt.bar(xvals_int, yvals, align='center')
      plt.xticks(xvals_int, xvals)
      plt.title('%Divergence')
      plt.show()
      plt.savefig('divergence.pdf')
      """