void SensorFrameRecorder::ReportCameraCalibrationInformation()

in Shared/HoloLensForCV/SensorFrameRecorder.cpp [210:271]


    void SensorFrameRecorder::ReportCameraCalibrationInformation(
        _Inout_ std::vector<std::wstring>& sourceFiles)
    {
        // TODO: Support PV calibration.

        for (SensorFrameRecorderSink^ sensorFrameSink : _sensorFrameSinks)
        {
            if (nullptr == sensorFrameSink)
            {
                continue;
            }

            auto cameraIntrinsics =
                sensorFrameSink->GetCameraIntrinsics();

            if (nullptr == cameraIntrinsics)
            {
                continue;
            }

            wchar_t fileName[MAX_PATH] = {};

            swprintf_s(
                fileName,
                L"%s\\%s_camera_space_projection.bin",
                _archiveSourceFolder->Path->Data(),
                sensorFrameSink->GetSensorName()->Data());

            sourceFiles.push_back(fileName);

            std::vector<Windows::Foundation::Point> pointList;
            pointList.resize(cameraIntrinsics->ImageWidth * cameraIntrinsics->ImageHeight);
            size_t index = 0;
            for (unsigned int x = 0; x < cameraIntrinsics->ImageWidth; ++x)
            {
                for (unsigned int y = 0; y < cameraIntrinsics->ImageHeight; ++y)
                {
                    Windows::Foundation::Point uv = { float(x), float(y) }, xy;
                    cameraIntrinsics->MapImagePointToCameraUnitPlane(uv, &xy);
                    pointList[index++] = xy;
                }
            }

            //TODO: Better conversion to char*
            std::wstring ws(fileName);
            std::string outputFilePath;
            outputFilePath.assign(ws.begin(), ws.end());

            FILE* file = nullptr;
            ASSERT(0 == fopen_s(&file, outputFilePath.c_str(), "wb"));

            size_t expectedSize = pointList.size() * sizeof(Windows::Foundation::Point);
            ASSERT(expectedSize == fwrite(
                reinterpret_cast<uint8_t*>(&pointList[0]),
                sizeof(uint8_t),
                expectedSize,
                file));

            ASSERT(0 == fclose(file));

        }
    }