Ask Your Question
0

Whats the equivalent of put(in java) for opencv c++?

asked 2017-10-08 22:01:04 -0600

Vahid Dnt gravatar image

I would like to translate the code below from java to open cv c++. I don't know whats the equivalent for put. Please help on this.

Mat A = new Mat(1, 3, CvType.CV_32FC1); A.put(0, 0, -1); A.put(0, 1, 0); A.put(0, 2, 1);

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

answered 2017-10-08 23:02:28 -0600

Tetragramm gravatar image

To answer all your basic questions, check out the tutorials HERE.

Both .get and .put are, in c++, .at< type >(). However, this is not the most efficient way if you need to access all the elements of a Mat, but for your example, it's simple enough.

For example

Mat A = Mat(1,3,CV_32F);
A.at<float>(0,0) = -1;
A.at<float>(0,1) = 0;
A.at<float>(0,2) = 1;

The type is replaced by the appropriate c++ type that the matrix is. For example:

  • CV_8UC1 = uchar or cv::Vec1b
  • CV_16UC1 = ushort
  • CV_8UC3 = cv::Vec3b
  • CV_32FC1 = float

ect.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2017-10-08 22:01:04 -0600

Seen: 343 times

Last updated: Oct 08 '17