Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Virtual background for image is not working #829

Open
risingmax123456 opened this issue Oct 18, 2024 · 6 comments
Open

Virtual background for image is not working #829

risingmax123456 opened this issue Oct 18, 2024 · 6 comments

Comments

@risingmax123456
Copy link

risingmax123456 commented Oct 18, 2024

Describe the bug
Virtual background for image is not working receiving error -2 in console

To Reproduce
Steps to reproduce the behavior:
implement agora with group video call and set a image virtual background

Expected behavior
Virtual background should work

Code using

agoraEngine?.enableExtension(
     'agora_video_filters_segmentation',
    'portrait_segmentation',
    true,
 );

let backgroundSourceType = BackgroundSourceType.BackgroundImg;
let source = 'https://jamme3na.blob.core.windows.net/jamme3na/001A00AD-630C-44FB-8054-6826F02C1564.jpg';
const result = agoraEngine?.enableVirtualBackground(
true,
{
background_source_type: backgroundSourceType,
source: source,
},
{},
);
if (result !== 0) {
console.error('Failed to set virtual background. Error code:', result);
}

please help

@risingmax123456
Copy link
Author

follow same documentation still facing issue

@guoxianzhe
Copy link
Contributor

@risingmax123456 You should use local absolute path of the custom background image.

@risingmax123456
Copy link
Author

i am using this to get absolute path still having issue

export async function getAbsolutePath(filePath) {
if (Platform.OS === 'android') {
if (filePath.startsWith('/assets/')) {
const fileName = filePath.replace('/assets/', '');
const destPath = ${ExternalCachesDirectoryPath}/${fileName};
if (!(await exists(destPath))) {
await copyFileAssets(fileName, destPath);
}
return destPath;
}
}
return filePath;
}

@risingmax123456
Copy link
Author

Any update ?

@guoxianzhe
Copy link
Contributor

@risingmax123456 Can you try to install the demo in your phone? It works fine to me. You can refer to the image configuration and code of the demo in https://github.com/AgoraIO-Extensions/react-native-agora/blob/main/example/src/examples/advanced/VirtualBackground/VirtualBackground.tsx#L132

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants