I am working with Kinect and am trying to take in depth data and process it.
Essentially, when I process depth frames from the Kinect I want to save 2- the front depth data of a player and the back. I then need to flip round the back data so that it can then be used to build a 3D model of the player.
The problems I am having is flipping this back data around.
I have the depth data in the form of of a 1D array of length (320*240 = 76800) for which I was planing to flip each row (320 positions in the array) to reverse the image.
let mutable flipped = Array.create (320*240) 0
for y=0 to 239 do
for x=0 to 319 do
let n = ((y)* 320 + x)
flipped.[n] <- depths.[(320*(y+1))-(n+1)]
System.Diagnostics.Debug.WriteLine("DepthsMax:" + Array.max(depths).ToString())
System.Diagnostics.Debug.WriteLine("FlippedMax:" + Array.max(flipped).ToString())
The depths array contains the data I am trying to flip round, however, this code makes the flipped array consist entirely of 0s.
Can anyone spot what I am doing wrong?
Thanks
First of all, note that you don’t need for
flippedto be mutable since you never reassign it (you only modify it).On to the problem itself. Given
n = 320*y + x, you are looking at index:Thus, you’re only ever accessing data from the first row. You want to be accessing index
y*320 + (319-x)or320*(y+1) - (x+1), not320*(y+1) - (n+1).