| 26 | namespace depthMap { |
| 27 | |
| 28 | void exportSimilaritySamplesCSV(const CudaHostMemoryHeap<TSim, 3>& in_volumeSim_hmh, |
| 29 | const std::vector<float>& in_depths, |
| 30 | const std::string& name, |
| 31 | const depthMapCommon::SgmParams& sgmParams, |
| 32 | const std::string& filepath, |
| 33 | const ROI& roi) |
| 34 | { |
| 35 | const ROI downscaledRoi = downscaleROI(roi, sgmParams.scale * sgmParams.stepXY); |
| 36 | |
| 37 | const size_t spitch = in_volumeSim_hmh.getBytesPaddedUpToDim(1); |
| 38 | const size_t pitch = in_volumeSim_hmh.getBytesPaddedUpToDim(0); |
| 39 | |
| 40 | const int sampleSize = 3; |
| 41 | |
| 42 | const int xOffset = std::floor(downscaledRoi.width() / (sampleSize + 1.0f)); |
| 43 | const int yOffset = std::floor(downscaledRoi.height() / (sampleSize + 1.0f)); |
| 44 | |
| 45 | std::vector<Point2d> ptsCoords(sampleSize * sampleSize); |
| 46 | std::vector<std::vector<float>> ptsDepths(sampleSize * sampleSize); |
| 47 | |
| 48 | for (int iy = 0; iy < sampleSize; ++iy) |
| 49 | { |
| 50 | for (int ix = 0; ix < sampleSize; ++ix) |
| 51 | { |
| 52 | const int ptIdx = iy * sampleSize + ix; |
| 53 | const int x = (ix + 1) * xOffset; |
| 54 | const int y = (iy + 1) * yOffset; |
| 55 | |
| 56 | ptsCoords.at(ptIdx) = {x, y}; |
| 57 | std::vector<float>& pDepths = ptsDepths.at(ptIdx); |
| 58 | |
| 59 | pDepths.reserve(in_depths.size()); |
| 60 | |
| 61 | for (int iz = 0; iz < in_depths.size(); ++iz) |
| 62 | { |
| 63 | const float simValue = float(*get3DBufferAt_h<TSim>(in_volumeSim_hmh.getBuffer(), spitch, pitch, x, y, iz)); |
| 64 | pDepths.push_back(simValue); |
| 65 | } |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | std::stringstream ss; |
| 70 | |
| 71 | ss << name << "\n"; |
| 72 | |
| 73 | for (int i = 0; i < ptsCoords.size(); ++i) |
| 74 | { |
| 75 | const Point2d& coord = ptsCoords.at(i); |
| 76 | ss << "p" << (i + 1) << " (x: " << coord.x << ", y: " << coord.y << ");"; |
| 77 | for (const float depth : ptsDepths.at(i)) |
| 78 | ss << depth << ";"; |
| 79 | ss << "\n"; |
| 80 | } |
| 81 | |
| 82 | std::ofstream file; |
| 83 | file.open(filepath, std::ios_base::app); |
| 84 | if (file.is_open()) |
| 85 | file << ss.str(); |
no test coverage detected