Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

depth16.at<uint16_t>(y,x); // welcome to row major world !

also, if your image is CV_16U, you must not try to access it as depth16.at<cv::Vec3b>

depth16.at<uint16_t>(y,x); // welcome to row major world !

also, if your image is CV_16U, you must not try to access it as depth16.at<cv::Vec3b>

why do you start indexing at 1 ? this is NOT matlab

writing for loops here is a terrible idea, and should be avoided at any cost. there are acouple of pitfalls there, and id seems, you hit ALL of them:

  • depth16.at<uint16_t>(y,x); // welcome to row major world !

  • also,

  • if your image is CV_16U, you must not try to access it as depth16.at<cv::Vec3b>

    (verboten)
  • why do you start indexing at 1 ?

  • this is NOT matlab

    C++, not matlab, you have to start iterating at 0 and end at n-1.

writing for loops here is a terrible idea, and should be avoided at any cost.

there are acouple a couple of pitfalls there, and id it seems, you hit ALL of them:

  • depth16.at<uint16_t>(y,x); // welcome to row major world !
  • if your image is CV_16U, you must not try to access it as depth16.at<cv::Vec3b> (verboten)
  • this is C++, not matlab, you have to start iterating at 0 and end at n-1.

writing for loops here is a terrible idea, and should be avoided at any cost.

there are a couple of pitfalls there, and it seems, you hit ALL of them:

  • depth16.at<uint16_t>(y,x); // welcome to row major world !
  • if your image is CV_16U, you must not try to access it as depth16.at<cv::Vec3b> (verboten)
  • this is C++, not matlab, you have to start iterating at 0 and end at n-1.
  • your depth image is 16_U, so in the [0..0xffff] range. a value of 255 does not make any sense, as well as 0.2 or 0.4 (expectation mismatch)

writing for loops here is a terrible idea, and should be avoided at any cost.

there are a couple of pitfalls there, and it seems, you hit ALL of them:

  • depth16.at<uint16_t>(y,x); // welcome to row major world !
  • if your image is CV_16U, you must not try to access it as depth16.at<cv::Vec3b> (verboten)
  • this is C++, not matlab, you have to start iterating at 0 and end at n-1.
  • your depth image is 16_U, so in the [0..0xffff] range. a value of 255 does not make any sense, as well as 0.2 or 0.4 (expectation mismatch)

please delete all of it, and rather use builtin functions, like setTo():

depthimg.setTo(some_number, depthimg>3000);