Ask Your Question
0

OpenCV C++ converting Vector to Mat [closed]

asked 2017-02-08 15:02:24 -0500

BhanuKiran gravatar image

Hi I have 2 vectors and i want to perform cross and dot product operations on them.

double va[] = {1.0, 2.0, 3.0};
double vb[] = {0.0, 0.0, 1.0};
double vc[3];

cv::Mat VA(1, 3, CV_32FC1, va);
cv::Mat VB(1, 3, CV_32FC1, vb);

std::cout << VA << std::endl;

When i print them my both va and VA are not the same !!!!

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by LBerger
close date 2017-02-08 15:15:15.848632

1 answer

Sort by ยป oldest newest most voted
0

answered 2017-02-08 15:07:30 -0500

LBerger gravatar image

updated 2017-02-08 15:08:07 -0500

va is double type and your Mat is float (CV32FC1) . You should use float for array or Mat of double type (CV_64FC1)

cv::Mat VC(1, 3, CV_64FC1, va);
edit flag offensive delete link more

Comments

1

Thanks for your reply. It's working

BhanuKiran gravatar imageBhanuKiran ( 2017-02-08 15:11:27 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2017-02-08 15:02:24 -0500

Seen: 1,051 times

Last updated: Feb 08 '17