VibrationData VibrationSensorModule::retrieveVibrationData() const { int samplesCount = 0; float recordStepSize = 0; int decimationFactor = readRecInfoDecimationFactor(); std::function<float(int16_t)> convertVibrationValue; switch (currentRecordingMode) { case RecordingMode::MTC://Time domain capture samplesCount = 4096; recordStepSize = 1.f / (220000.f / static_cast<float>(decimationFactor)); convertVibrationValue = { [](int16_t valueRaw) { return static_cast<float>(valueRaw) * 0.001907349; } }; break; case RecordingMode::MFFT://Spectral analysis through internal FFT case RecordingMode::AFFT: const uint8_t numberOfFFTAvg = readRecInfoFFTAveragesCount(); samplesCount = 2048; recordStepSize = 110000.f / static_cast<float>(decimationFactor) / static_cast<float>(samplesCount); convertVibrationValue = { [numberOfFFTAvg](int16_t valueRaw) { // handle special case according to https://ez.analog.com/mems/f/q-a/162759/adcmxl3021-fft-conversion/372600#372600 if(valueRaw == 0) { return 0.0; } return std::pow(2, static_cast<float>(valueRaw) / 2048) / numberOfFFTAvg * 0.9535;//数据处理公式,作用? } }; break; } write(spi_commands::BUF_PNTR, 0); VibrationData vibrationData; vibrationData.recordingMode = currentRecordingMode; vibrationData.stepAxis = generateSteps(recordStepSize, samplesCount); vibrationData.xAxis = readSamplesBuffer(spi_commands::X_BUF, samplesCount, convertVibrationValue); vibrationData.yAxis = readSamplesBuffer(spi_commands::Y_BUF, samplesCount, convertVibrationValue); vibrationData.zAxis = readSamplesBuffer(spi_commands::Z_BUF, samplesCount, convertVibrationValue); return vibrationData; }//dsp//return vibrationData 请问这段代码是什么意思
时间: 2023-03-14 08:33:18 浏览: 197
return static_cast<float>(valueRaw) * 0.001907349 / static_cast<float>(numberOfFFTAvg); } }; break; default: return VibrationData(); } // ... 这是一个代码片段,它描述的是如何通过内部FFT获取振动数据的过程。
相关问题
computePointSHOT (const int index, const std::vector<int> &indices, const std::vector<float> &sqr_dists, std::vector<bool> shot) = 0;
这是一个纯虚函数的声明,这意味着这个函数在当前类中没有实现,需要在子类中进行实现。该函数的作用是计算点云中某个点与一组索引(indices)给定的点之间的SHOT描述子(Shape Histograms of Oriented Points)。其中,index表示待计算SHOT描述子的点的索引,sqr_dists是待计算点与索引点之间的平方距离,shot是输出参数,表示计算出的SHOT描述子是否有效。
void NCut::GetPatchFeature(const MatrixXf &points, MatrixXf *features_in) { MatrixXf &features = *features_in; const int num_points = static_cast<int>(points.rows()); const int dim = _patch_size * _patch_size; features.resize(num_points, dim); for (int i = 0; i < num_points; ++i) { // .1 patch int irow = 0; int jcol = 0; _ff_feature_grid.Pos2d(points.coeffRef(i, 0), points.coeffRef(i, 1), &irow, &jcol); cv::Mat patch; cv::Point2f pt(static_cast<float>(irow), static_cast<float>(jcol)); cv::getRectSubPix(_cv_feature_map, cv::Size(_patch_size, _patch_size), pt, patch); // .2 maybe later i will add other features based on patch // .3 add to features assert(dim == patch.rows * patch.cols); int p = 0; for (int r = 0; r < patch.rows; ++r) { for (int c = 0; c < patch.cols; ++c) { float val = patch.at<float>(r, c); features.coeffRef(i, p++) = static_cast<float>( (std::isnan(val) || std::isinf(val)) ? 1.e-50 : val); // features.coeffRef(i, p++) = patch.at<float>(r, c); } } } }
这段代码是用于计算NCut算法中的图像块的特征向量。给定一个点集points,对于每个点,首先通过_ff_feature_grid将其映射到_feature_map图像上,并取该点为中心的_patch_size * _patch_size大小的矩形区域作为图像块。然后,对于每个图像块,将像素值添加到特征向量中,特征向量的维度为_patch_size * _patch_size。在添加每个像素值时,如果该值为NaN或Inf,则设置为1.e-50。最终,返回一个特征向量矩阵features,其行数为points中点的个数,列数为_patch_size * _patch_size。
阅读全文