Ask Your Question
0

an Alternative for cvGet2D()

asked 2013-07-25 05:31:51 -0600

engine gravatar image

Hi! I have a problem and I found i solution, but in c since I'm using c++ for my program , I changed the code but I can't change following part:

CvPoint pDst; // cv::Point pdst; CvScalar p1; // cv::Scalar p1;

p1=cvGet2D(&tdst,0,0); / / how can I change this ???

thanks in advance ? ?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

answered 2013-07-25 05:43:01 -0600

berak gravatar image

updated 2013-07-25 05:44:50 -0600

it works a bit different in c++

// m.type() == CV_8U
uchar u = m.at<uchar>(row,col);
m.at<uchar>(row,col) = 17;

// m.type() == CV_32F
float f = m.at<float>(row,col);
m.at<float>(row,col) = 11.1f;

// m.type() == CV_8UC3
Vec3b v = m.at<Vec3b>(row,col);
m.at<Vec3b>(row,col)[1] = 17;

// etc. 
// m.type() determines, what type you've got to feed into Mat::at<type_here>()
edit flag offensive delete link more

Comments

to be honest I don't get it ?? the type of tdst is 13 so how can get the values of p1 ??

engine gravatar imageengine ( 2013-07-25 05:52:54 -0600 )edit

bit of poking around showed, that 13 is actually CV_32FC2, so,

Point2f p = m.at&lt;Point2f&gt;(row,col);

berak gravatar imageberak ( 2013-07-25 06:14:51 -0600 )edit

thanks a lot for your help

engine gravatar imageengine ( 2013-07-25 06:33:29 -0600 )edit

Question Tools

Stats

Asked: 2013-07-25 05:31:51 -0600

Seen: 2,103 times

Last updated: Jul 25 '13