Ask Your Question
0

error when trying to run cpp-tutorial-pnp_detection [closed]

asked 2015-11-17 11:02:12 -0500

pmousoul gravatar image

updated 2015-11-17 11:06:42 -0500

Hello,

I'm trying to run this tutorial: http://docs.opencv.org/3.0-beta/doc/t...

with OpenCV 3.0 and I get the following error:

OpenCV Error: Assertion failed (channels() == CV_MAT_CN(dtype)) in copyTo, file /home/pmousoul/Downloads/opencv3/opencv/modules/core/src/copy.cpp, line 257
terminate called after throwing an instance of 'cv::Exception'
  what():  /home/pmousoul/Downloads/opencv3/opencv/modules/core/src/copy.cpp:257: error: (-215) channels() == CV_MAT_CN(dtype) in function copyTo

Aborted (core dumped)

Can someone please tell me what I'm I doing wrong?

edit: My OpenCV 3.0 version is: OpenCV version: 3.0.0-dev OpenCV VCS version: 3.0.0-699-gb3ac274

Thank you for your time, Cheers, Panos

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by pmousoul
close date 2016-02-11 08:42:39.333476

1 answer

Sort by ยป oldest newest most voted
0

answered 2015-11-19 06:50:26 -0500

I guess this is the code snippet that generated the error

/** Load a YAML file using OpenCV **/
void Model::load(const std::string path)
{
    cv::Mat points3d_mat;

    cv::FileStorage storage(path, cv::FileStorage::READ);
    storage["points_3d"] >> points3d_mat;
    storage["descriptors"] >> descriptors_;

    points3d_mat.copyTo(list_points3d_in_);

    storage.release();

}

Now the only reason why this would fail with the given exception, is that the FileStorage location is not read correctly and thus the data inside the points3d_mat are not correct.

Could you start by providing an absolute path instead of using the path variable and see if that works?

edit flag offensive delete link more

Comments

1

Yes you are right - it was my mistake. I did not generate properly the required input files.

pmousoul gravatar imagepmousoul ( 2015-11-19 14:31:48 -0500 )edit

Could you mark the question as solved then?

StevenPuttemans gravatar imageStevenPuttemans ( 2015-11-20 04:41:37 -0500 )edit

@StevenPuttemans@pmousoul Can you please help me in compiling the code. I want to run cpp-tutorial-pnp_detection but I am unable to understand where to make the build folder and compile it. Please help

nikhiljais gravatar imagenikhiljais ( 2018-11-29 01:58:27 -0500 )edit

This is a question from 2016. If you want to get a decent response, open up a new question with specific details on what goes wrong on your side.

StevenPuttemans gravatar imageStevenPuttemans ( 2018-12-01 21:08:39 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2015-11-17 11:02:12 -0500

Seen: 1,557 times

Last updated: Nov 19 '15