Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Error "Assertion failed (scn == 3 || scn == 4) in cvtColor" when calculating ORB features on point cloud

My task is to register image from camera to point cloud of scene using C++. My intuition here is to calculate ORB descriptors on both camera image and point cloud of scene so I can obtain point correspondences btw them and apply SolvePnP function to estimate the camera pose. I following this tutorial. I load the point cloud of scene in PLY format to cv::Mat and try to calculate ORB decriptors on it. Resultant Mat object has single channel. Here is my code:

Mat scene_mat = loadPLYSimple("a_cloud.ply", 1);

vector<KeyPoint> kp1, kp2;
Mat des1, des2;
Ptr<Feature2D> orb = ORB::create();

orb->detectAndCompute(scene_mat, Mat(), kp2, des2);

When run this code I get error

OpenCV Error: Assertion failed (scn == 3 || scn == 4) in cvtColor, file /home/vladimir/opencv/modules/imgproc/src/color.cpp, line 7564 terminate called after throwing an instance of 'cv::Exception'

What is the problem with this code? Is this correct way to calculate ORB descriptors on point cloud?

Error "Assertion failed (scn == 3 || scn == 4) in cvtColor" when calculating ORB features on point cloud

My task is to register image from camera to point cloud of scene using C++. My intuition here is to calculate ORB descriptors on both camera image and point cloud of scene so I can obtain point correspondences btw them and apply SolvePnP function to estimate the camera pose. I following this tutorial. I load the point cloud of scene in PLY format to cv::Mat and try to calculate ORB decriptors on it. Resultant Mat object has single channel. Here is my code:

Mat scene_mat = loadPLYSimple("a_cloud.ply", 1);

vector<KeyPoint> kp1, kp2;
Mat des1, des2;
Ptr<Feature2D> orb = ORB::create();

orb->detectAndCompute(scene_mat, Mat(), kp2, des2);

When run this code I get error

OpenCV Error: Assertion failed (scn == 3 || scn == 4) in cvtColor, file /home/vladimir/opencv/modules/imgproc/src/color.cpp, line 7564 terminate called after throwing an instance of 'cv::Exception'

What is the problem with this code? Is this correct way to calculate ORB descriptors on point cloud?