Search code examples
androidcameratokbox

Tokbox video publish unfocused (Android)


I am using tokbox for video chat and I want to take pictures of printed documents. When I am trying this on a Samsung s7edge my captured image is so unfocused I cannot read it. When I am trying this on a Nexus 6p the image is fine.

It is not a resolution problem, I am always using CameraCaptureResolution.HIGH

any thoughts?


Solution

  • I fixed it:

    I used this class: https://github.com/opentok/opentok-android-sdk-samples/blob/master/Custom-Video-Driver/app/src/main/java/com/tokbox/android/tutorials/customvideodriver/CustomVideoCapturer.java

    Changed the init function:

    @Override
    public void init() {
        mCamera = Camera.open(mCameraIndex);
        mCurrentDeviceInfo = new Camera.CameraInfo();
        Camera.getCameraInfo(mCameraIndex, mCurrentDeviceInfo);
        try{
            //set camera to continually auto-focus
            Camera.Parameters params = mCamera.getParameters();
            params.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);
            mCamera.setParameters(params);
        }catch (Exception e) {
            e.printStackTrace();
        }
    }
    

    and the swapCamera as well, so every time the back camera comes into play It must have autofocus.

    And in my Activity, onConnected:

    CustomVideoCapturer  mCapturer = new CustomVideoCapturer(a) ;
    mPublisher = new Publisher.Builder(this)
        .capturer(mCapturer)
        .resolution(Publisher.CameraCaptureResolution.HIGH).build();