/src/Thinkingtime_for_copy_task.java
Java | 404 lines | 267 code | 59 blank | 78 comment | 58 complexity | e3b8de28a023b76e9f8264988b3e42c5 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 Thinkingtime_for_copy_task{
- public static void main (String[] args)throws Exception,NullPointerException
- {
- int location[][] = new int[17][4];
- int error[][] = new int[1][4];
- File[] g = new File(("C:/Users/chens_000/Desktop/Test/new")).listFiles();
-
- for (int p=0;p <g.length;p++)
- {
-
-
- // System.out.println(g[p].getName());
- int task = taskorder(g[p].getName());
-
- IplImage src = cvLoadImage(g[p].getPath(),0);
-
- if(task == -1)
- {
- IplImage tmp2 = cvLoadImage("f.jpg",0);
- IplImage result2 = cvCreateImage(cvSize(src.width()-tmp2.width()+1, src.height()-tmp2.height()+1), IPL_DEPTH_32F, 1);
- cvZero(result2);
- cvMatchTemplate(src, tmp2, result2, CV_TM_CCORR_NORMED);
- double[] min_val = new double[2];
- double[] max_val = new double[2];
-
- CvPoint minLoc = new CvPoint();
- CvPoint maxLoc = new CvPoint();
-
- cvMinMaxLoc(result2, min_val, max_val, minLoc, maxLoc, null);
-
- CvPoint point = new CvPoint();
- point.x(maxLoc.x()+tmp2.width());
- point.y(maxLoc.y()+tmp2.height());
- error[0][0] = maxLoc.x();
- error[0][1] = maxLoc.y();
- error[0][2] = point.x();
- error[0][3] = point.y();
- System.out.println(g[p].getName()+" "+task+" ("+maxLoc.x()+", "+maxLoc.y()+") ("+point.x()+", "+point.y()+")");
-
- cvReleaseImage(src);
- cvReleaseImage(tmp2);
- cvReleaseImage(result2);
- continue;
- }
-
- if(task == 0)
- {
- IplImage tmp1 = cvLoadImage("e.jpg",0);
- IplImage result1 = cvCreateImage(cvSize(src.width()-tmp1.width()+1, src.height()-tmp1.height()+1), IPL_DEPTH_32F, 1);
- cvZero(result1);
- cvMatchTemplate(src, tmp1, result1, CV_TM_CCORR_NORMED);
- double[] min_val = new double[2];
- double[] max_val = new double[2];
-
- CvPoint minLoc = new CvPoint();
- CvPoint maxLoc = new CvPoint();
-
- cvMinMaxLoc(result1, min_val, max_val, minLoc, maxLoc, null);
-
- CvPoint point = new CvPoint();
- point.x(maxLoc.x()+tmp1.width());
- point.y(maxLoc.y()+tmp1.height());
- location[task][0] = maxLoc.x();
- location[task][1] = maxLoc.y();
- location[task][2] = point.x();
- location[task][3] = point.y();
-
- cvReleaseImage(src);
- cvReleaseImage(tmp1);
- cvReleaseImage(result1);
- continue;
- }
- IplImage tmp = cvLoadImage("d.jpg",0);
-
- IplImage result = cvCreateImage(cvSize(src.width()-tmp.width()+1, src.height()-tmp.height()+1), IPL_DEPTH_32F, 1);
- cvZero(result);
-
- cvMatchTemplate(src, tmp, result, CV_TM_CCORR_NORMED);
-
-
- double[] min_val = new double[2];
- double[] max_val = new double[2];
-
- CvPoint minLoc = new CvPoint();
- CvPoint maxLoc = new CvPoint();
-
- cvMinMaxLoc(result, min_val, max_val, minLoc, maxLoc, null);
-
- CvPoint point = new CvPoint();
- point.x(maxLoc.x()+tmp.width());
- point.y(maxLoc.y()+tmp.height());
- location[task][0] = maxLoc.x();
- location[task][1] = maxLoc.y();
- location[task][2] = point.x();
- location[task][3] = point.y();
-
- System.out.println(g[p].getName()+" "+task+" ("+maxLoc.x()+", "+maxLoc.y()+") ("+point.x()+", "+point.y()+")");
- cvReleaseImage(src);
- cvReleaseImage(tmp);
- cvReleaseImage(result);
- }
-
-
- File f = new File(("C:/Users/chens_000/Desktop/Test/Mouse_location_with_time.txt"));
- File h = new File(("C:/Users/chens_000/Desktop/Test/Frame_and_mouselocation_and_keystroke_and_time.txt"));
- File t = new File(("C:/Users/chens_000/Desktop/Test/Keystroke_with_time.txt"));
- // File g = new File("C:/Users/chens_000/Desktop/New1/Mrigendra_Singh/Frame_and_mouselocation_and_keystroke_and_time.txt");
- // File f = new File("C:/Users/chens_000/Desktop/New1/Mrigendra_Singh/Mouse_location_with_time.txt");
- // System.out.println(g[0].getName());
-
- long timestample[] = new long[17];
- Scanner s = new Scanner(h);
- Scanner r = new Scanner(f);
- Scanner v = new Scanner(t);
- v.useDelimiter("\\s+|,|\\n|:|;|\\(|\\)| ");
- s.useDelimiter("\\s+|,|\\n|:|;|\\(|\\)| ");
- r.useDelimiter("\\s+|,|\\n|:|;|\\(|\\)| ");
- long a[] = new long[200000];
- long b[] = new long[200000];
- String d[] = new String[200000];
- String q[] = new String[200000];
- q[0] = null;
- int qq=0;
-
- int ii = 0;
- a[0] = 0;
- String c = null;
- d[0] = null;
- int jj = 0;
- b[0] = 0;
- String e = null;
- int kk=0;
- while (v.hasNext())
- {
- q[qq]=v.next();
- // System.out.println(q[qq]+" ");
- qq++;
- }
- while (s.hasNext())
- {
- c = s.next();
- d[kk] = c;
- // System.out.println(d[kk]);
- kk++;
- if (isParsableToInt(c))
- {
- a[ii] = Long.parseLong(c);
- // System.out.println(a[ii]+" ");
- ii++;
- }
- }
-
-
- while (r.hasNext())
- {
- e = r.next();
- if (isParsableToInt(e))
- {
- b[jj] = Long.parseLong(e);
- // System.out.println(b[jj]+" ");
- jj++;
- }
- }
- int k = 0;
- int l=4;
- int m;
-
- int mm;
- int ll = 10;
- int it = 4;
- int pro = 0;
- for(int n=0;n<17;n++)
- { // System.out.println(n+ " this is n ");
- for(m=l;m<jj;m+=4)
- {
-
- // System.out.println(n+" "+location[n][0]+" <= "+b[m]+" <= " +location[n][2]+" "+location[n][1]+" <= "+b[m+1]+" <= "+location[n][3]+" "+b[m+2]+" "+b[m+3]);
- if(((location[n][0])<=b[m]) && (b[m]<=(location[n][2])) && ((location[n][1]-1)<=b[m+1]) && (b[m+1]<=(location[n][3]+10)) && (b[m+2]==1) && (b[m-2]==1) && ((b[m+3]-b[m-1])<1000))
- {
- timestample[n]=b[m+3];
- // System.out.println(n+" "+location[n][0]+" "+b[m]+" "+location[n][2]+" "+b[m+1]+" "+location[n][3]);
- // System.out.println(n+" "+timestample[n]);
- l=m+4;
- break;
- }
- }
-
- if(n>0)
- {
- for(int ml = l; ml<l+800; ml+=4 )
- {
- // System.out.println(b[ml]+" "+b[ml+2]+" "+b[ml+1]+" "+b[ml+3]);
- if((error[0][0] <= b[ml]) && (b[ml]<= error[0][2]) && (error[0][1]<=b[ml+1]) && (b[ml+1]<=error[0][3]) && (b[ml+2]==1) && (b[ml-2]==1))
- {
- --n;
- break;
- }
- }
- }
- /* if(n==10)
- {
- for(int ml = l; ml<l+800; ml+=4 )
- {
- System.out.println(b[ml]+" "+b[ml+2]+" "+b[ml+1]+" "+b[ml+3]);
- if((error[0][0] <= b[ml]) && (b[ml]<= error[0][2]) && (error[0][1]<=b[ml+1]) && (b[ml+1]<=error[0][3]) && (b[ml+2]==1) && (b[ml-2]==1))
- {
- --n;
- break;
- }
- }
- }*/
- }
- int u=4;
- int w;
- long frame[] = new long[17];
- for(int n=0;n<17;n++)
- {
- for( w=u;w<ii;w++)
- {
- if( (100000<a[w-3]) & (100000<a[w+1]) & (a[w-3]<=timestample[n]) & (timestample[n]<=a[w+1]))
- {
- // System.out.println(n+" "+w+" "+a[w-3]+" "+timestample[n]+" "+a[w+1]);
- frame[n] = a[w];
- System.out.println(n+" "+frame[n]+" "+timestample[n]);
- u=w;
- break;
- }
-
- }
-
-
- }
- long next[] = new long[17];
- int bb = 1;
- oo: for(int n=0;n<16;n++)
- {
- for(int aa=bb; aa<qq;aa++)
- {
- if (isParsableToInt(q[aa]))
- {
- if(n==2)
- {
- next[n] = timestample[n+1];
- System.out.println((next[n]-timestample[n])/1000.000);
- continue oo;
- }
- if((Long.parseLong(q[aa])>timestample[n]))
- {
- for(int run=aa+1;run<aa+10;run++)
- {
- if(q[run].equals("Press"))
- {
- for(int rr = run+1;rr<run+4;rr++)
- {
- if((isParsableToInt(q[rr])) && (Long.parseLong(q[rr])>10000))
- {
- next[n]=Long.parseLong(q[rr]);
- bb = run+4;
- System.out.println((next[n]-timestample[n])/1000.000);
- continue oo;
- }
- }
- }
- }
- }
- }
-
- }
-
- }
-
-
-
-
-
- /*
- long d[] = new long[ii];
-
-
- for (int j = 0; j < ii; j++)
- {
- d[j] = Long.parseLong(a[j]);
- }
-
-
- k=0;
- for (int j = 1; j <ii; j++)
- {
- if(d[j]>90000)
- k++;
-
- }
-
- long m[]=new long[k];
- k=0;
- for( int j=1;j<ii;j++)
- {
- if(d[j]>90000)
- {
- m[k]=d[j];
-
- k++;
-
- }
- }
-
- int count1=0;
- int temp=0;
- for(int j=1;j<k;j++)
- {
- for(int ij=2;ij<=jj/4;ij++)
- {
- if((m[j-1]<=b[ij*4-1])&(b[ij*4-1]<m[j]))
- {
-
- if(((b[ij*4-2]-b[ij*4-6])!=0) |((b[ij*4-3]-b[ij*4-7])!=0)|((b[ij*4-4])!=0)|((b[ij*4-8])!=0))
- count1++;
-
- }
- }
-
-
-
- System.out.println(count1);
-
- count1=0;
- }
- */
-
- }
-
-
-
-
-
-
- public static int taskorder(String i){
-
-
- int j = 0;
- if(i.equals("error.jpg"))
- j=-1;
- if(i.equals("pre.jpg"))
- j=0;
- if(i.equals("task1.jpg"))
- j=1;
- if(i.equals("task2.jpg"))
- j=2;
- if(i.equals("task3.jpg"))
- j=3;
- if(i.equals("task3a.jpg"))
- j=4;
- if(i.equals("task3b.jpg"))
- j=5;
- if(i.equals("task3c.jpg"))
- j=6;
- if(i.equals("task3d.jpg"))
- j=7;
- if(i.equals("task4.jpg"))
- j=8;
- if(i.equals("task5.jpg"))
- j=9;
- if(i.equals("task6.jpg"))
- j=10;
- if(i.equals("task7.jpg"))
- j=11;
- if(i.equals("task8.jpg"))
- j=12;
- if(i.equals("task9.jpg"))
- j=13;
- if(i.equals("task10.jpg"))
- j=14;
- if(i.equals("task11.jpg"))
- j=15;
- if(i.equals("task12.jpg"))
- j=16;
-
-
-
- return j;
-
- }
-
- public static boolean isParsableToInt(String i) {
-
- try
- {
- Long.parseLong(i);
- return true;
- }
- catch (NumberFormatException nfe)
- {
- return false;
- }
- }
-
-
- }