c++ - Kinect depth Segmentation frame rate -


i new kinect project , implementing depth threshold when distance greater 400mm

for (uint y = 0; y < pimg->rows; ++y) {     // row pointers mats     const ushort* pdepthrow = depth->ptr<ushort>(y);      (uint x = 0; x < pimg->cols; ++x)     {         ushort raw_depth = pdepthrow[x];         short realdepth = nuidepthpixeltodepth(raw_depth);         // if depth value valid, convert , copy        if (raw_depth != 65535)         {             if(realdepth >400 ) //greater 400mm             {                 pimg->at<vec4b>(y,x)[0] = 255;                 pimg->at<vec4b>(y,x)[1] = 255;                 pimg->at<vec4b>(y,x)[2] = 255;                 pimg->at<vec4b>(y,x)[3] = 255;             }             else             {                 pimg->at<vec4b>(y,x)[0] = 0;                 pimg->at<vec4b>(y,x)[1] = 0;                 pimg->at<vec4b>(y,x)[2] = 0;                 pimg->at<vec4b>(y,x)[3] = 0;             }         }      } 

it seems correct result reduces frame rate massively. when want rid of loop using cv::inrange, function support 8u1c when raw depth 16u. else can use segment depth according real distance?

try improve performance storing reference pixel. change this:

if (realdepth > 400) //greater 400mm {     pimg->at<vec4b>(y,x)[0] = 255;     pimg->at<vec4b>(y,x)[1] = 255;     pimg->at<vec4b>(y,x)[2] = 255;     pimg->at<vec4b>(y,x)[3] = 255; } else {     pimg->at<vec4b>(y,x)[0] = 0;     pimg->at<vec4b>(y,x)[1] = 0;     pimg->at<vec4b>(y,x)[2] = 0;     pimg->at<vec4b>(y,x)[3] = 0; } 

to this:
(i don´t know t because dont know pimg is. t should equal return value of at method. assume vec4b.)

t& pixel = pimg->at<vec4b>(y, x); // vec4b& pixel = .. if (realdepth > 400) //greater 400mm {     pixel[0] = 255;     pixel[1] = 255;     pixel[2] = 255;     pixel[3] = 255; } else {     pixel[0] = 0;     pixel[1] = 0;     pixel[2] = 0;     pixel[3] = 0; } 

Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -