public void onCreate(ViewGroup groupView) {
   log.pushTimer(this, "start");
   // Create OpenCV part:
   if (RUN_OPENCV) {
     opencv = new OpenCVInterface(this, this.mainActivity);
     JavaCameraView cameraView = new JavaCameraView(mainActivity, JavaCameraView.CAMERA_ID_ANY);
     cameraView.setLayoutParams(
         new FrameLayout.LayoutParams(
             ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
     cameraView.enableFpsMeter();
     cameraView.setVisibility(JavaCameraView.GONE);
     groupView.addView(cameraView);
     opencv.onCreate(cameraView);
   }
   // Create OpenGL render part:
   if (RUN_RENDERER) {
     render = new RenderInterface(this);
     GLSurfaceView renderView = new GLSurfaceView(mainActivity.getApplicationContext());
     renderView.setLayoutParams(
         new FrameLayout.LayoutParams(
             ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
     groupView.addView(renderView);
     render.onCreate(renderView);
   }
   // Set layout things:
   mainActivity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
   log.log(TAG, "Framework created in " + log.popTimer(this).time + "ms.");
 }
  /**
   * Rendering of a single frame. Here we update and render the detected trackable list.
   *
   * @param gl Unused context.
   */
  @Override
  public void onDrawFrame(GL10 gl) {
    if (MainInterface.DEBUG_FRAME_LOGGING) log.pushTimer(this, "opengl frame");

    // Clear:
    GLES20.glClear(GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT);

    // If new markerlist, get:
    if (mainInterface.getListUpdateStatus()) {
      this.toRender = mainInterface.getList();
      if (toRender == null) {
        log.log(TAG, "Error getting list!");
        toRender = new ArrayList<Trackable>();
      } else log.debug(TAG, "Updated list – found " + this.toRender.size() + " " + "trackables.");
    }
    // ------------------------ RENDER ------------------------
    if (!toRender.isEmpty()) {
      for (Trackable trackable : toRender) {
        // Reset model matrix to identity
        Matrix.setIdentityM(mModelMatrix, 0);
        Matrix.multiplyMM(mModelMatrix, 0, trackable.getTRANSLATION(), 0, mModelMatrix, 0);
        drawObject(trackable.getFloatbuffer());
      }
    }
    if (MainInterface.DEBUG_FRAME_LOGGING) {
      log.debug(TAG, "OpenGL rendered frame in " + log.popTimer(this).time + "ms.");
    }
  }
 /**
  * Helper function for setting flags.
  *
  * @param value The flag to set.
  * @param bool The value to set that flag at.
  */
 @SuppressWarnings("UnusedDeclaration")
 public void setFlag(Flags value, boolean bool) {
   switch (value) {
     case ALLOW_DUPLICATE_MARKERS:
       this.ALLOW_DUPLICATE_MARKERS = bool;
       break;
     case ALLOW_UNCERTAIN_HAMMING:
       MarkerPatternHelper.hammingDeforce = bool;
       break;
     case ONLY_HOMOGRAPHY:
       this.RUN_RENDERER = !bool;
       this.ONLY_HOMOGRAPHY = bool;
       break;
     case RUN_OPENCV:
       this.RUN_OPENCV = bool;
       break;
     case RUN_RENDERER:
       this.RUN_RENDERER = bool;
       break;
     case DEBUG_FRAME_LOGGING:
       MainInterface.DEBUG_FRAME_LOGGING = bool;
       break;
     case DEBUG_LOGGING:
       MainInterface.DEBUG_LOGGING = bool;
       break;
     case DEBUG_FRAME:
       this.DEBUG_FRAME = bool;
       break;
     case USE_CANNY:
       Detector.USE_CANNY = bool;
       break;
     case USE_ADAPTIVE:
       Detector.USE_ADAPTIVE = bool;
       break;
     case DEBUG_PREP_FRAME:
       Detector.DEBUG_PREP_FRAME = bool;
       break;
     case DEBUG_CONTOURS:
       Detector.DEBUG_CONTOURS = bool;
       break;
     case DEBUG_POLY:
       Detector.DEBUG_POLY = bool;
       break;
     case DEBUG_DRAW_MARKERS:
       Detector.DEBUG_DRAW_MARKERS = bool;
       break;
     case DEBUG_DRAW_SAMPLING:
       Detector.DEBUG_DRAW_SAMPLING = bool;
       break;
     case DEBUG_DRAW_MARKER_ID:
       Detector.DEBUG_DRAW_MARKER_ID = bool;
       break;
     default:
       log.log(TAG, "Failed to set flag " + value + "!");
       break;
   }
 }
 public MainInterface(Activity mainActivity, float[][] camMatrix, float[] distortionCoefficients) {
   this.log = Messenger.getInstance();
   log.log(TAG, "Constructing framework.");
   this.mainActivity = mainActivity;
   this.listeners = new ArrayList<HomographyListener>();
   this.allTrackables = new ArrayList<Entity>();
   this.detectedTrackables = new ArrayList<Trackable>();
   // Set camera matrix:
   this.camMatrix = camMatrix;
   this.distCoef = distortionCoefficients;
 }
 public void onDestroy() {
   if (RUN_OPENCV) opencv.onDestroy();
   log.log(TAG, "Stopping.");
 }