/src/BeforeAfter.java
Java | 161 lines | 117 code | 26 blank | 18 comment | 25 complexity | e2b70c86e61548d0f3760f25a4355b82 MD5 | raw file
- import static com.googlecode.javacv.cpp.opencv_core.*;
- import static com.googlecode.javacv.cpp.opencv_imgproc.*;
- import static com.googlecode.javacv.cpp.opencv_highgui.*;
- import java.io.File;
- import java.util.Scanner;
-
- public class BeforeAfter{
- public static void main (String[] args)throws Exception,NullPointerException
- {
- int location[][] = new int[16][4];
- long click[][] = new long[1000][2];
-
- File key = new File(("C:/Users/chens_000/Desktop/3.txt"));
-
- long timestample[] = new long[1000];
- Scanner keys = new Scanner(key);
-
- keys.useDelimiter("\\s+|,|\\n|:|;|\\(|\\)| ");
-
- String b[] = new String[200000];
-
- int ii = 0;
- String c = null;
- int jj = 0;
- b[0] = null;
-
- while (keys.hasNext())
- {
- b[ii] = keys.next();
- if((b[ii].equals("Period")) && (b[ii-1].equals("Relea")))
- {
- timestample[jj] = Long.parseLong(keys.next());
- System.out.println(timestample[jj]+" "+jj);
- jj++;
- }
- ii++;
-
-
- }
-
- File frame = new File(("C:/Users/chens_000/Desktop/2.txt"));
- Scanner frames = new Scanner(frame);
- frames.useDelimiter("\\s+|,|\\n|:|;|\\(|\\)| ");
-
- int iii = 0;
- int jjj = 0;
- String e = null;
- long a[] = new long[200000];
- a[0] = 0;
- long frame_time[][] = new long[10000][2];
- while (frames.hasNext())
- {
- e = frames.next();
- if(isParsableToInt(e))
- {
- a[iii] = Long.parseLong(e);
- if(a[iii]>10000)
- {
- frame_time[jjj][0] = a[iii-1];
- frame_time[jjj][1] = a[iii];
- // System.out.println(frame_time[jjj][0]+" "+frame_time[jjj][1]);
- jjj++;
- }
- iii++;
- }
- }
- int k=0;
- long before_after[][] = new long[jj][2];
- for(int n=0;n<jj;n++)
- {
- for(int m=0;m<jjj;m++)
- {
- if((frame_time[m][1]<=timestample[n])&&(timestample[n]<=frame_time[m+1][1]))
- {
- before_after[k][0] = frame_time[m][0];
- before_after[k][1] = frame_time[m+1][0];
- System.out.println(before_after[k][0] +" "+before_after[k][1]+" "+n );
-
- }
- }
- }
-
- /*
- long xy[][][]= new long[16][10000][2];
- IplImage src = cvLoadImage("C:/Users/chens_000/Desktop/new2/click.jpg",0);
- // IplImage gray = cvCreateImage(cvGetSize(src), IPL_DEPTH_32F, 1);
- int radius = 1;
- l=0;
- int lo=0;
- for(lo=0;lo<dian;lo++)
- {
- CvPoint center = cvPointFrom32f(new CvPoint2D32f(click[lo][0],click[lo][1]));
- cvCircle(src, center, radius, CvScalar.GREEN, 6, CV_AA, 0);
-
- }
- cvSaveImage("C:/Users/chens_000/Desktop/new2/click1.jpg", src);
- cvShowImage("Result",src);
- cvWaitKey(0);
- */
-
- }
-
- public static int taskorder(String i){
-
-
- int j = 0;
-
- if(i.equals("task1.jpg"))
- j=0;
- if(i.equals("task2.jpg"))
- j=1;
- if(i.equals("task3.jpg"))
- j=2;
- if(i.equals("task3a.jpg"))
- j=3;
- if(i.equals("task3b.jpg"))
- j=4;
- if(i.equals("task3c.jpg"))
- j=5;
- if(i.equals("task3d.jpg"))
- j=6;
- if(i.equals("task4.jpg"))
- j=7;
- if(i.equals("task5.jpg"))
- j=8;
- if(i.equals("task6.jpg"))
- j=9;
- if(i.equals("task7.jpg"))
- j=10;
- if(i.equals("task8.jpg"))
- j=11;
- if(i.equals("task9.jpg"))
- j=12;
- if(i.equals("task10.jpg"))
- j=13;
- if(i.equals("task11.jpg"))
- j=14;
- if(i.equals("task12.jpg"))
- j=15;
-
-
-
- return j;
-
- }
-
- public static boolean isParsableToInt(String i) {
-
- try
- {
- Long.parseLong(i);
- return true;
- }
- catch (NumberFormatException nfe)
- {
- return false;
- }
- }
-
-
- }