Commit 0cf35e2b by wester

prä test vortrag

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