コード例 #1
0
ファイル: heatMapSaver.cpp プロジェクト: zgsxwsdxg/openpose
    void HeatMapSaver::saveHeatMaps(const std::vector<Array<float>>& heatMaps, const std::string& fileName) const
    {
        try
        {
            // Record cv::mat
            if (!heatMaps.empty())
            {
                // File path (no extension)
                const auto fileNameNoExtension = getNextFileName(fileName) + "_heatmaps";

                // Get names for each heatMap
                std::vector<std::string> fileNames(heatMaps.size());
                for (auto i = 0; i < fileNames.size(); i++)
                    fileNames[i] = {fileNameNoExtension + (i != 0 ? "_" + std::to_string(i) : "") + "." + mImageFormat};

                // heatMaps -> cvOutputDatas
                std::vector<cv::Mat> cvOutputDatas(heatMaps.size());
                for (auto i = 0; i < cvOutputDatas.size(); i++)
                    unrollArrayToUCharCvMat(cvOutputDatas[i], heatMaps[i]);

                // Save each heatMap
                for (auto i = 0; i < cvOutputDatas.size(); i++)
                    saveImage(cvOutputDatas[i], fileNames[i]);
            }
        }
        catch (const std::exception& e)
        {
            error(e.what(), __LINE__, __FUNCTION__, __FILE__);
        }
    }
コード例 #2
0
 void WVideoSaver<TDatums>::workConsumer(const TDatums& tDatums)
 {
     try
     {
         if (checkNoNullNorEmpty(tDatums))
         {
             // Debugging log
             dLog("", Priority::Low, __LINE__, __FUNCTION__, __FILE__);
             // Profiling speed
             const auto profilerKey = Profiler::timerInit(__LINE__, __FUNCTION__, __FILE__);
             // T* to T
             auto& tDatumsNoPtr = *tDatums;
             // Record video(s)
             std::vector<cv::Mat> cvOutputDatas(tDatumsNoPtr.size());
             for (auto i = 0u ; i < cvOutputDatas.size() ; i++)
                 cvOutputDatas[i] = tDatumsNoPtr[i].cvOutputData;
             spVideoSaver->write(cvOutputDatas);
             // Profiling speed
             Profiler::timerEnd(profilerKey);
             Profiler::printAveragedTimeMsOnIterationX(profilerKey, __LINE__, __FUNCTION__, __FILE__);
             // Debugging log
             dLog("", Priority::Low, __LINE__, __FUNCTION__, __FILE__);
         }
     }
     catch (const std::exception& e)
     {
         this->stop();
         error(e.what(), __LINE__, __FUNCTION__, __FILE__);
     }
 }