コード例 #1
0
  public static Result verifySignature(String accno) {
    Customer cust = Customer.byAccno(accno);
    float[] src = new float[96];
    String angles = cust.signOneAngles;
    StringTokenizer st = new StringTokenizer(angles, "|");
    int tokenCount = st.countTokens();
    for (int i = 0; i < tokenCount; i++) {
      String token = st.nextToken();
      float angle = Float.parseFloat(token);
      src[i] = angle;
    }
    String inputFile = "public/signatureimages/" + accno + "/" + accno + "_verify.jpg";
    String smoothfilename = "public/signatureimages/" + accno + "/" + accno + "_verify_smooth.jpg";
    String binaryfilename = "public/signatureimages/" + accno + "/" + accno + "_verify_binary.jpg";
    String sizeNormalizeFileName =
        "public/signatureimages/" + accno + "/" + accno + "_verify_normalize.jpg";
    SigImgProcessingController.smoothing(inputFile, smoothfilename);
    SigImgProcessingController.binarization(smoothfilename, binaryfilename);
    SigImgProcessingController.sizeNormalization(binaryfilename, sizeNormalizeFileName);
    float[] trg = SigImgProcessingController.calculateAngles(sizeNormalizeFileName);

    if (SigImgProcessingController.compareBlockAngles(src, trg)) {
      return ok("Signatures Matched");
    } else {
      return ok("Signatures Not Matched");
    }
  }
コード例 #2
0
  public static Result create_save() {
    Form<CustomerForm> filledForm = customerForm.bindFromRequest();

    if (filledForm.hasErrors()) {
      System.out.println("in error");
      return badRequest(create.render(filledForm));
    }

    CustomerForm customerForm = filledForm.get();
    if (customerForm == null) {
      System.out.println("in form");
      return badRequest(create.render(filledForm));
    }

    Customer customer = new Customer();
    formToModel(customer, customerForm);
    MultipartFormData body = request().body().asMultipartFormData();
    FilePart picture1 = body.getFile("signatureOne");
    FilePart picture2 = body.getFile("signatureTwo");
    if (picture1 != null && picture2 != null) {
      File file1 = picture1.getFile();
      File file2 = picture2.getFile();
      String path = "public/signatureimages/" + customer.accountNumber;
      File f = new File(path);
      f.mkdir();
      file1.renameTo(new File(path, customer.signatureOne));
      file2.renameTo(new File(path, customer.signatureTwo));
      System.out.println("File uploaded successfully...");
    } else {
      filledForm.reject("file", "Please select the image to uplaod");
    }

    String inputFile =
        "public/signatureimages/" + customer.accountNumber + "/" + customer.signatureOne;
    String smoothfilename =
        "public/signatureimages/" + customer.accountNumber + "/signatureOne_smooth.jpg";
    String binaryfilename =
        "public/signatureimages/" + customer.accountNumber + "/signatureOne_binary.jpg";
    String sizeNormalizeFileName =
        "public/signatureimages/" + customer.accountNumber + "/signatureOne_normalize.jpg";
    SigImgProcessingController.smoothing(inputFile, smoothfilename);
    SigImgProcessingController.binarization(smoothfilename, binaryfilename);
    SigImgProcessingController.sizeNormalization(binaryfilename, sizeNormalizeFileName);
    float[] sig1 = SigImgProcessingController.calculateAngles(sizeNormalizeFileName);
    StringBuffer angels = new StringBuffer();

    for (int i = 0; i < sig1.length; i++) {
      angels.append(sig1[i] + "|");
    }
    System.out.println("Angles: " + angels);
    customer.signOneAngles = angels.toString();

    customer.save();
    return redirect(controllers.routes.CustomerController.index());
  }