MCPcopy Create free account
hub / github.com/alicevision/AliceVision / exportScoresToFile

Method exportScoresToFile

src/aliceVision/keyframe/KeyframeSelector.cpp:796–843  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

794}
795
796bool KeyframeSelector::exportScoresToFile(const std::string& filename, const bool exportSelectedFrames) const
797{
798 std::size_t sequenceSize = scoresMap.begin()->second->size();
799 if (sequenceSize == 0)
800 {
801 ALICEVISION_LOG_ERROR("Nothing to export, scores do not seem to have been computed!");
802 return false;
803 }
804
805 std::ofstream os;
806 os.open((fs::path(_outputFolder) / filename).string(), std::ios::app);
807
808 if (!os.is_open())
809 {
810 ALICEVISION_LOG_ERROR("Unable to open the scores file: " << filename << ".");
811 return false;
812 }
813
814 ALICEVISION_LOG_DEBUG("Exporting scores as CSV file: " << filename << " (export selected frames: " << exportSelectedFrames << ")");
815
816 os.seekp(0, std::ios::end); // Put the cursor at the end of the file
817 if (os.tellp() == std::streampos(0))
818 { // 'tellp' returns the cursor's position
819 // If the file does not exist yet, add a header
820 std::string header = "FrameNb;";
821 for (const auto& mapIterator : scoresMap)
822 header += mapIterator.first + ";";
823
824 if (exportSelectedFrames)
825 header += "Selected;";
826
827 os << header << "\n";
828 }
829
830 for (std::size_t index = 0; index < sequenceSize; ++index)
831 {
832 os << index << ";"; // First column: frame index
833
834 for (const auto& mapIterator : scoresMap)
835 os << mapIterator.second->at(index) << ";";
836 if (exportSelectedFrames)
837 os << _selectedFrames.at(index);
838 os << "\n";
839 }
840
841 os.close();
842 return true;
843}
844
845bool KeyframeSelector::exportFlowVisualisation(const std::size_t rescaledWidth)
846{

Callers 1

aliceVision_mainFunction · 0.80

Calls 4

pathClass · 0.85
closeMethod · 0.80
sizeMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected