Python Forum
are these equation to PyOpenCV API function conversions correct?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
are these equation to PyOpenCV API function conversions correct?
#1
We wanted to try out the idea from this research paper:
http://faculty.ucmerced.edu/mhyang/paper...17_pen.pdf

A bit too math heavy for me.
The guy doing the math coding 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=1MBwM4E...y-3JNZbx5x

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", cv2.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 centre = 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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  To put a solution of an equation into a function pianistseb 6 3,273 Nov-11-2018, 08:22 PM
Last Post: pianistseb
  How to make my python 3.6 unnesting function correct? PrateekG 6 3,664 Jul-24-2018, 12:09 PM
Last Post: PrateekG

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020