org.opencv.android.JavaCameraView Java Examples

The following examples show how to use org.opencv.android.JavaCameraView. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: OpenCvCamera.java    From opencv-documentscanner-android with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.cam);
    mOpenCvCameraView = (JavaCameraView) findViewById(R.id.tutorial1_activity_java_surface_view);
    mOpenCvCameraView.setVisibility(View.VISIBLE);

    mOpenCvCameraView.setCvCameraViewListener(this);
}
 
Example #2
Source File: MainActivity.java    From real_time_circle_detection_android with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    cameraView = (JavaCameraView) findViewById(R.id.cameraview);
    cameraView.setCvCameraViewListener(this);
    //cameraView.setMaxFrameSize(1280, 720);
}
 
Example #3
Source File: VisionEnabledActivity.java    From FTCVision with MIT License 5 votes vote down vote up
protected final void initializeVision(int framePreview, TestableVisionOpMode opMode) {
    openCVCamera = (CameraBridgeViewBase) findViewById(framePreview);
    openCVCamera.setVisibility(SurfaceView.VISIBLE);
    openCVCamera.setCvCameraViewListener(this);

    this.opMode = opMode;

    opMode.sensors = new Sensors();
    opMode.fps = new FPS();
    //FIXME this is the line that causes glitchiness
    TestableVisionOpMode.openCVCamera = (JavaCameraView) openCVCamera;
}
 
Example #4
Source File: Puzzle15Activity.java    From OpenCV-AndroidSamples with MIT License 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    Log.d(TAG, "Creating and setting view");
    mOpenCvCameraView = (CameraBridgeViewBase) new JavaCameraView(this, -1);
    setContentView(mOpenCvCameraView);
    mOpenCvCameraView.setCvCameraViewListener(this);
    mPuzzle15 = new Puzzle15Processor();
    mPuzzle15.prepareNewGame();
}
 
Example #5
Source File: AAVActivity.java    From AAV with GNU General Public License v2.0 5 votes vote down vote up
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	// requestWindowFeature(Window.FEATURE_NO_TITLE);
	getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

	setContentView(R.layout.main);

	PreferenceManager.setDefaultValues(this, R.xml.settings, false);
	_sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
	_trackingColor = Integer.parseInt(_sharedPreferences.getString(getString(R.string.color_key), "0"));

	if (_trackingColor == 0) {
		_lowerThreshold = new Scalar(60, 100, 30); // Green
		_upperThreshold = new Scalar(130, 255, 255);
	} else if (_trackingColor == 1) {
		_lowerThreshold = new Scalar(160, 50, 90); // Purple
		_upperThreshold = new Scalar(255, 255, 255);
	} else if (_trackingColor == 2) {
		_lowerThreshold = new Scalar(1, 50, 150); // Orange
		_upperThreshold = new Scalar(60, 255, 255);
	}
	_showContourEnable = _sharedPreferences.getBoolean("contour", false);

	_opencvCameraView = (JavaCameraView) findViewById(R.id.aav_activity_surface_view);
	_opencvCameraView.setCvCameraViewListener(this);

	_opencvCameraView.setMaxFrameSize(352, 288); // (176, 144); //(320, 240); <-Callback buffer is too small for these resolutions.
	_mainController = new ActuatorController();
	_countOutOfFrame = 0;

	_gestureDetector = new GestureDetector(this, new GestureDetector.SimpleOnGestureListener() {
		@Override
		public void onLongPress(MotionEvent e) {
			startActivityForResult(new Intent(getApplicationContext(), SettingsActivity.class), 0);
		}
	});
}
 
Example #6
Source File: AuthenticationActivity.java    From ml-authentication with Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_authentication);

    //Usage of this flag was inactivated in AuthenticationActivity and StudentImageCollectionActivity on 20170129
    /*isDeviceRooted = getIntent().getBooleanExtra(AuthenticationThread.IS_DEVICE_ROOTED_IDENTIFIER, false);

    if (isDeviceRooted){
        screenBrightnessMode = DetectionHelper.getScreenBrightnessMode(getApplicationContext());
        screenBrightness = DetectionHelper.getScreenBrightness(getApplicationContext());
        displayTemperatureNight = DetectionHelper.getDisplayTemperatureNight();
    }*/

    authenticationAnimation = (GifImageView) findViewById(R.id.authentication_animation);
    AuthenticationInstructionHelper.setAuthenticationInstructionAnimation(getApplicationContext(), authenticationAnimation);

    // Initialize DB Session
    LiteracyApplication literacyApplication = (LiteracyApplication) getApplicationContext();
    DaoSession daoSession = literacyApplication.getDaoSession();
    studentImageCollectionEventDao = daoSession.getStudentImageCollectionEventDao();
    authenticationEventDao = daoSession.getAuthenticationEventDao();

    if (!readyForAuthentication()){
        startStudentImageCollectionActivity(false);
    }

    preview = (JavaCameraView) findViewById(R.id.CameraView);

    // Use front-camera
    preview.setCameraIndex(1);

    preview.setVisibility(SurfaceView.VISIBLE);
    preview.setCvCameraViewListener(this);

    final TrainingThread trainingThread = new TrainingThread(getApplicationContext());

    tensorFlowLoadingThread = new Thread(new Runnable() {
        @Override
        public void run() {
            tensorFlow = trainingThread.getInitializedTensorFlow();
        }
    });

    recognitionThreadStarted = false;

    animalOverlayHelper = new AnimalOverlayHelper(getApplicationContext());

    activityStopped = false;
}
 
Example #7
Source File: AuthenticationActivity.java    From ml-authentication with Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_authentication);

    //Usage of this flag was inactivated in AuthenticationActivity and StudentImageCollectionActivity on 20170129
    /*isDeviceRooted = getIntent().getBooleanExtra(AuthenticationThread.IS_DEVICE_ROOTED_IDENTIFIER, false);

    if (isDeviceRooted){
        screenBrightnessMode = DetectionHelper.getScreenBrightnessMode(getApplicationContext());
        screenBrightness = DetectionHelper.getScreenBrightness(getApplicationContext());
        displayTemperatureNight = DetectionHelper.getDisplayTemperatureNight();
    }*/

    authenticationAnimation = (GifImageView) findViewById(R.id.authentication_animation);
    AuthenticationInstructionHelper.setAuthenticationInstructionAnimation(getApplicationContext(), authenticationAnimation);

    // Initialize DB Session
    LiteracyApplication literacyApplication = (LiteracyApplication) getApplicationContext();
    DaoSession daoSession = literacyApplication.getDaoSession();
    studentImageCollectionEventDao = daoSession.getStudentImageCollectionEventDao();
    authenticationEventDao = daoSession.getAuthenticationEventDao();

    if (!readyForAuthentication()){
        startStudentImageCollectionActivity(false);
    }

    preview = (JavaCameraView) findViewById(R.id.CameraView);

    // Use front-camera
    preview.setCameraIndex(1);

    preview.setVisibility(SurfaceView.VISIBLE);
    preview.setCvCameraViewListener(this);

    final TrainingThread trainingThread = new TrainingThread(getApplicationContext());

    tensorFlowLoadingThread = new Thread(new Runnable() {
        @Override
        public void run() {
            tensorFlow = trainingThread.getInitializedTensorFlow();
        }
    });

    recognitionThreadStarted = false;

    animalOverlayHelper = new AnimalOverlayHelper(getApplicationContext());

    activityStopped = false;
}
 
Example #8
Source File: StudentImageCollectionActivity.java    From ml-authentication with Apache License 2.0 2 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_authentication_student_image_collection);

    //Usage of this flag was inactivated in AuthenticationActivity and StudentImageCollectionActivity on 20170129
    /*isDeviceRooted = getIntent().getBooleanExtra(AuthenticationThread.IS_DEVICE_ROOTED_IDENTIFIER, false);

    if (isDeviceRooted){
        screenBrightnessMode = DetectionHelper.getScreenBrightnessMode(getApplicationContext());
        screenBrightness = DetectionHelper.getScreenBrightness(getApplicationContext());
        displayTemperatureNight = DetectionHelper.getDisplayTemperatureNight();
    }*/

    authenticationAnimation = (GifImageView) findViewById(R.id.authentication_animation);
    AuthenticationInstructionHelper.setAuthenticationInstructionAnimation(getApplicationContext(), authenticationAnimation);

    animalOverlayName = getIntent().getStringExtra(AuthenticationActivity.ANIMAL_OVERLAY_IDENTIFIER);

    preview = (JavaCameraView) findViewById(R.id.CameraView);

    preview.setCameraIndex(1);

    preview.setVisibility(SurfaceView.VISIBLE);
    preview.setCvCameraViewListener(this);

    lastTime = new Date().getTime();

    // Reset imageProcessed counter
    imagesProcessed = 0;

    // Initialize DB Session
    literacyApplication = (LiteracyApplication) getApplicationContext();
    DaoSession daoSession = literacyApplication.getDaoSession();
    studentImageCollectionEventDao = literacyApplication.getDaoSession().getStudentImageCollectionEventDao();

    // Create required DB Objects
    studentImageCollectionEventDao = daoSession.getStudentImageCollectionEventDao();
    studentImageDao = daoSession.getStudentImageDao();

    device = DeviceInfoHelper.getDevice(getApplicationContext());

    studentImages = new ArrayList<>();

    animalOverlayHelper = new AnimalOverlayHelper(getApplicationContext());

    activityStopped = false;

    authenticationAnimationAlreadyPlayed = getIntent().getBooleanExtra(AuthenticationActivity.AUTHENTICATION_ANIMATION_ALREADY_PLAYED_IDENTIFIER, false);
}
 
Example #9
Source File: StudentImageCollectionActivity.java    From ml-authentication with Apache License 2.0 2 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_authentication_student_image_collection);

    //Usage of this flag was inactivated in AuthenticationActivity and StudentImageCollectionActivity on 20170129
    /*isDeviceRooted = getIntent().getBooleanExtra(AuthenticationThread.IS_DEVICE_ROOTED_IDENTIFIER, false);

    if (isDeviceRooted){
        screenBrightnessMode = DetectionHelper.getScreenBrightnessMode(getApplicationContext());
        screenBrightness = DetectionHelper.getScreenBrightness(getApplicationContext());
        displayTemperatureNight = DetectionHelper.getDisplayTemperatureNight();
    }*/

    authenticationAnimation = (GifImageView) findViewById(R.id.authentication_animation);
    AuthenticationInstructionHelper.setAuthenticationInstructionAnimation(getApplicationContext(), authenticationAnimation);

    animalOverlayName = getIntent().getStringExtra(AuthenticationActivity.ANIMAL_OVERLAY_IDENTIFIER);

    preview = (JavaCameraView) findViewById(R.id.CameraView);

    preview.setCameraIndex(1);

    preview.setVisibility(SurfaceView.VISIBLE);
    preview.setCvCameraViewListener(this);

    lastTime = new Date().getTime();

    // Reset imageProcessed counter
    imagesProcessed = 0;

    // Initialize DB Session
    literacyApplication = (LiteracyApplication) getApplicationContext();
    DaoSession daoSession = literacyApplication.getDaoSession();
    studentImageCollectionEventDao = literacyApplication.getDaoSession().getStudentImageCollectionEventDao();

    // Create required DB Objects
    studentImageCollectionEventDao = daoSession.getStudentImageCollectionEventDao();
    studentImageDao = daoSession.getStudentImageDao();

    device = DeviceInfoHelper.getDevice(getApplicationContext());

    studentImages = new ArrayList<>();

    animalOverlayHelper = new AnimalOverlayHelper(getApplicationContext());

    activityStopped = false;

    authenticationAnimationAlreadyPlayed = getIntent().getBooleanExtra(AuthenticationActivity.AUTHENTICATION_ANIMATION_ALREADY_PLAYED_IDENTIFIER, false);
}