Java Code Examples for org.opencv.android.CameraBridgeViewBase#setVisibility()

The following examples show how to use org.opencv.android.CameraBridgeViewBase#setVisibility() . 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: MainActivity.java    From OpenCV-Android-Object-Detection with MIT License 6 votes vote down vote up
/**
 * Called when the activity is first created.
 */
@Override
public void onCreate(Bundle savedInstanceState) {

    Log.i(TAG, "called onCreate");
    super.onCreate(savedInstanceState);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    setContentView(R.layout.layout);

    if(ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
        ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.CAMERA}, REQUEST_PERMISSION);
    }

    mOpenCvCameraView = (CameraBridgeViewBase) findViewById(R.id.tutorial1_activity_java_surface_view);
    mOpenCvCameraView.setVisibility(SurfaceView.VISIBLE);
    mOpenCvCameraView.setCvCameraViewListener(this);
    tvName = (TextView) findViewById(R.id.text1);

}
 
Example 2
Source File: GabrielClientActivity.java    From faceswap with Apache License 2.0 6 votes vote down vote up
private void init_once() {
		Log.d(DEBUG_TAG, "on init once");

		renderer = new CVRenderer(this);
		mOpenCvCameraView = (CameraBridgeViewBase) findViewById(R.id.cv_camera_view);
		mOpenCvCameraView.setVisibility(CameraBridgeViewBase.VISIBLE);
		mOpenCvCameraView.setCvCameraViewListener(renderer);

//		cameraOverlay = (CameraOverlay) findViewById(R.id.display_surface);
//		cameraOverlay.bringToFront();
//		mPreview = (CameraPreview) findViewById(R.id.camera_preview);
//		if (Const.DISPLAY_PREVIEW_ONLY) {
//			RelativeLayout.LayoutParams invisibleLayout = new RelativeLayout.LayoutParams(0, 0);
//			mDisplay.setLayoutParams(invisibleLayout);
//			mDisplay.setVisibility(View.INVISIBLE);
//			mDisplay.setZOrderMediaOverlay(false);
//		}
//		mPreview.setPreviewCallback(previewCallback);
//		cameraOverlay.setImageSize(mPreview.imageSize);

		Const.ROOT_DIR.mkdirs();
		Const.LATENCY_DIR.mkdirs();

		hasStarted = true;
	}
 
Example 3
Source File: CameraActivity.java    From Android-Car-duino with GNU General Public License v2.0 6 votes vote down vote up
@SuppressWarnings("deprecation")
@Override
protected void onCreate(Bundle savedInstanceState) {
    Log.i(TAG, "called onCreate");
    super.onCreate(savedInstanceState);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    setContentView(R.layout.camera_activity);
    mOpenCvCameraView = (CameraBridgeViewBase) findViewById(R.id.CameraView);
    //mOpenCvCameraView.setMaxFrameSize(240,135);
    mOpenCvCameraView.setVisibility(SurfaceView.VISIBLE);
    mOpenCvCameraView.setCvCameraViewListener(this);

    detector = new GestureDetector(this);

    debugConsole = (TextView) findViewById(R.id.debugConsole);

    if(blue.btEnabled) {
        try {
            bt.runBT();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
 
Example 4
Source File: MainActivity.java    From opencv-android-sample with MIT License 6 votes vote down vote up
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    Log.i(TAG, "called onCreate");
    super.onCreate(savedInstanceState);

    // Load ndk built module, as specified
    // in moduleName in build.gradle
    System.loadLibrary("native");

    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    setContentView(R.layout.activity_main);

    mOpenCvCameraView = (CameraBridgeViewBase) findViewById(R.id.camera_view);

    mOpenCvCameraView.setVisibility(SurfaceView.VISIBLE);

    mOpenCvCameraView.setCvCameraViewListener(this);
}
 
Example 5
Source File: MainActivity.java    From MOAAP with MIT License 5 votes vote down vote up
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    setContentView(R.layout.activity_main);

    if (ContextCompat.checkSelfPermission(MainActivity.this, Manifest.permission.CAMERA)
            != PackageManager.PERMISSION_GRANTED) {
        Log.i("permission", "request CAMERA");
        ActivityCompat.requestPermissions(MainActivity.this, new String[]{Manifest.permission.CAMERA}, REQUEST_CAMERA);
    }else {
        Log.i("permission", "CAMERA already granted");
        camera_granted = true;
    }
    if (ContextCompat.checkSelfPermission(MainActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE)
            != PackageManager.PERMISSION_GRANTED) {
        Log.i("permission", "request EXTERNAL_STROAGE");
        ActivityCompat.requestPermissions(MainActivity.this, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, REQUEST_EXTERNAL_STROAGE);
    }else {
        Log.i("permission", "EXTERNAL_STROAGE already granted");
        read_external_storage_granted = true;
    }

    OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_3_2_0, this, mLoaderCallback);

    mOpenCvCameraView = (CameraBridgeViewBase) findViewById(R.id.java_surface_view);
    mOpenCvCameraView.setVisibility(SurfaceView.VISIBLE);
    mOpenCvCameraView.setCvCameraViewListener(this);

    Log.d("OCR", "onCreate done");

}
 
Example 6
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 7
Source File: CameraCalibrationActivity.java    From OpenCV-AndroidSamples with MIT License 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    Log.i(TAG, "called onCreate");
    super.onCreate(savedInstanceState);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    setContentView(R.layout.activity_camera_calibration);

    mOpenCvCameraView = (CameraBridgeViewBase) findViewById(R.id.camera_calibration_java_surface_view);
    mOpenCvCameraView.setVisibility(SurfaceView.VISIBLE);
    mOpenCvCameraView.setCvCameraViewListener(this);
}
 
Example 8
Source File: Tutorial1Activity.java    From OpenCV-AndroidSamples with MIT License 5 votes vote down vote up
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    Log.i(TAG, "called onCreate");
    super.onCreate(savedInstanceState);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    setContentView(R.layout.activity_tutorial1);

    mOpenCvCameraView = (CameraBridgeViewBase) findViewById(R.id.tutorial1_activity_java_surface_view);

    mOpenCvCameraView.setVisibility(SurfaceView.VISIBLE);

    mOpenCvCameraView.setCvCameraViewListener(this);
}
 
Example 9
Source File: FDOpenCVPresenter.java    From Image-Detection-Samples with Apache License 2.0 4 votes vote down vote up
public void setCamera(CameraBridgeViewBase openCvCameraView) {
    openCvCameraView.setVisibility(SurfaceView.VISIBLE);
    openCvCameraView.setMaxFrameSize(MAX_WIDTH, MAX_HEIGHT);
    openCvCameraView.setCvCameraViewListener(this);
}