public void onStartPostProcessing() {
    LayoutInflater inflator = ApplicationScreen.instance.getLayoutInflater();
    postProcessingView =
        inflator.inflate(R.layout.plugin_processing_sequence_postprocessing, null, false);

    mImgView = ((ImageView) postProcessingView.findViewById(R.id.sequenceImageHolder));

    if (PreviewBmp != null) {
      PreviewBmp.recycle();
    }

    paint = new Paint();
    paint.setColor(0xFF00AAEA);
    paint.setStrokeWidth(5);
    paint.setPathEffect(new DashPathEffect(new float[] {5, 5}, 0));

    PreviewBmp = mAlmaCLRShot.getPreviewBitmap();

    if (PreviewBmp != null) {
      Matrix matrix = new Matrix();
      matrix.postRotate(90);
      Bitmap rotated =
          Bitmap.createBitmap(
              PreviewBmp, 0, 0, PreviewBmp.getWidth(), PreviewBmp.getHeight(), matrix, true);
      mImgView.setImageBitmap(rotated);
      mImgView.setRotation(
          mCameraMirrored
              ? ((mDisplayOrientation == 0 || mDisplayOrientation == 180) ? 0 : 180)
              : 0);
    }

    sequenceView = ((OrderControl) postProcessingView.findViewById(R.id.seqView));
    final Bitmap[] thumbnailsArray = new Bitmap[thumbnails.size()];
    for (int i = 0; i < thumbnailsArray.length; i++) {
      Bitmap bmp = thumbnails.get(i);
      Matrix matrix = new Matrix();
      matrix.postRotate(
          mCameraMirrored
              ? ((mDisplayOrientation == 0 || mDisplayOrientation == 180) ? 270 : 90)
              : 90);
      Bitmap rotated =
          Bitmap.createBitmap(bmp, 0, 0, bmp.getWidth(), bmp.getHeight(), matrix, true);
      thumbnailsArray[i] = rotated;
    }
    sequenceView.setContent(thumbnailsArray, this);
    LayoutParams lp = (LayoutParams) sequenceView.getLayoutParams();
    lp.height = thumbnailsArray[0].getHeight();
    sequenceView.setLayoutParams(lp);

    sequenceView.setRotation(mCameraMirrored ? 180 : 0);

    mHandler.sendEmptyMessage(MSG_END_OF_LOADING);
  }
  @Override
  public void onSequenceChanged(final int[] idx) {
    sequenceView.setEnabled(false);

    Size input = new Size(MainScreen.getImageWidth(), MainScreen.getImageHeight());
    // int imagesAmount =
    // Integer.parseInt(PluginManager.getInstance().getFromSharedMem("amountofcapturedframes"+Long.toString(sessionID)));
    // ArrayList<byte []> compressed_frame = new ArrayList<byte []>();
    int minSize = 1000;
    if (mMinSize == 0) {
      minSize = 0;
    } else {
      minSize = input.getWidth() * input.getHeight() / mMinSize;
    }

    Size preview = new Size(mDisplayWidth, mDisplayHeight);
    try {
      mAlmaCLRShot.initialize(
          preview,
          mAngle,
          /*
           * sensitivity for objection detection
           *
           */
          mSensitivity - 15,
          /*
           *  Minimum size of object to be able to detect
           *  -15 ~ 15
           *  max -> easy detection dull detection
           *  min ->
           */
          minSize,
          /*
           * ghosting parameter
           * 0 : normal operation
           * 1 : detect ghosted objects but not remove them
           * 2 : detect and remove all object
           */
          Integer.parseInt(mGhosting),
          idx);
    } catch (NumberFormatException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (Exception e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    mHandler.sendEmptyMessage(MSG_REDRAW);
  }
  @Override
  public boolean handleMessage(Message msg) {
    switch (msg.what) {
      case MSG_END_OF_LOADING:
        setupSaveButton();
        postProcessingRun = true;
        break;
      case MSG_LEAVING:
        ApplicationScreen.getMessageHandler()
            .sendEmptyMessage(ApplicationInterface.MSG_POSTPROCESSING_FINISHED);

        PluginManager.getInstance()
            .sendMessage(
                ApplicationInterface.MSG_BROADCAST, ApplicationInterface.MSG_CONTROL_UNLOCKED);

        ApplicationScreen.getGUIManager().lockControls = false;

        postProcessingRun = false;
        return false;

      case MSG_REDRAW:
        if (PreviewBmp != null) PreviewBmp.recycle();
        if (finishing) return true;
        PreviewBmp = mAlmaCLRShot.getPreviewBitmap();
        if (PreviewBmp != null) {
          Matrix matrix = new Matrix();
          matrix.postRotate(90);
          Bitmap rotated =
              Bitmap.createBitmap(
                  PreviewBmp, 0, 0, PreviewBmp.getWidth(), PreviewBmp.getHeight(), matrix, true);
          mImgView.setImageBitmap(rotated);
          mImgView.setRotation(
              CameraController.isFrontCamera()
                  ? ((mDisplayOrientation == 0 || mDisplayOrientation == 180) ? 0 : 180)
                  : 0);
        }

        sequenceView.setEnabled(true);
        break;
      default:
        break;
    }
    return true;
  }
  @Override
  public boolean handleMessage(Message msg) {
    switch (msg.what) {
      case MSG_END_OF_LOADING:
        setupSaveButton();
        postProcessingRun = true;
        break;
      case MSG_LEAVING:
        MainScreen.H.sendEmptyMessage(PluginManager.MSG_POSTPROCESSING_FINISHED);
        mJpegBufferList.clear();

        Message msg2 = new Message();
        msg2.arg1 = PluginManager.MSG_CONTROL_UNLOCKED;
        msg2.what = PluginManager.MSG_BROADCAST;
        MainScreen.H.sendMessage(msg2);

        MainScreen.guiManager.lockControls = false;

        postProcessingRun = false;
        return false;

      case MSG_REDRAW:
        if (PreviewBmp != null) PreviewBmp.recycle();
        if (finishing == true) return true;
        PreviewBmp = mAlmaCLRShot.getPreviewBitmap();
        if (PreviewBmp != null) {
          Matrix matrix = new Matrix();
          matrix.postRotate(90);
          Bitmap rotated =
              Bitmap.createBitmap(
                  PreviewBmp, 0, 0, PreviewBmp.getWidth(), PreviewBmp.getHeight(), matrix, true);
          mImgView.setImageBitmap(rotated);
          mImgView.setRotation(
              MainScreen.getCameraMirrored()
                  ? ((mDisplayOrientation == 0 || mDisplayOrientation == 180) ? 0 : 180)
                  : 0);
        }

        sequenceView.setEnabled(true);
        break;
    }
    return true;
  }
  public void onSequenceChanged(final int[] idx) {
    sequenceView.setEnabled(false);

    CameraController.Size imageSize = CameraController.getCameraImageSize();
    Size input = new Size(imageSize.getWidth(), imageSize.getHeight());
    int minSize = 1000;
    if (mMinSize == 0) {
      minSize = 0;
    } else {
      minSize = input.getWidth() * input.getHeight() / mMinSize;
    }

    Size preview = new Size(mDisplayWidth, mDisplayHeight);
    try {
      mAlmaCLRShot.initialize(
          preview,
          mAngle,
          /*
           * sensitivity for objection detection
           */
          mSensitivity - 15,
          /*
           * Minimum size of object to be able to detect -15 ~ 15 max -> easy
           * detection dull detection min ->
           */
          minSize,
          /*
           * ghosting parameter 0 : normal operation 1 : detect ghosted
           * objects but not remove them 2 : detect and remove all object
           */
          Integer.parseInt(mGhosting),
          idx);
    } catch (NumberFormatException e) {
      e.printStackTrace();
    } catch (Exception e) {
      e.printStackTrace();
    }

    mHandler.sendEmptyMessage(MSG_REDRAW);
  }