Advertisement
Guest User

Untitled

a guest
Jul 28th, 2014
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.21 KB | None | 0 0
  1. ~
  2. ~
  3. 1 #include "mrg/foundation/logging/FrameLogger.h"
  4. 2 #include "mrg/foundation/logging/ProtocolBufferLogFrame.h"
  5. 3 #include "mrg/foundation/image/ImageProtocolBufferAdaptor.h"
  6. 4 #include "mrg/foundation/image/ImageBase.h"
  7. 5 #include "mrg/foundation/image/ImageForward.h"
  8. 6 #include "mrg/foundation/image/ImageTypes.h"
  9. 7 #include "opencv2/opencv.hpp"
  10. 8 #include "mrg/adaptors/opencv/image/OpenCVImageAdaptor.h"
  11. 9 #include "cv.h"
  12. 10 #include "highgui.h"
  13. 11 #include "protobuf/image/pbImageArray.pb.h"
  14. 12 #include "cvaux.h"
  15. 13
  16. 14
  17. 15
  18. 16 int main(int argc, char* argv[]){
  19. 17
  20. 18 std::string videoOutput = "/Users/juliedequaire/data/logView/MyNewbieProject/bbmono/video.avi";
  21. 19 std::string loggingPath = "/Users/juliedequaire/data/logs/MyNewbieProject/bbmono/2014-07-28-11-25-47/bbee.monolithic" ;
  22. 20 mrg::foundation::logging::FrameLogger logger ;
  23. 21
  24. 22 logger.Open(loggingPath, mrg::foundation::logging::READ);
  25. 23
  26. 24 // opencv
  27. 25 int fourcc = CV_FOURCC('F','F','V','1');
  28. 26 double fps = 20;
  29. 27
  30. 28 cv::VideoWriter video;
  31. 29 video.open(videoOutput, fourcc, fps, cv::Size(480,640), false);
  32. 30 cv::Mat cvImg ;
  33. 31
  34. 32 // read monolithic file
  35. 33 mrg::datatypes::protobuf::image::pbImageArray pbImg ;
  36. 34 mrg::foundation::logging::ProtocolBufferLogFrame<mrg::datatypes::protobuf::image::pbImageArray> imArrPBFrame(pbImg);
  37. 35
  38. 36
  39. 37 while(!logger.ReachedEndOfLog()){
  40. 38 logger.Read(imArrPBFrame);
  41. 39 std::vector<mrg::foundation::image::ImageBaseSPtr_t> imgSPtr = mrg::foundation::image::ImageProtocolBufferAdaptor::ImageArrayFro mProtocolBuffer(pbImg);
  42. 40
  43. 41 for (unsigned int i=0; i < imgSPtr.size(); ++i){
  44. 42
  45. 43 cvImg = mrg::adaptors::opencv::image::OpenCVImageAdaptor::DeepAdaptImageToOpenCVImage(*imgSPtr[i], true);
  46. 44 cv::resize(cvImg, cvImg, cv::Size(480,640),0,0,cv::INTER_NEAREST);
  47. 45 std::cout << cvImg.type() << std::endl;
  48. 46 cv::imshow("mono pict", cvImg);
  49. 47 cv::waitKey(50);
  50. 48 video.write(cvImg);
  51. 49
  52. 50 }
  53. 51 }
  54. 52 video.release();
  55. 53
  56. 54
  57. 55 return 1;
  58. 56
  59. 57 }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement