Guest User

Untitled

a guest
Mar 20th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. // ConsoleApplication5.cpp : Defines the entry point for the console
  2. application.
  3. //
  4.  
  5. #include "stdafx.h"
  6. #include <opencv2/core.hpp>
  7. #include <opencv2/highgui.hpp>
  8. #include <stdio.h>
  9. #include <algorithm>
  10. #include <array>
  11. #include <chrono>
  12. #include <random>
  13.  
  14. int main()
  15. {
  16.  
  17. /*
  18. This is used to randomize the images.
  19. */
  20.  
  21. std::array<int, 25> randomshuffle;
  22. for (int i = 0; i < 25; i++)
  23. {
  24. randomshuffle[i] = i;
  25. }
  26.  
  27.  
  28. unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
  29. std::shuffle(randomshuffle.begin(), randomshuffle.end(),
  30. std::default_random_engine(seed));
  31. for (int &x : randomshuffle) std::cout << ' ' << x;
  32. std::cout << 'n';
  33.  
  34.  
  35. std::array<int, 4> label = { 0, 1, 2, 3};
  36. for (int i = 0; i < 4; i++)
  37. {
  38. label[i] = i;
  39. }
  40.  
  41.  
  42.  
  43. /*
  44. This is used to import the images using the random image and label.
  45. */
  46.  
  47. for (int i = 0; i < 5; i++)
  48. {
  49. std::string z = "";
  50. unsigned seed2 =
  51. std::chrono::system_clock::now().time_since_epoch().count();
  52. std::shuffle(label.begin(), label.end(),
  53. std::default_random_engine(seed2));
  54.  
  55. if (label[0] == 0)
  56. {
  57. z = "Standing";
  58. }
  59. else if (label[0] == 1)
  60. {
  61. z = "Sitting";
  62. }
  63. else if (label[0] == 2)
  64. {
  65. z = "Laying";
  66. }
  67. else if (label[0] == 3)
  68. {
  69. z = "Active";
  70. }
  71.  
  72.  
  73. cv::Mat image;
  74. int x = 0;
  75. std::string path = "D:\Motion\data\inputs\master\" + z +
  76. std::to_string(randomshuffle[i]) + ".jpg";
  77. image = cv::imread(path);
  78. imshow(z + " " + std::to_string(i), image);
  79. cv::waitKey(10000);
  80. }
  81.  
  82. return 0;
  83. }
Add Comment
Please, Sign In to add comment