I have a screenshot of the infrared output of a Kinect using OpenKinect on a Mac.
I would like to calculate the distance of the green wall and the orange posts. I'm only bothered about a single dimension array, say y = 240 (along the horizontal center of the image).
I have tried using MarvinJ to convert the image to greyscale and save the colour value to an array, but I quickly found that this is not the way to go about this, due to the integer colour values of the greyscale image are very similar and do not represent the depth well enough.
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Greyscale Test</title>
</head>
<body>
<script src="https://www.marvinj.org/releases/marvinj-0.9.js"></script>
<script>
image = new MarvinImage();
image.load("ir_test.png", imageLoaded);
function imageLoaded() {
var imageOut = new MarvinImage(image.getWidth(), image.getHeight());
var image2 = new MarvinImage(image.getWidth(), image.getHeight());
Marvin.invertColors(image, image2);
Marvin.invertColors(image2, imageOut);
var y = 240;
var colour_array = [];
for (var x = 0; x < imageOut.getWidth(); x++) { // For loop to loop through the x-axis
var colour = imageOut.getIntComponent0(x, y);
colour_array.push(colour);
}
document.getElementById('colour_array_div').innerHTML = colour_array;
}
</script>
<div id="colour_array_div"></div>
</body>
</html>
What I'm trying to work out is how to convert the colour to a distance, preferably in millimeters.