public void setPreview(Camera camera) throws IOException { if(surfaceHolder != null) { camera.setPreviewDisplay(surfaceHolder); } else { camera.setPreviewTexture(surfaceTexture); } } }
public void setSurfaceTexture(SurfaceTexture texture) { mTexture = texture; if(mState == State.PREVIEW && mCameraDevice != null && mTexture != null) { try { mCameraDevice.setPreviewTexture(mTexture); } catch (IOException e) { releaseCamera(); } } }
mCamera.setPreviewTexture(surface); } catch (IOException t) {}
public synchronized void startPreview() { if(mState != State.OPENED) { return; } if(mCameraDevice == null) { return; } if(mTexture == null) { return; } try { mCameraDevice.setPreviewTexture(mTexture); mCameraDevice.startPreview(); mState = State.PREVIEW; } catch (Exception e) { releaseCamera(); e.printStackTrace(); } }
@SuppressLint("NewApi") void setUpPreview() { try { if (mPreview.getOutputClass() == SurfaceHolder.class) { final boolean needsToStopPreview = mShowingPreview && Build.VERSION.SDK_INT < 14; if (needsToStopPreview) { mCamera.stopPreview(); } mCamera.setPreviewDisplay(mPreview.getSurfaceHolder()); if (needsToStopPreview) { mCamera.startPreview(); } } else { mCamera.setPreviewTexture((SurfaceTexture) mPreview.getSurfaceTexture()); } } catch (IOException e) { throw new RuntimeException(e); } }
@Override public void run() { int[] textures = new int[1]; GLES20.glGenTextures(1, textures, 0); surfaceTexture = new SurfaceTexture(textures[0]); try { camera.setPreviewTexture(surfaceTexture); camera.setPreviewCallback(GPUImageRenderer.this); camera.startPreview(); } catch (IOException e) { e.printStackTrace(); } } });
@SuppressLint("NewApi") void setUpPreview() { try { if (mPreview.getOutputClass() == SurfaceHolder.class) { final boolean needsToStopPreview = mShowingPreview && Build.VERSION.SDK_INT < 14; if (needsToStopPreview) { mCamera.stopPreview(); } mCamera.setPreviewDisplay(mPreview.getSurfaceHolder()); if (needsToStopPreview) { mCamera.startPreview(); } } else { mCamera.setPreviewTexture((SurfaceTexture) mPreview.getSurfaceTexture()); } } catch (IOException e) { throw new RuntimeException(e); } }
mCamera.setPreviewTexture(surface); } catch (IOException t) {
mCamera.setPreviewTexture(null);
camera.setPreviewTexture(null);
mCamera.setPreviewTexture(null);
/** * Opens the camera and starts sending preview frames to the underlying detector. The preview * frames are not displayed. * * @throws IOException if the camera's preview texture or display could not be initialized */ @RequiresPermission(Manifest.permission.CAMERA) public CameraSource start() throws IOException { synchronized (mCameraLock) { if (mCamera != null) { return this; } mCamera = createCamera(); // SurfaceTexture was introduced in Honeycomb (11), so if we are running and // old version of Android. fall back to use SurfaceView. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { mDummySurfaceTexture = new SurfaceTexture(DUMMY_TEXTURE_NAME); mCamera.setPreviewTexture(mDummySurfaceTexture); } else { mDummySurfaceView = new SurfaceView(mContext); mCamera.setPreviewDisplay(mDummySurfaceView.getHolder()); } mCamera.startPreview(); mProcessingThread = new Thread(mFrameProcessor); mFrameProcessor.setActive(true); mProcessingThread.start(); } return this; }
/** * Opens the camera and starts sending preview frames to the underlying detector. The preview * frames are not displayed. * * @throws IOException if the camera's preview texture or display could not be initialized */ @RequiresPermission(Manifest.permission.CAMERA) public CameraSource start() throws IOException { synchronized (cameraLock) { if (camera != null) { return this; } camera = createCamera(); // SurfaceTexture was introduced in Honeycomb (11), so if we are running and // old version of Android. fall back to use SurfaceView. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { dummySurfaceTexture = new SurfaceTexture(DUMMY_TEXTURE_NAME); camera.setPreviewTexture(dummySurfaceTexture); } else { dummySurfaceView = new SurfaceView(context); camera.setPreviewDisplay(dummySurfaceView.getHolder()); } camera.startPreview(); processingThread = new Thread(frameProcessor); frameProcessor.setActive(true); processingThread.start(); } return this; }
/** * Opens the camera and starts sending preview frames to the underlying detector. The preview * frames are not displayed. * * @throws IOException if the camera's preview texture or display could not be initialized */ @RequiresPermission(Manifest.permission.CAMERA) public CameraSource start() throws IOException { synchronized (mCameraLock) { if (mCamera != null) { return this; } mCamera = createCamera(); // SurfaceTexture was introduced in Honeycomb (11), so if we are running and // old version of Android. fall back to use SurfaceView. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { mDummySurfaceTexture = new SurfaceTexture(DUMMY_TEXTURE_NAME); mCamera.setPreviewTexture(mDummySurfaceTexture); } else { mDummySurfaceView = new SurfaceView(mContext); mCamera.setPreviewDisplay(mDummySurfaceView.getHolder()); } mCamera.startPreview(); mProcessingThread = new Thread(mFrameProcessor); mFrameProcessor.setActive(true); mProcessingThread.start(); } return this; }
protected void add() throws TextureException { int[] textures = new int[1]; GLES20.glGenTextures(1, textures, 0); int textureId = textures[0]; GLES20.glBindTexture(GL_TEXTURE_EXTERNAL_OES, textureId); GLES20.glTexParameterf(GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_NEAREST); GLES20.glTexParameterf(GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR); GLES20.glTexParameterf(GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE); GLES20.glTexParameterf(GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE); setTextureId(textureId); mSurfaceTexture = new SurfaceTexture(textureId); if (mMediaPlayer != null) { mSurface = new Surface(mSurfaceTexture); mMediaPlayer.setSurface(mSurface); } else if (mCamera != null) { try { mSurfaceTexture.setOnFrameAvailableListener(mOnFrameAvailableListener); mCamera.setPreviewTexture(mSurfaceTexture); } catch (IOException e) { throw new TextureException(e); } } else if (mSurfaceListener != null) { mSurfaceListener.setSurface(new Surface(mSurfaceTexture)); } }
public void setPreviewTexture(SurfaceTexture texture){ if(mCamera!=null){ try { mCamera.setPreviewTexture(texture); } catch (IOException e) { e.printStackTrace(); } } }
public void setPreviewTexture(SurfaceTexture texture){ if(mCamera!=null){ try { mCamera.setPreviewTexture(texture); } catch (IOException e) { e.printStackTrace(); } } }
camera.setPreviewTexture(cameraSurfaceTexture); camera.startPreview(); } catch (IOException ioe) {
@Override public void onSurfaceCreated(GL10 gl, EGLConfig config) { if (mCamera != null) { mCamera.stopPreview(); mCamera.release(); mCamera = null; } mCamera = Camera.open(cameraId); mController.setImageDirection(cameraId); Camera.Size size = mCamera.getParameters().getPreviewSize(); mController.setDataSize(size.height, size.width); try { mCamera.setPreviewTexture(mController.getTexture()); mController.getTexture().setOnFrameAvailableListener(new SurfaceTexture.OnFrameAvailableListener() { @Override public void onFrameAvailable(SurfaceTexture surfaceTexture) { mController.requestRender(); } }); } catch (IOException e) { e.printStackTrace(); } mCamera.startPreview(); }
@Override public void setPreview(SurfaceTexture surfaceTexture) { try { camera.setPreviewTexture(surfaceTexture); } catch (IOException e) { e.printStackTrace(); } }