The quickest recording of a range of events

The quickest recording of a range of events

Hello Prophesee Team,
I want to write some amounts of events (200ms, several pipeline slices) before a dynamically calculated point in time. I am always saving last 5 pointers of event buffers to deque, and use it to write events when I need it.
WriteCSV() works, but I want to do that quicker, so I tried to write in the .RAW file, and have problems with the WriteRAW().
The .raw file is created, but it is not loaded in the Metavision studio,
metavision_file_to_dat.exe has many NonMonotonicTimeHigh and InvalidVectBase errors.

and the metavision_evt2_raw_file_decoder.exe and metavision_evt3_raw_file_decoder.exe both create the output file with garbage values.

for the writing I have used code in the openeb/.../i_events_stream.cpp

  1. ofs.write(reinterpret_cast<char*>(buffer->data()), size * sizeof(Metavision::I_EventsStream::RawData));

Do you see any problems in this code:

  1. EventsWriter::EventsWriter(Metavision::Camera& camera)
  2. {
  3.     header = camera.get_device().get_facility<Metavision::I_HW_Identification>()->get_header();
  4.     header.add_date();
  5. }

  6. bool EventsWriter::AddSlice(EventBufferPtr buffer)
  7. {
  8.     buffers_deque.push_back(buffer);

  9.     if (buffers_deque.size() > buffers_amount)
  10.         buffers_deque.pop_front();

  11.     return true;
  12. }

  13. bool EventsWriter::WriteCSV()
  14. {
  15.     if (!buffers_deque.empty())
  16.     {
  17.         auto start = buffers_deque.front()->front().t;
  18.         auto end = buffers_deque.back()->back().t;
  19.         std::ostringstream ss;

  20.         for (auto& buffer : buffers_deque)
  21.             for (auto& evt : *buffer)
  22.                 ss << evt.t << "," << evt.x << "," << evt.y << "," << evt.p << "\n";

  23.         std::stringstream filename;
  24.         filename << start << "-" << end << ".csv";
  25.         std::ofstream ofs(filename.str());
  26.         ofs << ss.str();
  27.     }
  28.     return true;
  29. }

  30. bool EventsWriter::WriteRAW()
  31. {
  32.     if (!buffers_deque.empty())
  33.     {
  34.         auto start = buffers_deque.front()->front().t;
  35.         auto end = buffers_deque.back()->back().t;

  36.         std::stringstream filename;
  37.         filename << start << "-" << end << ".raw";
  38.         std::ofstream ofs(filename.str());
  39.         ofs << header;

  40.         for (auto& buffer : buffers_deque)
  41.         {
  42.             auto size = buffer->size();
  43.             ofs.write(reinterpret_cast<char*>(buffer->data()), size * sizeof(Metavision::I_EventsStream::RawData));
  44.         }
  45.         ofs.close();
  46.         ofs.clear();
  47.     }
  48.     return true;
  49. }



    As a Prophesee customer, join the community conversation. 
    Request your free access today.