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

react-native-vision-camera #1474

Closed
ciaoamigoschat opened this issue Nov 9, 2023 · 11 comments
Closed

react-native-vision-camera #1474

ciaoamigoschat opened this issue Nov 9, 2023 · 11 comments

Comments

@ciaoamigoschat
Copy link

Hello, I wanted to ask if your project supports react-native-vision-camera or if there's anyone who can guide me on how to configure it with react-native-webrtc.

@saghul
Copy link
Member

saghul commented Nov 9, 2023

You cannot use them together. WebRTC opens the camera directly.

@ciaoamigoschat
Copy link
Author

I don't want to use them together, I want to use react-native-vision-camera instead of the default one.

@saghul
Copy link
Member

saghul commented Nov 10, 2023

So you do want to use them together then, You cannot use vision camera as a source for WebRTC because it opens the camera directly.

@ciaoamigoschat
Copy link
Author

I found this information on the react-native-vision-camera docs: https://react-native-vision-camera.com/docs/guides/frame-processors-plugins-overview#long-running-frame-processors. It says that if your Frame Processor takes longer than a single frame interval to execute, or runs asynchronously, you can create a copy of the frame and dispatch the actual frame processing to a separate thread.

I understand that this is done to avoid blocking the main thread, which could cause the video feed to stutter. However, my WebRTC application does not need to process the frames in real time. I can simply send the frames to the server without any processing.

Therefore, I can use the vision camera to capture frames and then send them to the server using WebRTC. I will not be using the vision camera and WebRTC together, but rather sequentially.

In other words, you are using the vision camera to capture frames and then sending those frames to the server using WebRTC. You are not using the vision camera to process the frames in real time. This is perfectly acceptable, and there is no need to create a copy of the frame or dispatch the frame processing to a separate thread.

@8BallBomBom
Copy link
Member

8BallBomBom commented Nov 10, 2023

With alterations you could indeed have it where this module feeds frames over to the other module or vice versa but that would require a lot of compatibility work on both ends 🤔

Very much considered out of scope for this project.

@saghul
Copy link
Member

saghul commented Nov 10, 2023

I found this information on the react-native-vision-camera docs: https://react-native-vision-camera.com/docs/guides/frame-processors-plugins-overview#long-running-frame-processors. It says that if your Frame Processor takes longer than a single frame interval to execute, or runs asynchronously, you can create a copy of the frame and dispatch the actual frame processing to a separate thread.

I understand that this is done to avoid blocking the main thread, which could cause the video feed to stutter. However, my WebRTC application does not need to process the frames in real time. I can simply send the frames to the server without any processing.

Therefore, I can use the vision camera to capture frames and then send them to the server using WebRTC. I will not be using the vision camera and WebRTC together, but rather sequentially.

In other words, you are using the vision camera to capture frames and then sending those frames to the server using WebRTC. You are not using the vision camera to process the frames in real time. This is perfectly acceptable, and there is no need to create a copy of the frame or dispatch the frame processing to a separate thread.

There is no way for you to inject those frames into the WebRTC pipeline. You could send them over a datachannel I guess, but that will likely generate bad results since it's notvery performant, binary data needs to be base64 encoded.

@ciaoamigoschat
Copy link
Author

Thank you for the responses. Let me explain what I need to do; perhaps there is another solution. I need to capture the image from the local camera every 60 seconds while in a video call. How can I achieve this using only WebRTC

@8BallBomBom
Copy link
Member

You could use frame processors but it will require some native programming.
We do have Android support and there is a pr which needs pushing through to enable support for iOS over here.

@mskalra
Copy link

mskalra commented Dec 8, 2023

Hey @ciaoamigoschat I could be wrong, but I dont think you can achieve this with the existing WebRTC RN module on the device without making changes to native code.

You can do it pretty easily on the server side using that module, process the image there and then send it back to the client (assuming what you're building is not client to client).

Alternatively if you want to use react-native-vision-camera you can use frame processors to get the frame like @8BallBomBom suggested. But again you'll have to write native code to get the actual frame contents (https://github.com/yasintorun/vision-camera-base64 needs updating and is incompatible with v3 of vision-camera) and you'll also have to write your own native WebRTC component to send the video stream to your client/server.

TLDR: consider https://github.com/react-native-webrtc/react-native-webrtc and to process frames every 60 seconds on the receiving side.

@ciaoamigoschat
Copy link
Author

Thanks for your consideration, but I'm interested in capturing the image on the transmitting side.

@saghul
Copy link
Member

saghul commented Dec 10, 2023

It is not possible with this plugin.

@saghul saghul closed this as not planned Won't fix, can't repro, duplicate, stale Dec 10, 2023
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

4 participants