@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { Log.i(TAG, "onActivityResult called"); super.onActivityResult(requestCode, resultCode, data); mView.enableView(); mView.resumeCamera(); finish(); }
@Override protected void onResume() { super.onResume(); if (mView != null) { mView.enableView(); } class mRunnable implements Runnable { @Override public void run() { while (mView == null) { try { Thread.sleep(500); } catch (InterruptedException e) { e.printStackTrace(); } } while (mView.getVisibility() != View.VISIBLE) { try { Thread.sleep(500); } catch (InterruptedException e) { e.printStackTrace(); } } if (mView.getVisibility() == View.VISIBLE) { mView.setCvCameraViewListener(mView); if (mView.lFilters.size() == 0) { mView.appendFilter(new MatAdaptiveThresholding()); // black background, white letters mView.appendFilter(new MatBinarizationFilter()); // white background, black letters mView.appendFilter(new MatNegative()); // negative mView.appendFilter(new MatBlackYellowFilter()); // black background, yellow letters mView.appendFilter(new MatBlueYellowFilter()); // blue background, yellow letters mView.appendFilter( new MatBlueYellowInvertedFilter()); // yellow background, blue letters mView.appendFilter(new MatWhiteRedFilter()); // white background, red letters } Log.i(TAG, "filters: " + mView.lFilters.toString()); // Restore last filter, if available mView.restoreCurrentFilterSet(); // Re-enable view mView.enableView(); // mView.focusCamera(); // icSeeTutorial.initMediaPlayer(); mHandlerTutorial.postDelayed(mPlayTutorialReminder, 3000); } } } Thread tCheckForSurface = new Thread(new mRunnable()); tCheckForSurface.start(); }
@Override public void onPictureTaken(byte[] arg0, Camera arg1) { Bitmap bitmapPicture = BitmapFactory.decodeByteArray(arg0, 0, arg0.length); mView.saveCurrentFilterSet(); // Store filter for later reference // Get current running filter if (!mView.curFilterSubset().equals("")) { Mat imgMAT = new Mat(); Utils.bitmapToMat(bitmapPicture, imgMAT); // If the image is empty if (imgMAT.empty()) return; // Ignore // Apply filters mView.applyCurrentFilters(imgMAT); Utils.matToBitmap(imgMAT, bitmapPicture); } else { // Log.i(TAG, "no filter"); } startImageEdit(bitmapPicture); }
@Override public void onGesturePerformed(GestureOverlayView overlay, Gesture gesture) { ArrayList<Prediction> predictions = gestureLib.recognize(gesture); String sTheme; // Log.i(TAG, "predictions: "+predictions.toString()); TextView sliderText = (TextView) findViewById(R.id.verticalSeekbarText); for (Prediction prediction : predictions) { if (prediction.score > 1.0) { // Toast.makeText(this, prediction.name, Toast.LENGTH_SHORT) // .show(); if (prediction.name.contains("right")) { sTheme = mView.nextFilterSubset(); // Process frame to show results mView.process(1); if (sTheme != null) { movementCounter++; sliderText.setText("Next Theme: " + sTheme); /*Toast.makeText(ICSeeRealtimeActivity.this, "Next Theme: " + sTheme, Toast.LENGTH_SHORT).show();*/ mView.saveCurrentFilterSet(); // Store filter for later reference SoundPlayer.playSound(this.getApplicationContext(), SoundPlayer.S2); try { Thread.sleep(500); } catch (InterruptedException e) { e.printStackTrace(); } if (!movementTutorial) { if (icSeeTutorial.getTutorialState(mContext) == 1) { movementTutorial = true; } // icSeeTutorial.playSound(this.getApplicationContext(), 2); ICSeeTutorial.playChangedFilter(mContext); } else if (movementCounter == 4) { ICSeeTutorial.playAutoFocus(mContext); movementCounter = 0; } } else { mView.initFilterSubsets(); sliderText.setText("No theme applicable"); /*Toast.makeText(ICSeeRealtimeActivity.this, "No theme applicable", Toast.LENGTH_SHORT).show();*/ SoundPlayer.playSound(this.getApplicationContext(), SoundPlayer.S1); // icSeeTutorial.playSound(this.getApplicationContext(), 5); ICSeeTutorial.playNoFiltersLeft(mContext); } } else if (prediction.name.contains("left")) { sTheme = mView.previousFilterSubset(); // Process frame to show results mView.process(1); if (sTheme != null) { movementCounter++; sliderText.setText("Previous Theme: " + sTheme); /*Toast.makeText(ICSeeRealtimeActivity.this, "Previous Theme: " + sTheme, Toast.LENGTH_SHORT).show();*/ mView.saveCurrentFilterSet(); // Store filter for later reference SoundPlayer.playSound(this.getApplicationContext(), SoundPlayer.S3); try { Thread.sleep(500); } catch (InterruptedException e) { e.printStackTrace(); } if (!movementTutorial) { if (icSeeTutorial.getTutorialState(mContext) == 1) { movementTutorial = true; } // icSeeTutorial.playSound(this.getApplicationContext(), 2); ICSeeTutorial.playChangedFilter(mContext); } else if (movementCounter == 4) { ICSeeTutorial.playAutoFocus(mContext); movementCounter = 0; } } else { mView.initFilterSubsets(); sliderText.setText("No theme applicable"); /*Toast.makeText(ICSeeRealtimeActivity.this, "No theme applicable", Toast.LENGTH_SHORT).show();*/ SoundPlayer.playSound(this.getApplicationContext(), SoundPlayer.S1); // icSeeTutorial.playSound(this.getApplicationContext(), 5); ICSeeTutorial.playNoFiltersRight(mContext); } } else if (prediction.name.contains("omicron") || prediction.name.contains("omicron1") || prediction.name.contains("omicron2") || prediction.name.contains("omicron3") || prediction.name.contains("omicron4")) { // if tutorial state is off if (icSeeTutorial.getTutorialState(mContext) == 0) { icSeeTutorial.tutorialOn(); ICSeeTutorial.playTutorialOn(mContext); movementTutorial = false; icSeeTutorial.getTutorialState(mContext); } else { icSeeTutorial.tutorialOff(); icSeeTutorial.stopSound(); ICSeeTutorial.playTutorialOff(mContext); icSeeTutorial.getTutorialState(mContext); } } } } }
public void showFilters() { String sTheme = mView.curFilterSubset(); Toast.makeText(ICSeeRealtimeActivity.this, "Next Theme: " + sTheme, Toast.LENGTH_SHORT).show(); }
@Override protected void onStop() { // Log.i(TAG, "onStop"); super.onStop(); if (mView != null) mView.disableView(); }
@Override protected void onStart() { super.onStart(); mView = (RealtimeFilterView) findViewById(R.id.pbPreview); mView.setLongClickable(true); }