Commit 0cf35e2b by wester

prä test vortrag

parent 6813e21f
...@@ -127,7 +127,7 @@ void getDepthData(IMultiSourceFrame* frame) { ...@@ -127,7 +127,7 @@ void getDepthData(IMultiSourceFrame* frame) {
if (depthframe) depthframe->Release(); if (depthframe) depthframe->Release();
} }
void getRgbData(IMultiSourceFrame* frame, bool writFrameToFile) { void getRgbData(IMultiSourceFrame* frame, bool writeFrameInVector) {
IColorFrame* colorframe; IColorFrame* colorframe;
IColorFrameReference* frameref = NULL; IColorFrameReference* frameref = NULL;
frame->get_ColorFrameReference(&frameref); frame->get_ColorFrameReference(&frameref);
...@@ -136,6 +136,14 @@ void getRgbData(IMultiSourceFrame* frame, bool writFrameToFile) { ...@@ -136,6 +136,14 @@ void getRgbData(IMultiSourceFrame* frame, bool writFrameToFile) {
if (!colorframe) return; if (!colorframe) return;
if (writeFrameInVector) {
snapshotPoints.clear();
snapshotPoints.reserve(width*height);
snapshotColors.clear();
snapshotColors.reserve(width*height * 3);
}
// Get data from frame // Get data from frame
colorframe->CopyConvertedFrameDataToArray(colorwidth*colorheight*4, rgbimage, ColorImageFormat_Rgba); colorframe->CopyConvertedFrameDataToArray(colorwidth*colorheight*4, rgbimage, ColorImageFormat_Rgba);
...@@ -155,7 +163,7 @@ void getRgbData(IMultiSourceFrame* frame, bool writFrameToFile) { ...@@ -155,7 +163,7 @@ void getRgbData(IMultiSourceFrame* frame, bool writFrameToFile) {
*fdest++ = rgbimage[4 * idx + 1] / 255.f; *fdest++ = rgbimage[4 * idx + 1] / 255.f;
*fdest++ = rgbimage[4 * idx + 2] / 255.f; *fdest++ = rgbimage[4 * idx + 2] / 255.f;
if (writFrameToFile) { if (writeFrameInVector) {
//copy points with valid Color //copy points with valid Color
snapshotPoints.push_back(framePositions[i]); snapshotPoints.push_back(framePositions[i]);
...@@ -176,13 +184,6 @@ void getKinectData(bool writeFrameInVector) { ...@@ -176,13 +184,6 @@ void getKinectData(bool writeFrameInVector) {
delete currentControlerPos; delete currentControlerPos;
currentControlerPos = steamTracking->getTransformationForDevice(0); currentControlerPos = steamTracking->getTransformationForDevice(0);
if (writeFrameInVector) {
snapshotPoints.clear();
snapshotPoints.reserve(width*height);
snapshotColors.clear();
snapshotColors.reserve(width*height * 3);
}
getDepthData(frame); getDepthData(frame);
getRgbData(frame, writeFrameInVector); getRgbData(frame, writeFrameInVector);
...@@ -206,11 +207,12 @@ void writePointCloud() { ...@@ -206,11 +207,12 @@ void writePointCloud() {
pntsHeader header; pntsHeader header;
size_t pointArrayByteSize = points.size() * sizeof(glm::vec3); size_t pointArrayByteSize = points.size() * sizeof(glm::vec3);
std::cout << points.size() << " " << sizeof(glm::vec3);
size_t coloArrayByteSize = colors.size() * sizeof(unsigned char); size_t coloArrayByteSize = colors.size() * sizeof(unsigned char);
header.featureTableByteLenght = pointArrayByteSize + coloArrayByteSize; header.featureTableByteLenght = pointArrayByteSize + coloArrayByteSize;
std::ostringstream os; std::ostringstream os;
os << "{\"POINTS_LENGTH\":" << (points.size() / 3) << ", \"POSITION\" : {\"byteOffset\":0}, \"RGB\" : {\"byteOffset\":" << pointArrayByteSize << "}}"; os << "{\"POINTS_LENGTH\":" << (points.size() ) << ", \"POSITION\" : {\"byteOffset\":0}, \"RGB\" : {\"byteOffset\":" << pointArrayByteSize << "}}";
std::string json = os.str(); std::string json = os.str();
header.featureTableJSONByteLenght = json.size(); header.featureTableJSONByteLenght = json.size();
...@@ -248,11 +250,11 @@ void drawKinectData() { ...@@ -248,11 +250,11 @@ void drawKinectData() {
//get controler pos //get controler pos
points.clear(); points.clear();
colors.clear(); colors.clear();
points.reserve(points.capacity() + width*height); points.reserve(points.size() + width*height);
colors.reserve(colors.capacity() + width*height * 3); colors.reserve(colors.size() + width*height * 3);
for (int i = 0; i < snapshotPoints.size(); i++) { for (int i = 0; i < snapshotPoints.size(); i++) {
points.push_back(*currentControlerPos * snapshotPoints[i]); points.push_back(/*currentControlerPos */ snapshotPoints[i]);
colors.push_back(snapshotColors[i * 3]); colors.push_back(snapshotColors[i * 3]);
colors.push_back(snapshotColors[i * 3 + 1]); colors.push_back(snapshotColors[i * 3 + 1]);
colors.push_back(snapshotColors[i * 3 + 2]); colors.push_back(snapshotColors[i * 3 + 2]);
...@@ -347,7 +349,7 @@ int main(int argc, char* argv[]) { ...@@ -347,7 +349,7 @@ int main(int argc, char* argv[]) {
for (int i = 0; i < width; i++) { for (int i = 0; i < width; i++) {
*fdest++ = 1.0 * i / width; *fdest++ = 1.0 * i / width;
*fdest++ = 1.0 *j / height; *fdest++ = 1.0 *j / height;
*fdest++ = 0; *fdest++ = 1;
snapshotPoints.push_back(glm::vec3(1.0 * i / width, 1.0 *j / height, 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 *i / width*255);
......
No preview for this file type
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