void CompactTriples::load(ModifiableTriples &triples, ProgressListener *listener) { triples.sort(order); IteratorTripleID *it = triples.searchAll(); vector<unsigned int> vectorY, vectorZ; unsigned int lastX, lastY, lastZ; unsigned int x, y, z; // First triple if(it->hasNext()) { TripleID *triple = it->next(); swapComponentOrder(triple, SPO, order); lastX = x = triple->getSubject(); lastY = y = triple->getPredicate(); lastZ = z = triple->getObject(); vectorY.push_back(y); vectorZ.push_back(z); numTriples++; } // Rest of the triples while(it->hasNext()) { TripleID *triple = it->next(); //cout << "111> " << triple << endl; swapComponentOrder(triple, SPO, order); //cout << "222> " << triple << endl; x = triple->getSubject(); y = triple->getPredicate(); z = triple->getObject(); if(x!=lastX) { vectorY.push_back(0); vectorY.push_back(y); vectorZ.push_back(0); vectorZ.push_back(z); } else if(y!=lastY) { vectorY.push_back(y); vectorZ.push_back(0); vectorZ.push_back(z); } else { vectorZ.push_back(z); } lastX = x; lastY = y; lastZ = z; NOTIFYCOND(listener, "Converting to CompactTriples.", numTriples, triples.getNumberOfElements()); numTriples++; } delete it; VectorUIntIterator itY(vectorY); VectorUIntIterator itZ(vectorZ); streamY->add(itY); streamZ->add(itZ); #if 0 // Debug Adjacency Lists cout << "Y" << vectorY.size() << "): "; for(unsigned int i=0;i<arrayY->getNumberOfElements();i++){ cout << arrayY->get(i) << " "; } cout << endl; cout << "Z" << vectorZ.size() << "): "; for(unsigned int i=0;i<arrayZ->getNumberOfElements();i++){ cout << arrayZ->get(i) << " "; } cout << endl; #endif }
bool OpenNiDevice::grab(void) { if (!_depth.isValid() && !_color.isValid() && !_ir.isValid()) { std::cout << "No stream available." << std::endl; return false; } if (_depth.isValid()) { _depth.readFrame(&_frameDepth); const openni::DepthPixel* data = reinterpret_cast<const openni::DepthPixel*>(_frameDepth.getData()); std::vector<float>::iterator itZ(_z.begin()); std::vector<float>::iterator itCoords(_coords.begin()); for (int row = 0; row < _height; ++row) { for (int col = 0; col < _width; ++col, ++itZ, ++data) { float x; float y; float z; openni::CoordinateConverter::convertDepthToWorld(_depth, col, row, *data, &x, &y, &z); *itZ = *data * 0.001; *itCoords++ = x * 0.001; *itCoords++ = y * 0.001; *itCoords++ = z * 0.001; } } } if (_color.isValid()) { _color.readFrame(&_frameColor); const openni::RGB888Pixel* data = reinterpret_cast<const openni::RGB888Pixel*>(_frameColor.getData()); const int size = _width * _height; for(int i=0; i<size; i++, data++) { _imgRgb[3*i] = data->r; _imgRgb[3*i+1] = data->g; _imgRgb[3*i+2] = data->b; } } if (_ir.isValid()) { _ir.readFrame(&_frameIr); const uint16_t* data = reinterpret_cast<const uint16_t*>(_frameIr.getData()); const int size = _width * _height; for(int i=0; i<size; i++, data++) { _imgIr[3*i] = *data >> 2; _imgIr[3*i+1] = *data >> 2; _imgIr[3*i+2] = *data >> 2; } }