I am working on a project where I require to track aerial objects and calculate the six degree of freedom.
I am currently tracking colored balls , and calculating their center in rgb_frame, and using the center values to find the depth in the depth_frame.
After finding the depth(Z) in real-world co-ords,I am calculating the real-world X and Y using equations: X = (Zu)/fx and Y = (Zv)/fy , where fx,fy are the focal length obtained from the kinect's intrinsic params ,and u and v in this case are the center's x,y values.
I am treating (u,v) as image point and (X,Y,Z) as image point and feeding into this method: solvePnP
obj_pts = np.array([[X,Y,Z]],np.float64)
img_pts = np.array([[u,v]],np.float64)
ret,rvecs,tvecs = cv2.solvePnP(obj_pts,img_pts,camera_matrix2,np_dist_coefs)
I expect to find the rvecs which I will use as input for:
cv2.Rodrigues(rvecs)
to get the euler angles namely, pitch, yaw, roll.
I am presently having issues with the solvePnP call, which gives me the following error:
/opencv-3.0.0/modules/calib3d/src/solvepnp.cpp:61: error: (-215) npoints >= 0 && npoints == std::max(ipoints.checkVector(2, CV_32F), ipoints.checkVector(2, CV_64F)) in function solvePnP
I also understand that sending just the center's object and image points is not recommended. By this is my first step towards the realization. I intend to use feature detectors like SIFT to make it more interesting later.
Can anyone please suggest on my approach and help me accomplish finding the six degrees of freedom:
forward/back, up/down, left/right, pitch, yaw, roll
.