How to convert vector<point3f> to homogenous
I tried converting to Mat but it doesn't work. I don't know how to use vectors because there is not Point4fPoint4f. This is the error I get if I use matrix input and output of converttohomogenous
OpenCV Error: Assertion failed (npoints >= 0) in cv::convertPointsToHomogeneous, file C:\Bin\opencv-master\source\modules\calib3d\src\fundam.cpp, line 965
vector<cv::Point3f> opencv_cloud(8);
//fill up
//Convert to homogenous mat
cv::Mat opencv_cloud_mat_homo, opencv_cloud_mat = cv::Mat(opencv_cloud).reshape(1).t();
cv::convertPointsToHomogeneous(opencv_cloud, opencv_cloud_mat_homo);
I have this but its manual and I dont know how to convert back to non homogenous i.e. divide the mat by the last row
//8 corners of aabb
vector<cv::Point3d> opencv_cloud(8), opencv_cloud_homo;
opencv_cloud[0] = cv::Point3d(-min.x, -min.y, min.z); opencv_cloud[1] = cv::Point3d(-min.x, -min.y, max.z);
opencv_cloud[2] = cv::Point3d(-max.x, -min.y, max.z); opencv_cloud[3] = cv::Point3d(-max.x, -min.y, min.z);
opencv_cloud[4] = cv::Point3d(-min.x, -max.y, min.z); opencv_cloud[5] = cv::Point3d(-min.x, -max.y, max.z);
opencv_cloud[6] = cv::Point3d(-max.x, -max.y, max.z); opencv_cloud[7] = cv::Point3d(-max.x, -max.y, min.z);
//Convert to homogenous mat
cv::Mat opencv_cloud_mat_homo, opencv_cloud_mat = cv::Mat(opencv_cloud).reshape(1).t();
cv::vconcat(opencv_cloud_mat, cv::Mat::ones(cv::Size(8, 1), CV_64FC1), opencv_cloud_mat_homo);