コード例 #1
0
  private void processNetwork() throws IOException {
    System.out.println("Downsampling images...");

    for (final ImagePair pair : this.imageList) {
      final NeuralData ideal = new BasicNeuralData(this.outputCount);
      final int idx = pair.getIdentity();
      for (int i = 0; i < this.outputCount; i++) {
        if (i == idx) {
          ideal.setData(i, 1);
        } else {
          ideal.setData(i, -1);
        }
      }

      final Image img = ImageIO.read(pair.getFile());
      final ImageNeuralData data = new ImageNeuralData(img);
      this.training.add(data, ideal);
    }

    final String strHidden1 = getArg("hidden1");
    final String strHidden2 = getArg("hidden2");

    this.training.downsample(this.downsampleHeight, this.downsampleWidth);

    final int hidden1 = Integer.parseInt(strHidden1);
    final int hidden2 = Integer.parseInt(strHidden2);

    this.network =
        EncogUtility.simpleFeedForward(
            this.training.getInputSize(), hidden1, hidden2, this.training.getIdealSize(), true);
    System.out.println("Created network: " + this.network.toString());
  }
コード例 #2
0
 public void handleIntent(int requestCode, int resultCode, Intent data) {
   if (resultCode == Activity.RESULT_OK && requestCode == REQUEST_CAPTURE) {
     setCapturedImage();
   } else if (resultCode == Activity.RESULT_OK && requestCode == REQUEST_GALLERY && null != data) {
     mImagePair.imagePath =
         ImageUtils.getSmallImageFromSDCard(
             folderName, ImageUtils.getRealPathFromURI(mContext, data.getData()), mWidth, mHeight);
     mImagePair.imageView.setImageBitmap(
         ImageUtils.getBitmapFromFile(mImagePair.imagePath, mWidth, mHeight));
   } else if (resultCode == Activity.RESULT_CANCELED
       && (requestCode == REQUEST_CAPTURE || requestCode == REQUEST_GALLERY)) {
     mImagePair.imagePath = null;
   }
 }