Advertisement
Guest User

Untitled

a guest
Feb 21st, 2018
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. vbl::CVBLError SaveStatisticsArrayToFS(vbl::const_basestring base_path, vbl::const_basestring filename_template, vbl::const_basestring data_format, vbl::const_basestring estimation_name, vbl::TArray<DATA_TYPE> data) {
  2. vbl::CVBLError result = EVBLErrorOk;
  3.  
  4. CVBLString filename = CVBLString::Format( filename_template, m_StreamNumber ) ;
  5.  
  6. result = vbl::CVBLBaseFile::FolderExists(base_path) ;
  7.  
  8. if (result.IsError()) {
  9. result = vbl::CVBLBaseFile::CreatePathForFile(base_path);
  10. if (result.IsError()) {
  11. result.SetMessage(_T("Could not create folder to save fps estimations") ) ;
  12. return (result);
  13. }
  14. }
  15.  
  16. CVBLString full_path = CVBLString( base_path ) + _T("/") + filename ;
  17.  
  18. vbl::TObjectPtr<vbl::CVBLFileDataWriter> writer = vbl::CVBLBaseFile::CreateFile(full_path.c_ptr(), 0) ;
  19.  
  20. if (writer == NULL) {
  21. result = EVBLErrorIO ;
  22. result.SetMessage( _T("Could not create file to save fps estimations") ) ;
  23. return (result);
  24. }
  25.  
  26. vbl::CVBLString formatted_definition = media_components::CMediaUtils::FormatDefinition( m_MediaDefinition, 0 ) ;
  27.  
  28. vbl::CVBLString header = CVBLString::Format( _T("Estimation name:,%s\nStream definition:\n %s\nFrame,Estimation\n"),
  29. estimation_name,
  30. formatted_definition.c_ptr()
  31. ) ;
  32.  
  33. writer->Write(header.c_ptr(), ( header.GetLength() + 1 ) * sizeof(vbl::basechar) ) ;
  34. for (vbl::baseuint i = 0; i < data.Length(); i++) {
  35. CVBLString message = GenerateMessage( data, i, data_format ) ;
  36. vbl::baseuint data_written = writer->Write(message.c_ptr(), ( message.GetLength() + 1 ) * sizeof(vbl::basechar) ) ;
  37.  
  38. if (data_written != ( ( message.GetLength() + 1 ) * sizeof(vbl::basechar) ) ) {
  39. result = EVBLErrorIO;
  40. result.SetMessage(_T("Failed to write fps statistics to file") ) ;
  41. return (result) ;
  42. }
  43. }
  44. return (result);
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement