are these algorithm to OpenCV API function conversions correct?

asked 2018-10-06 09:42:09 -0600

jasper12 gravatar image

updated 2018-10-06 09:56:05 -0600

We wanted to try out the idea from this research paper: http://faculty.ucmerced.edu/mhyang/pa...

A bit too math heavy for me. The guy doing the math coding part wasn't able to finish it by testing it out and left. I payed him for the job so just want to maker sure I haven't been completely screwed over. The code is in Python and uses PyOpenCV functions and just two Numpy functions for matrix math. The full code can be found here, I have no problem open sourcing it on Github if it actually works: https://drive.google.com/open?id=1MBw...

Here's the equations/algorithms I want to verify was properly or fully converted to code.

1) Page 3, "Approximate Pose Estimation", figure 2 was converted to: aruco.estimatePoseSingleMarkers()

rotation_vector, translation_vector, _model_points = cv2.aruco.estimatePoseSingleMarkers(marker_corners, marker_length, camera_matrix, dist_coeffs)

2) Page 3, "Inter-Frame Corner Tracking", calcOpticalFlowPyrLK() was used.

def calc_optical_flow(prev_img, next_img, prev_pts, next_pts):
    next_pts, _status, _err = cv2.calcOpticalFlowPyrLK((prev_img, next_img, prev_pts, next_pts))
    return next_pts

3) Page 3, "Dense Pose Refinement", numpy.linalg.lstsq() was used which is a Nmpy function which "returns the least-squares solution to a linear matrix equation"

def refine_pose(rotation_vector, translation_vector):
    leastsq_sol, sum_residuals, rank, singular = np.linalg.lstsq(rotation_vector, translation_vector, rcond=None)
    return leastsq_sol, singular

4) Page 4, "Dodecahedron Calibration", equations was converted to few functions and don't expect anyone to read through all of it, that's fine. That said the code is in the file "dodec_calibration.py" if anyone will want to have a look.

5) Page 4, "Pen Tip Calibration", few equations were converted to numpy.linalg.solve() which is a Numpy function which "solves a linear matrix equation".

def calibrate_pen(object_rotation_matrix, translation_vector):
    centre = np.linalg.solve(object_rotation_matrix, translation_vector)
    print('Centre of pen-tip sphere: {}'.format(centre))
    return centre

That's all. Thanks in advance.

edit retag flag offensive close merge delete