QmcContext::~QmcContext() { while (my.metrics.isEmpty() == false) { delete my.metrics.takeFirst(); } QHashIterator<pmID, QmcDesc*> descs(my.descCache); while (descs.hasNext()) { descs.next(); delete descs.value(); } while (my.indoms.isEmpty() == false) { delete my.indoms.takeFirst(); } if (my.context >= 0) my.source->delContext(my.context); }
void ShaderReflectionPimpl::PrintUniforms(ID3DXConstantTable * table) { std::vector<D3DXHANDLE> constants; unsigned int i = 0; for (unsigned int i = 0;; ++i) { D3DXHANDLE constant = table->GetConstant(NULL, i); if (constant) { constants.push_back(constant); } else { break; } } std::vector<D3DXCONSTANT_DESC> descs(constants.size()); UINT size = descs.size(); for (unsigned int i = 0; i < constants.size(); ++i) { table->GetConstantDesc(constants[i], &descs[i], &size); } unsigned int max_register = 0; unsigned int max_register_index = 0; for (unsigned int i = 0; i < constants.size(); ++i) { if (max_register < descs[i].RegisterIndex) { max_register = descs[i].RegisterIndex; max_register_index = i; } } int register_count = max_register + descs[max_register_index].RegisterCount + 1;//0 indexed. int x = 0; //std::cout << table->GetBufferPointer() << std::endl; }
void ELucidBinaryDescriptorExtractor::computeDescriptors( const cv::Mat& image, const std::vector<cv::KeyPoint>& key_points, std::vector<bool> *valid_descriptors, cv::Mat *descriptors) const { std::clock_t start = std::clock(); cv::Mat blurred_image; int _blur_radius = 5; //FIXME: move this to class member cv::blur(image, blurred_image, cv::Size(_blur_radius, _blur_radius)); const int num_channels = image.channels(); uchar pixels[num_samples]; valid_descriptors->reserve(key_points.size()); // TODO: Clean this up and don't use redundant code if(!_useWideDesc) { int desc_width = 32; assert(desc_width == num_samples / 2); cv::Mat descs(key_points.size(), desc_width, CV_8UC1); /* Unary Representation Lookup Tables*/ uchar lut_lower[4] = { 0x00, 0x01, 0x03, 0x07, }; uchar lut_upper[4] = { 0x00, 0x10, 0x30, 0x70, }; for(int k = 0; k < key_points.size(); ++k) { uchar *cur_desc = descs.ptr<uchar>(k); float x = key_points[k].pt.x; float y = key_points[k].pt.y; valid_descriptors->push_back( (x - patch_size/2) > 0 && (y - patch_size/2) > 0 && (x + patch_size/2) < image.cols && (y + patch_size/2) < image.rows); if((*valid_descriptors)[k]) { // TODO: Replace this by directly accessing pattern pixels cv::Mat patch; getRectSubPix(blurred_image, cv::Size(patch_size, patch_size), key_points[k].pt, patch); uchar* patch_ptr = patch.data; for(int p = 0; p < num_samples; ++p) { pixels[p] = patch_ptr[pattern[p][1] * patch_size + pattern[p][0]]; } int bin_width = 16; uchar temp_desc[num_samples]; Util::getRankVectors2(num_samples, bin_width, pixels, &(temp_desc[0])); int next_idx = 0; for(int i = 0; i < num_samples; i+=2) { cur_desc[next_idx++] = lut_lower[temp_desc[i]] | lut_upper[temp_desc[i+1]]; } } } std::clock_t stop = std::clock(); std::cout << "Time to compute eLUCID 256 bit descriptors " << (1000.0*(stop - start)) / CLOCKS_PER_SEC << "ms" << std::endl; *descriptors = descs; } else { int desc_width = 64; assert(desc_width == num_samples); cv::Mat descs(key_points.size(), desc_width, CV_8UC1); /* Sampled Unary Representation Lookup Tables*/ uchar lut[8] = { 0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, }; for(int k = 0; k < key_points.size(); ++k) { uchar *cur_desc = descs.ptr<uchar>(k); float x = key_points[k].pt.x; float y = key_points[k].pt.y; valid_descriptors->push_back( (x - patch_size/2) > 0 && (y - patch_size/2) > 0 && (x + patch_size/2) < image.cols && (y + patch_size/2) < image.rows); if((*valid_descriptors)[k]) { // TODO: Replace this by directly accessing pattern pixels cv::Mat patch; getRectSubPix(blurred_image, cv::Size(patch_size, patch_size), key_points[k].pt, patch); uchar* patch_ptr = patch.data; for(int p = 0; p < num_samples; ++p) { pixels[p] = patch_ptr[pattern[p][1] * patch_size + pattern[p][0]]; } int bin_width = 8; uchar temp_desc[num_samples]; Util::getRankVectors2(num_samples, bin_width, pixels, &(temp_desc[0])); for(int i = 0; i < num_samples; i++) { cur_desc[i] = lut[temp_desc[i]]; } } } std::clock_t stop = std::clock(); std::cout << "Time to compute eLUCID 512 bit descriptors " << (1000.0*(stop - start)) / CLOCKS_PER_SEC << "ms" << std::endl; *descriptors = descs; } }