cpp-tutorial-pnp_registration throw error [closed]

asked 2017-06-05 13:45:28 -0600

double gravatar image

updated 2017-06-06 12:06:40 -0600

Hi everyone,

I am trying to use cpp-tutorial-pnp_registration in opencv sample code whose location is /home/*/opencv-3.2.0/samples/cpp/tutorial_code/calib3d/real_time_pose_estimation/src/main_registration.cpp

I just try to use opencv original data resized_IMG_3875.JPG and box.ply to get textured 3D model (yml file), however, opencv throw the following error for me:

--------------------------------------------------------------------------
This program shows how to create your 3D textured model. 
Usage:
./cpp-tutorial-pnp_registration
--------------------------------------------------------------------------

init done
Click the box corners ...
Waiting ...
COMPUTING POSE ...
OpenCV Error: Assertion failed (npoints >= 0 && npoints == std::max(ipoints.checkVector(2, CV_32F), ipoints.checkVector(2, CV_64F))) in solvePnP, file /tmp/binarydeb/ros-kinetic-opencv3-3.2.0/modules/calib3d/src/solvepnp.cpp, line 63
terminate called after throwing an instance of 'cv::Exception'
  what():  /tmp/binarydeb/ros-kinetic-opencv3-3.2.0/modules/calib3d/src/solvepnp.cpp:63: error: (-215) npoints >= 0 && npoints == std::max(ipoints.checkVector(2, CV_32F), ipoints.checkVector(2, CV_64F)) in function solvePnP

Aborted (core dumped)

I am not sure what the problem is and could you give me some idea? Any idea will be appreciate.

Thanks in advance.

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by berak
close date 2017-06-06 16:26:22.044294

Comments

No problem for me. You have to clic at least 4 points to use this program

LBerger gravatar imageLBerger ( 2017-06-05 14:24:23 -0600 )edit

Thanks for your quick reply. after I run ./cpp-tutorial-pnp_registration, the window is closed quickly and I don't have time to clic in the window.

double gravatar imagedouble ( 2017-06-05 14:27:29 -0600 )edit

i check the picture in the window, it is black and does not show the box figure.

double gravatar imagedouble ( 2017-06-05 14:31:18 -0600 )edit

How do you run ? click or open terminal ? do you use windows or linux?

LBerger gravatar imageLBerger ( 2017-06-05 14:36:55 -0600 )edit

I use ubuntu 16.04 and I can attach my screen shot of my pc.

double gravatar imagedouble ( 2017-06-05 14:55:53 -0600 )edit

I use windows and I'm not a linux specialist. Have you seen this image ? If no program try to load this image from this folder : "../../samples/cpp/tutorial_code/calib3d/real_time_pose_estimation/" ?

LBerger gravatar imageLBerger ( 2017-06-05 15:13:56 -0600 )edit

if you arrive at "COMPUTING POSE ...", you're already behind the "wait for clicks" loop.

maybe it's just paranoid, but it might suffer from the "waitkey does not return -1" bug (which was around in early 3.2.0).

could you try to change this line to

while ( waitKey(30) != 27 )

(and then, break out if the loop by pressing the escape key)

well, if that should fix it, you still want to update to latest github master branch, i guess...

berak gravatar imageberak ( 2017-06-06 00:14:57 -0600 )edit
1

Yes, it fixed. Thanks! i will update it.

double gravatar imagedouble ( 2017-06-06 11:29:54 -0600 )edit

again, that was a shortlived bug, which was fixed in the meantime, so please update your opencv libs.

berak gravatar imageberak ( 2017-06-06 11:53:57 -0600 )edit