PageRenderTime 266ms CodeModel.GetById 0ms RepoModel.GetById 1ms app.codeStats 0ms

/src/BeforeAfter.java

https://bitbucket.org/yan_chen/pc-image-processing
Java | 161 lines | 117 code | 26 blank | 18 comment | 25 complexity | e2b70c86e61548d0f3760f25a4355b82 MD5 | raw file
  1. import static com.googlecode.javacv.cpp.opencv_core.*;
  2. import static com.googlecode.javacv.cpp.opencv_imgproc.*;
  3. import static com.googlecode.javacv.cpp.opencv_highgui.*;
  4. import java.io.File;
  5. import java.util.Scanner;
  6. public class BeforeAfter{
  7. public static void main (String[] args)throws Exception,NullPointerException
  8. {
  9. int location[][] = new int[16][4];
  10. long click[][] = new long[1000][2];
  11. File key = new File(("C:/Users/chens_000/Desktop/3.txt"));
  12. long timestample[] = new long[1000];
  13. Scanner keys = new Scanner(key);
  14. keys.useDelimiter("\\s+|,|\\n|:|;|\\(|\\)| ");
  15. String b[] = new String[200000];
  16. int ii = 0;
  17. String c = null;
  18. int jj = 0;
  19. b[0] = null;
  20. while (keys.hasNext())
  21. {
  22. b[ii] = keys.next();
  23. if((b[ii].equals("Period")) && (b[ii-1].equals("Relea")))
  24. {
  25. timestample[jj] = Long.parseLong(keys.next());
  26. System.out.println(timestample[jj]+" "+jj);
  27. jj++;
  28. }
  29. ii++;
  30. }
  31. File frame = new File(("C:/Users/chens_000/Desktop/2.txt"));
  32. Scanner frames = new Scanner(frame);
  33. frames.useDelimiter("\\s+|,|\\n|:|;|\\(|\\)| ");
  34. int iii = 0;
  35. int jjj = 0;
  36. String e = null;
  37. long a[] = new long[200000];
  38. a[0] = 0;
  39. long frame_time[][] = new long[10000][2];
  40. while (frames.hasNext())
  41. {
  42. e = frames.next();
  43. if(isParsableToInt(e))
  44. {
  45. a[iii] = Long.parseLong(e);
  46. if(a[iii]>10000)
  47. {
  48. frame_time[jjj][0] = a[iii-1];
  49. frame_time[jjj][1] = a[iii];
  50. // System.out.println(frame_time[jjj][0]+" "+frame_time[jjj][1]);
  51. jjj++;
  52. }
  53. iii++;
  54. }
  55. }
  56. int k=0;
  57. long before_after[][] = new long[jj][2];
  58. for(int n=0;n<jj;n++)
  59. {
  60. for(int m=0;m<jjj;m++)
  61. {
  62. if((frame_time[m][1]<=timestample[n])&&(timestample[n]<=frame_time[m+1][1]))
  63. {
  64. before_after[k][0] = frame_time[m][0];
  65. before_after[k][1] = frame_time[m+1][0];
  66. System.out.println(before_after[k][0] +" "+before_after[k][1]+" "+n );
  67. }
  68. }
  69. }
  70. /*
  71. long xy[][][]= new long[16][10000][2];
  72. IplImage src = cvLoadImage("C:/Users/chens_000/Desktop/new2/click.jpg",0);
  73. // IplImage gray = cvCreateImage(cvGetSize(src), IPL_DEPTH_32F, 1);
  74. int radius = 1;
  75. l=0;
  76. int lo=0;
  77. for(lo=0;lo<dian;lo++)
  78. {
  79. CvPoint center = cvPointFrom32f(new CvPoint2D32f(click[lo][0],click[lo][1]));
  80. cvCircle(src, center, radius, CvScalar.GREEN, 6, CV_AA, 0);
  81. }
  82. cvSaveImage("C:/Users/chens_000/Desktop/new2/click1.jpg", src);
  83. cvShowImage("Result",src);
  84. cvWaitKey(0);
  85. */
  86. }
  87. public static int taskorder(String i){
  88. int j = 0;
  89. if(i.equals("task1.jpg"))
  90. j=0;
  91. if(i.equals("task2.jpg"))
  92. j=1;
  93. if(i.equals("task3.jpg"))
  94. j=2;
  95. if(i.equals("task3a.jpg"))
  96. j=3;
  97. if(i.equals("task3b.jpg"))
  98. j=4;
  99. if(i.equals("task3c.jpg"))
  100. j=5;
  101. if(i.equals("task3d.jpg"))
  102. j=6;
  103. if(i.equals("task4.jpg"))
  104. j=7;
  105. if(i.equals("task5.jpg"))
  106. j=8;
  107. if(i.equals("task6.jpg"))
  108. j=9;
  109. if(i.equals("task7.jpg"))
  110. j=10;
  111. if(i.equals("task8.jpg"))
  112. j=11;
  113. if(i.equals("task9.jpg"))
  114. j=12;
  115. if(i.equals("task10.jpg"))
  116. j=13;
  117. if(i.equals("task11.jpg"))
  118. j=14;
  119. if(i.equals("task12.jpg"))
  120. j=15;
  121. return j;
  122. }
  123. public static boolean isParsableToInt(String i) {
  124. try
  125. {
  126. Long.parseLong(i);
  127. return true;
  128. }
  129. catch (NumberFormatException nfe)
  130. {
  131. return false;
  132. }
  133. }
  134. }