Closed kuldip241995 closed 1 month ago
Hey, which device do you use?
Hey, which device do you use?
Hello, iPhone 15 and iOS 17.0
And just to make sure, is it a simulator or a real device?
And just to make sure, is it a simulator or a real device?
As of now, I'm using the simulator, I have downloaded your GitHub repo project and setup using npm install && pod install then start the npm server and run the example project and pick any image from image picker and getting error
I think there was a problem on iOS with simulators, I have to check it again and update the README (and possibly the code to emit a warning). Is it possible for you to try it with a real device?
I think there was a problem on iOS with simulators, I have to check it again and update the README (and possibly the code to emit a warning). Is it possible for you to try it with a real device?
Let me check in the real device as well and get back to you, thank you
@atlj I have tried with a real device then removing the background is working fine, so what needs to be done if wanted to run in the simulator as well??
I was researching this back then and it turned out the selfie segmentation API (the one I use to remove background) doesn't work on the Simulator. One workaround we can implement is to return the original image when people call this library and warn them. One other option is to implement MLKit for iOS but honestly, it has worse results than selfie segmentation.
So in summary, this is an OS restriction, not a library code one.
I was researching this back then and it turned out the selfie segmentation API (the one I use to remove background) doesn't work on the Simulator. One workaround we can implement is to return the original image when people call this library and warn them. One other option is to implement MLKit for iOS but honestly, it has worse results than selfie segmentation.
So in summary, this is an OS restriction, not a library code one.
Will continue with the real device, meanwhile, if you find any solution then please commit your code.
Thank you so much for your response
Sure stuff! And I will close this issue once I update the README (and possibly add the warning)
Sure stuff! And I will close this issue once I update the README (and possibly add the warning)
Okay great
Hello @atlj, I Also checked with you to see if we can add functionality in this library if somebody passes backgroundColor props colour = 'red' then it will applied on the image URI red colour else remove the background of the image, something is possible?
Hey @kuldip241995 that's definitely possible to do on native side. And as an alternative you can use a Skia canvas or a regular React Native view to put a view at the back of the image. And then you can use Skia's own screenshotting functionality or react-native-view-shot to get the screenshot of that area. Downside is the view shotting mechanism is a bit flaky sometimes but this would give more flexibility so you could put any react native you want at the back of the image.
Hey @kuldip241995 that's definitely possible to do on native side. And as an alternative you can use a Skia canvas or a regular React Native view to put a view at the back of the image. And then you can use Skia's own screenshotting functionality or react-native-view-shot to get the screenshot of that area. Downside is the view shotting mechanism is a bit flaky sometimes but this would give more flexibility so you could put any react native you want at the back of the image.
Okay, Thank you so much for your suggestions, Appreciated!
f8af627 and 1aaf0bb adds a warning and documents this behavior.
When I have run your react-native-background-remover-main GitHub repo example and try to check whether it was working fine or not, so
async function removeSelectionBackground() { if (!imageURI) { return; }
}
in this function catch (error) is executed and does not get any output, kindly check and provide your solution