Ask Your Question
0

How to count depth images from kinect

asked 2011-11-05 04:10:22 -0500

Paul0nc gravatar image

I'm using a Kinect with depth_viewer. I'm able to view depth images, but I'd like to be able to view and store a fixed number of them (say, 100). If I put a counter in my main program, it does not increment. If I put the same counter in the subscriber callback function to openni_camera, it does not increment (I'm guessing it gets reset on every received message).

I would think this is easy... but I'm not sure how to approach it. Any help would be appreciated.

Thanks, Paul

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2011-11-05 04:22:19 -0500

lucascoelho gravatar image

You should use a global variable to store the number.

edit flag offensive delete link more

Comments

I tried this. It yielded a compilation error that the variable was not defined within the scope of the callback function.
Paul0nc gravatar image Paul0nc  ( 2011-11-05 04:32:01 -0500 )edit
That's strange because we don't need to define a global variable again inside the callback function. What arguments are your callback function using?
lucascoelho gravatar image lucascoelho  ( 2011-11-05 05:01:14 -0500 )edit
The callback argument is the depth image from the kinect. Can I add any other arguments?
Paul0nc gravatar image Paul0nc  ( 2011-11-05 05:23:38 -0500 )edit
Declaring the local variable in the callback function to be a 'static int' solved the problem.
Paul0nc gravatar image Paul0nc  ( 2011-11-05 05:31:13 -0500 )edit
You can use more than 1 arguments. To know how to do it, please see that page: http://www.ros.org/wiki/roscpp/Overview/Publishers%20and%20Subscribers . A static variable is not deleted if your program go out of the function. So it will have the previous value if the function is called again.
lucascoelho gravatar image lucascoelho  ( 2011-11-05 05:46:31 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2011-11-05 04:10:22 -0500

Seen: 288 times

Last updated: Nov 05 '11