Kinect depth Segmentation frame rate

I am new to kinect project And I am implementing a depth threshold when distance is greater than 400mm

for (UINT y = 0; y < pImg->rows; ++y) { // Get row pointers for Mats const USHORT* pDepthRow = depth->ptr<USHORT>(y); for (UINT x = 0; x < pImg->cols; ++x) { USHORT raw_depth = pDepthRow[x]; SHORT realDepth = NuiDepthPixelToDepth(raw_depth); // If depth value is valid, convert and copy it if (raw_depth != 65535) { if(realDepth >400 ) //greater than 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 get the correct result but reduces the frame rate massively. When I want to get rid of the loop by using the cv::inRange, but this function only support 8U1C when the raw depth is 16U. So what else can I use to segment the depth according to the real distance?

-------------Problems Reply------------

Try to improve performance by storing a reference to the pixel. Change this:

if (realDepth > 400) //greater than 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;
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 what T is because I dont know what pImg is. T should be equal to the return value of the at method. I assume it is Vec4b.)

T& pixel = pImg->at<Vec4b>(y, x); // probably Vec4b& pixel = ..
if (realDepth > 400) //greater than 400mm
pixel[0] = 255;
pixel[1] = 255;
pixel[2] = 255;
pixel[3] = 255;
pixel[0] = 0;
pixel[1] = 0;
pixel[2] = 0;
pixel[3] = 0;

Category:c# Views:5 Time:2018-03-13
Tags: opencv kinect

Related post

  • Precision of the kinect depth camera 2011-10-08

    How precise is the depth camera in the kinect? range? resolution? noise? Especially I'd like to know: Are there any official specs about it from Microsoft? Are there any scientific papers on the subject? Investigations from TechBlogs? Personal experi

  • What causes frame rate loss? 2009-06-21

    I'm writing a game with cocos2d and I have noticed that the frame rate drops as the game progresses. I've checked for leaks but everything looks fine so I'm at a loss as to what to do next. Sorry if this is a really basic question but what sort of fa

  • Fastest 2D frame rate possible with android NDK, my try included, better options available? 2010-05-20

    Fastest 2D frame rate possible with android NDK, my try included, better options available? I used the NDK and OpenGL ES 2.0 to display a frame as a texture on a GL_TRIANGLE_STRIP. This was done on a HTC Desire, same hardware as Nexus One. I tried to

  • Draw high res animations with high frame rate on Android 2011-01-18

    I've got 30+ single bitmaps (320x240 pixels) that I would like to display one after another in full screen on Android devices resulting in an animation. Currently I implemented the animation using an ImageView and a Timer that sets the next frame and

  • cocos2D frame rate is only 30, without any actions? 2011-11-22

    I have this in my app delegate: [director setAnimationInterval:1.0/60]; Despite this my app is running around 30 fps. What is weird is that it is currently doing absolutely nothing. the init for my only layer does nothing more than add 6 sprites base

  • How to change variable frame rate to constant? 2012-08-29

    Hello, I am exporting a mpeg HDV file that has a constant frame rate to a H264 video (.mp4) video to upload to a web-base video player. I'm actually using the preset in Media Encoder "YouTube HD 720p 29.97". The online video web interface I use requi

  • Fixed vs. variable frame rates in games: what is best, and when? 2008-09-09

    After working for a while developing games, I've been exposed to both variable frame rates (where you work out how much time has passed since the last tick and update actor movement accordingly) and fixed frame rates (where you work out how much time

  • What can cause a reduction in frame rate when upgrading a graphics card? 2008-09-11

    We have a two-screen DirectX application that previously ran at a consistent 60 FPS (the monitors' sync rate) using a NVIDIA 8400GS (256MB). However, when we swapped out the card for one with 512 MB of RAM the frame rate struggles to get above 40 FPS

  • How to change the frame rate of a core animation instance? 2009-03-22

    Take CABasicAnimation for example. How do you lower the frame rate (overhead)? Animations run smooth, but my touchesMoved method skips a beat. Want to reduce the animation frame rate so touchesMoved is not skipping movements. --------------Solutions-

  • Flash Player magical frame rate 2009-07-01

    A long time ago (5+ years) I read an article about optimal frame rates for the Flash Player. The article reasoned through some calculations that 31 frames per second was the optimal fps to run your movies at and seemed, at the time, logical to me and

  • Edit the frame rate of an avi file 2009-07-14

    Is it possible to change the frame rate of an avi file using the Video for windows library? I tried the following steps but did not succeed. AviFileInit AviFileOpen(OF_READWRITE) pavi1 = AviFileGetStream avi_info = AviStreamInfo avi_info.dwrate = 15

  • Which frame does ffmpeg get when reducing the frame rate 2009-10-12

    I have some video that I would like to convert to images of frames every 2 sec. E.g. If the video is 7 seconds long at 15 fps I would like to get frames 1, 31, 61, 91. The command: ffmpeg -i foo.mp4 -r 0.5 -f image2 -vcodec mjpeg foo%d.jpg appears to

  • What is the most efficient way to keep a steady frame rate with DirectX and C++? 2009-10-17

    I'm learning DirectX from a book about game programming, and it uses the following method for a game loop: long int start = GetTickCount(); while(true) GameRun(); void GameRun() { if(GetTickCount() - start >= 30) //do stuff } This makes start equa

  • Making a program timer-based rather than frame-rate dependent? 2009-11-16

    I have a game engine to work on as part of a class. Currently, its rendering is frame-rate dependent and one requirement is to move to a timer-based dependency. I am not sure how to determine where it is relying on frame-rates. I'm not sure what to l

  • Android game loop, how to control speed and frame rate 2010-02-15

    I've written a game for Android, and I've tested it on the Dev Phone 1. It works perfectly, the speed is just right. However, I'm sure phone CPU's are getting faster. They may already be faster than the dev phone. How do I make sure that my game runs

  • OpenCV Frame Rate Issue 2010-03-10

    I am working on a school project with OpenCV. A major part of the program will be a comparison of histograms. There will be a database of histograms and new histograms will be created from a live video feed then compared to the histograms in the data

  • Help getting frame rate (fps) up in Python + Pygame 2010-03-27

    I am working on a little card-swapping world-travel game that I sort of envision as a cross between Bejeweled and the 10 Days geography board games. So far the coding has been going okay, but the frame rate is pretty bad... currently I'm getting low

  • SFML SetFramerateLimit Not Limiting Frame Rate 2010-04-03

    Compiler: Visual C++ OS: Windows 7 Enterprise For some reason, Window::SetFramerateLimit isn't limiting the frame rate in the app I'm working on, but it works fine for others. The framerate is capped to 60, but mine jumps around at 100-99 and then go

  • Older iPhone/ iPod frame rate? 2010-04-04

    Do older iPods and iPhones have a frame rate of 60fps? I'm finding that all the methods for calculating time intervals on iPhone (cftimeinterval, nstimer, timesince1970, etc) are all giving me bad data, so I've decided assume a frame rate of 60, just

  • How to optimize frame rate in Flash/Actionscript? 2010-06-07

    I'm building an application in Actionscript using Flash assets, and my frame rate becomes very low (~7 fps) when I attempt to render 20+ assets on the screen, even though most of those assets are stopped movie clips. I've tried setting .cacheAsBitmap

  • frame rate on the iphone using mach_absolute_time 2010-06-20

    I have the following code, and wanted to get other set of eyes to make sure I have written the right code to calculate the frame rate of a scene. Could you please chime in? This is written for the iPad using SDK 3.2. thanks! - (void)drawView:(id)send

  • creating controls to change the speed/frame rate of a youtube video 2010-07-20

    I am trying to build a custom video player and have not found any method in the youtube api for altering frame rates or such. Does anyone know where I might find a solution. I am hoping to be able to put the video into a half speed/solw-motion playba

  • how to get flv frame rate in as3? 2010-09-06

    Well, i have to set the stage frame rate according to the frame rate of the flv and I will have differnet flv with different frame rate so i have to get frame rate of FlV using action script ?? Is there any method available in Video Class of ActionSc

  • SVG Background animation and frame rate 2010-10-03

    I've made an animation with SVG. It's like a slowly changing wallpaper. The idea is that you should barely notice it is changing. It's purely decorative, and I don't want it to drain any resources. Is there a way to set the frame rate in SVG? I thoug

  • ffmpeg split avi into frames with known frame rate 2010-10-12

    I posted this as comments under this related thread. However, they seem to have gone unnoticed =( I've used ffmpeg -i myfile.avi -f image2 image-%05d.bmp to split myfile.avi into frames stored as .bmp files. It seemed to work except not quite. When r

Copyright (C), All Rights Reserved.

processed in 0.088 (s). 11 q(s)