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

Switch mode without restart #806

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

Namazed
Copy link
Contributor

@Namazed Namazed commented Mar 23, 2020

Solution

I trying use all actions, which depend on Mode (photo/video), without restart camera (preview, engine), but only for Engine.Camera1. I added flag for this small improve.

@natario1 Maybe you know, which bad effects we will get with this solution.

@natario1
Copy link
Owner

natario1 commented Mar 25, 2020

What happens if you basically remove all that you have done and simply change CameraBaseEngine.setMode() line 393? Instead of calling restart(), call restartBind().
And instead of CameraState.ENGINE, use CameraState.BIND in the previous line.

I think you would achieve the same benefit and it would work for both Camera1 and Camera2.

@natario1
Copy link
Owner

natario1 commented Mar 25, 2020

The issue with your solution is that the capture size is recomputed, but the preview size is not recomputed. But the preview size depends on the capture size... (we want a preview size the same aspect ratio). Maybe there are more issues but this is the one that I can see right now.

@Namazed
Copy link
Contributor Author

Namazed commented Mar 25, 2020

The issue with your solution is that the capture size is recomputed, but the preview size is not recomputed. But the preview size depends on the capture size... (we want a preview size the same aspect ratio). Maybe there are more issues but this is the one that I can see right now.

Thanks for your answers, but now in the library we always use previewSize only for Picture, in both mode. Why I need stop and start preview if my preview didn't change after switch mode?
The method restartBind() do stop/start preview and this is problem, because I see artefacts on preview when switch mode.

@natario1
Copy link
Owner

For example because someone might call:

camera.setPictureSize(SizeSelectors.aspectRatio(16/9));
camera.setVideoSize(SizeSelectors.aspectRatio(4/3));

and we want the preview to be 16:9 in the first case and 4:3 in the second case. But in your solution the preview size wouldn't change. I understand that it doesn't matter in your app but I think it matters for the library.

If you change restart() with restartBind() you should save some time in my opinion. setMode does not need the full restart indeed

@Namazed
Copy link
Contributor Author

Namazed commented Mar 25, 2020

For example because someone might call:

camera.setPictureSize(SizeSelectors.aspectRatio(16/9));
camera.setVideoSize(SizeSelectors.aspectRatio(4/3));

and we want the preview to be 16:9 in the first case and 4:3 in the second case. But in your solution the preview size wouldn't change. I understand that it doesn't matter in your app but I think it matters for the library.

If you change restart() with restartBind() you should save some time in my opinion. setMode does not need the full restart indeed

Yes, I understood you. I think we need more smarter logic in this place. We need look at preview size (ratio) on picture mode and video mode, and if they equal we can switch mode without restart preview and camera. What you think about this idea?

I didn't want use restartBind() because this method call stop and start preview after this I see how preview freezes, but this don't need if preview ratio for both mode equal

@Namazed
Copy link
Contributor Author

Namazed commented Mar 26, 2020

For example because someone might call:

camera.setPictureSize(SizeSelectors.aspectRatio(16/9));
camera.setVideoSize(SizeSelectors.aspectRatio(4/3));

and we want the preview to be 16:9 in the first case and 4:3 in the second case. But in your solution the preview size wouldn't change. I understand that it doesn't matter in your app but I think it matters for the library.

If you change restart() with restartBind() you should save some time in my opinion. setMode does not need the full restart indeed

Hi, @natario1.
I added logic, which check ratio and if ratio different we call restartBind(), but only for Camera1, because when I configured both mode video and photo for Camera2, it threw exception .

@Namazed
Copy link
Contributor Author

Namazed commented Apr 7, 2020

Hi @natario1,
What you think about it?

@Namazed
Copy link
Contributor Author

Namazed commented Aug 17, 2020

Hi @natario1,
I mentioned you again. What you think about this solution?
If you don't want take it in your lib, I will close this PR and stay on my fork.

@isamotiuc
Copy link

Will be cool to have it, especially if you have UI for capturing video/picture like a messenger application. When you have a long tap on a button for recording video and click for the same button for taking pictures.

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

Successfully merging this pull request may close these issues.

Disable restart camera after change mode (photo/video)
3 participants