Ignore:
Timestamp:
2019-07-11T18:33:51+12:00 (5 years ago)
Author:
cpb16
Message:

Added x pos checker, needs testing, and remove errors

File:
1 edited

Legend:

Unmodified
Added
Removed
  • other-projects/is-sheet-music-encore/trunk/image-identification-development/src/Main.java

    r33324 r33325  
    180180
    181181    }
    182     public static Boolean ClusterCheck(StartAndEndPoint parseArray[]){
    183         System.out.println("LENGTH: " + parseArray.length);
    184         //MAKE THREE COMPARISONS
    185         //After clusters have been found.
    186         //Check if  their x positions intersect
    187         //Logic being
    188         //(L1.S < L2.E && L1.S > L2.S)
    189         //or
    190         //(L2.S < L1.E && L2.S > L1.S)
    191         //Variance is using Start of line point.
    192         //USING VARIANTS
     182    public static double VarianceCalc(StartAndEndPoint parseArray[]){
    193183        double sum =0;
    194184        double temp =0;
     
    207197        variance = Math.abs(temp/(size -1));
    208198        System.out.println("VARIANCE: " + variance);
    209         if(variance <= CLUSTER_DISTANCE_MAX && variance > CLUSTER_DISTANCE_MIN){
    210             for(int i = 0; i < 3; i++){
    211                 double l1_S = parseArray[i].getP1().x;
    212                 double l1_E = parseArray[i].getP2().x;
    213                 double l2_S =
    214 
    215             }
     199        return variance;
     200    }
     201    public static Boolean lineComparison(double baseLineS, double compareLineS, double compareLineE ){
     202        if(baseLineS < compareLineE && baseLineS > compareLineS){
     203            return true;
    216204        }
    217205        return false;
     206    }
     207    public static Boolean ClusterCheck(StartAndEndPoint parseArray[]){
     208        try {
     209            System.out.println("LENGTH: " + parseArray.length);
     210            //MAKE THREE COMPARISONS
     211            //After clusters have been found.
     212            //Check if  their x positions intersect
     213            //Logic being
     214            //(L1.S < L2.E && L1.S > L2.S)
     215            //or
     216            //(L2.S < L1.E && L2.S > L1.S)
     217            //Variance is using Start of line point.
     218            //USING VARIANTS
     219            double variance = VarianceCalc(parseArray);
     220            Boolean consistent = false;
     221            if (variance <= CLUSTER_DISTANCE_MAX && variance > CLUSTER_DISTANCE_MIN) {
     222                for (int i = 0; i < parseArray.length - 1; i++) {
     223                    System.out.println(i);
     224                    double l1_S = parseArray[i].getP1().x;
     225                    double l1_E = parseArray[i].getP2().x;
     226                    double l2_S = parseArray[i + 1].getP1().x;
     227                    double l2_E = parseArray[i + 1].getP2().x;
     228
     229                    //Check which starts after
     230                    if (l1_S >= l2_S) {
     231                        //baseLineStart is l1_S (call with lineComparison)
     232                        consistent = lineComparison(l1_S, l2_S, l2_E);
     233
     234                    } else if (l2_S > l1_S) {
     235                        //baseLineStart is l2_S (call with lineComparison)
     236                        consistent = lineComparison(l2_S, l1_S, l1_E);
     237                    } else {
     238                        System.err.println("An error, comparing l1_S and l2_S, has occurred");
     239                    }
     240
     241                    //Check if false was returned;
     242                    if (consistent == false) {
     243                        System.out.println(" X positions of two lines did not overlap each other" + '\t');
     244                        System.out.print("l1_S: " + l1_S + '\t');
     245                        System.out.print("l1_E: " + l1_E + '\t');
     246                        System.out.print("l2_S: " + l2_S + '\t');
     247                        System.out.print("l2_E: " + l2_E);
     248                        return false;
     249                    }
     250                }
     251                //Have been through for loop, maintaining consistent being true.
     252                //Have also meet the variance MIN and MAX requirement. Therefore it is a cluster
     253                return true;
     254            }
     255            System.out.println("Did not meet Cluster Distance Min and Max requirements, Variance = " + variance);
     256            return false;
     257        }
     258        catch (Exception e){
     259            System.err.println("           "+e.getMessage());
     260            return false;
     261        }
    218262    }
    219263
     
    680724        }
    681725        catch (Exception e) {
    682             System.err.println(e);
     726            System.err.println("          " +e.getMessage());
    683727        }
    684728        return returnArray;
Note: See TracChangeset for help on using the changeset viewer.