Opencv (4.5.1) error: assertion failed (((npoints > = 4) | (npoints = = 3 & & flags = = s)

Solve the problem of solvepnp (outdim, indim, cameramatrix, distcoeff, RVEC, tvec); There is an unhandled exception at 0x00007ffbc3844b89 (in biaoding.exe): Microsoft C + + exception: CV:: exception, in the memory location of 0x000000571351b2d0
 
Mapping 3D point cloud to 2D image, using OpenCV solvepnp, running error

OpenCV(4.5.1) Error: Assertion failed (( (npoints >= 4) || (npoints == 3 && amp; flags == SOLVEPNP_ ITERATIVE && amp; useExtrinsicGuess) || (npoints >= 3 && amp; flags == SOLVEPNP_ SQPNP) ) && amp; npoints == std::max(ipoints.checkVector(2, CV_ 32F), ipoints.checkVector(2, CV_ 64F))) in cv::solvePnPGeneric, file C:\build\master_ winpack-build-win64-vc15\opencv\modules\calib3d\src\solvepnp.cpp, line 802

The error is as follows:

The input coordinates of 3D point cloud and 2D pixel are:

Conversion type:

After the conversion, the output of outdim and indim is changed, and it is no longer a 6 * 3 matrix, so an error will be reported

So the error is because the matrix dimensions in solvepnp are inconsistent. The solution is to use push again in the most stupid way_ Back redefines outdim and indim, instead of using for loop to define outdim and indim, just in case cameramatrix is also redefined

Finally, the rotation translation matrix from radar to camera and the result map of point cloud mapping to image are obtained

 

Read More: