Commit 6813e21f by Kai Westerkamp

..

parent d5c9509f
Pipeline #247 passed with stage
in 19 seconds
...@@ -156,6 +156,7 @@ void getRgbData(IMultiSourceFrame* frame, bool writFrameToFile) { ...@@ -156,6 +156,7 @@ void getRgbData(IMultiSourceFrame* frame, bool writFrameToFile) {
*fdest++ = rgbimage[4 * idx + 2] / 255.f; *fdest++ = rgbimage[4 * idx + 2] / 255.f;
if (writFrameToFile) { if (writFrameToFile) {
//copy points with valid Color
snapshotPoints.push_back(framePositions[i]); snapshotPoints.push_back(framePositions[i]);
snapshotColors.push_back(rgbimage[4 * idx + 0]); snapshotColors.push_back(rgbimage[4 * idx + 0]);
...@@ -185,27 +186,6 @@ void getKinectData(bool writeFrameInVector) { ...@@ -185,27 +186,6 @@ void getKinectData(bool writeFrameInVector) {
getDepthData(frame); getDepthData(frame);
getRgbData(frame, writeFrameInVector); getRgbData(frame, writeFrameInVector);
if (writeFrameInVector) {
//get controler pos
//frame -> global
points.clear();
colors.clear();
points.reserve(points.capacity() + width*height);
colors.reserve(colors.capacity() + width*height*3);
for(int i = 0; i < snapshotPoints.size(); i++) {
points.push_back(*currentControlerPos * snapshotPoints[i]);
colors.push_back(snapshotColors[i*3]);
colors.push_back(snapshotColors[i*3+1]);
colors.push_back(snapshotColors[i*3+2]);
}
}
glBindBuffer(GL_ARRAY_BUFFER, vboId); glBindBuffer(GL_ARRAY_BUFFER, vboId);
glBufferData(GL_ARRAY_BUFFER, width*height * 3 * sizeof(GLfloat), framePositions, GL_DYNAMIC_DRAW); glBufferData(GL_ARRAY_BUFFER, width*height * 3 * sizeof(GLfloat), framePositions, GL_DYNAMIC_DRAW);
glUnmapBuffer(GL_ARRAY_BUFFER); glUnmapBuffer(GL_ARRAY_BUFFER);
...@@ -262,7 +242,24 @@ void rotateCamera() { ...@@ -262,7 +242,24 @@ void rotateCamera() {
void drawKinectData() { void drawKinectData() {
getKinectData(captureFrame); getKinectData(captureFrame);
//add points to point cloud
if (captureFrame) {
//get controler pos
points.clear();
colors.clear();
points.reserve(points.capacity() + width*height);
colors.reserve(colors.capacity() + width*height * 3);
for (int i = 0; i < snapshotPoints.size(); i++) {
points.push_back(*currentControlerPos * snapshotPoints[i]);
colors.push_back(snapshotColors[i * 3]);
colors.push_back(snapshotColors[i * 3 + 1]);
colors.push_back(snapshotColors[i * 3 + 2]);
}
}
captureFrame = false; captureFrame = false;
if (writeFile) { if (writeFile) {
writePointCloud(); writePointCloud();
writeFile = false; writeFile = false;
...@@ -340,14 +337,41 @@ int main(int argc, char* argv[]) { ...@@ -340,14 +337,41 @@ int main(int argc, char* argv[]) {
glClearColor(0,0,0,0); glClearColor(0,0,0,0);
glClearDepth(1.0f); glClearDepth(1.0f);
snapshotPoints.clear();
snapshotColors.clear();
// Write color array for vertices
float* fdest = (float*)frameColors;
float* fdest2 = (float*)framePositions;
for (int j = 0; j < height; j++) {
for (int i = 0; i < width; i++) {
*fdest++ = 1.0 * i / width;
*fdest++ = 1.0 *j / height;
*fdest++ = 0;
snapshotPoints.push_back(glm::vec3(1.0 * i / width, 1.0 *j / height, 0));
snapshotColors.push_back(1.0 *i / width*255);
snapshotColors.push_back(1.0 *j / height*255);
snapshotColors.push_back(0);
*fdest2++ = 1.0 *i / width;
*fdest2++ = 1.0 *j / height;;
*fdest2++ = 0;
}
}
// Set up array buffers // Set up array buffers
const int dataSize = width*height * 3 * 4; const int dataSize = width*height * 3 * 4;
glGenBuffers(1, &vboId); glGenBuffers(1, &vboId);
glBindBuffer(GL_ARRAY_BUFFER, vboId); glBindBuffer(GL_ARRAY_BUFFER, vboId);
glBufferData(GL_ARRAY_BUFFER, dataSize, 0, GL_DYNAMIC_DRAW); glBufferData(GL_ARRAY_BUFFER, dataSize, framePositions, GL_DYNAMIC_DRAW);
glGenBuffers(1, &cboId); glGenBuffers(1, &cboId);
glBindBuffer(GL_ARRAY_BUFFER, cboId); glBindBuffer(GL_ARRAY_BUFFER, cboId);
glBufferData(GL_ARRAY_BUFFER, dataSize, 0, GL_DYNAMIC_DRAW); glBufferData(GL_ARRAY_BUFFER, dataSize, frameColors, GL_DYNAMIC_DRAW);
// Camera setup // Camera setup
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment