MeiCam SDK For Android  3.10.0
Virtual live broadcast

When users are shooting a video, the virtual live broadcast function is realized by image matting and later applying the virtual scene package (.capturescene) of Meishe SDk to the video.
The specific steps are as follows:

  1. Initialize the StreamingContext. There are two ways to create a NvsStreamingContext singleton object. Here we choose to create singleton object without the flags.

    m_streamingContext = NvsStreamingContext.init(this, null);

  2. Set the callback and connects the capture preview output to the NvsLiveWindow control.

    //Sets the callback interface to the streaming context. m_streamingContext.setCaptureDeviceCallback(this); m_streamingContext.getAssetPackageManager().setCallbackInterface(this);

    //Connects capture preview output to the NvsLiveWindow control. m_streamingContext.connectCapturePreviewWithLiveWindow(m_liveWindow);

  3. Add image matting capture Fx.

    NvsCaptureVideoFx keyerFx = m_streamingContext.appendBuiltinCaptureVideoFx("Master Keyer"); if(keyerFx != null) { //Opens the overflow color removal. keyerFx.setBooleanVal("Spill Removal",true); //Set the intensity of the overflow removal to the lowest. keyerFx.setFloatVal("Spill Removal Intensity",0); //Set the boundary shrinking strength. keyerFx.setFloatVal("Shrink Intensity",0.4); }

  4. Start the capture preview.

    //Color pick is needed on the captured video. So Users need to use STREAMING_ENGINE_CAPTURE_FLAG_GRAB_CAPTURED_VIDEO_FRAME flag. m_streamingContext.startCapturePreview(0, NvsStreamingContext.VIDEO_CAPTURE_RESOLUTION_GRADE_HIGH, NvsStreamingContext.STREAMING_ENGINE_CAPTURE_FLAG_GRAB_CAPTURED_VIDEO_FRAME, null);

  5. Click to pick color and pass the extracted background image color value to the key effect.

    NvsColor sampledColor = m_streamingContext.sampleColorFromCapturedVideoFrame(sampleRect); //Passes the extracted background image color value to the key effect. NvsCaptureVideoFx keyerFx = m_streamingContext.getCaptureVideoFxByIndex(0); if(keyerFx) { keyerFx.setColorVal("Key Color",sampledColor); }

  6. Use the virtual scene package, and the virtual live scene will appear.

    m_streamingContext.applyCaptureScene(sceneId);