MeiCam SDK For Android
2.10.2
|
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:
m_streamingContext = NvsStreamingContext.init(this, null);
//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);
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); }
//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);
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); }
m_streamingContext.applyCaptureScene(sceneId);