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

Camera2 / CameraX API #32

Closed
andreasb242 opened this issue Apr 1, 2024 · 16 comments
Closed

Camera2 / CameraX API #32

andreasb242 opened this issue Apr 1, 2024 · 16 comments

Comments

@andreasb242
Copy link
Contributor

This #22 would need Camera2 API.
This #23 also.
Probably this #10 also.

I think this should be done. It can be done, without increasing the API Level, which is important for me, because I plan to use old Phones!

I'll probably have a look at it.

@andreasb242
Copy link
Contributor Author

We need to use Camera2 for sure, even if it's more complicated than CameraX.
I did some research, I looked at the code and I looked at the new interface.

I think it's not possible to do a refactoring with the existing code, there are to many changes which are not compatible.

I currently think the solution would be to refactor the main screen, and to allow to select between the current Interface and the new Interface.
The new Interface needs a new implementation, which also can support new features, but at the beginning just supports the very basic stuff. So both interfaces can be supported over a longer time, without breaking the existing code.

@woheller69 what are your thoughts about it?
As I read your comments in the other Issues, you also think you cannot migrate to Camera2, right?

@woheller69
Copy link
Owner

I think that is a good idea. Simply migrating will probably break a lot of things. And I currently have no time for such a major rewrite.

If someone is willing to invest time and we can do it step by step without breaking existing code I am fine with this.
So I also think an option to switch between old an new camera API would be a good way to go ahead.

@andreasb242
Copy link
Contributor Author

Thanks! I work on this, as I still have an issue with crashing camera.
But I could not check another Vendor than Xiaomi / MIUI yet.

@andreasb242
Copy link
Contributor Author

This is my current progress. It's not finished yet, but it's all compiling and nothing fully broken ;-)
On the start, there is only one button per category and a short summary, how it's configured (yes, the first is missin, not finished).
if you click on the summary, the assigned settings are opened.

But the important part: If you switch the recording mode, the settings can be replaced, so the second view will be recoding dependent.
So it's possible to open different settings for the current implementation and for Camera2, where a lot is different, and at the beginning a lot will be missing, it's just not possible to implement everything at once.

Screenshot_20240416-203937_TimeLapseCam

@woheller69 what do you think about this?

@woheller69
Copy link
Owner

For the planning section (duration, star time, etc) there should also be a group.
And where do we switch between old camera api and new api?

I would prefer to do it this way:
Simply keep the old stuff completely as it is and only add a checkbox in the menu at the top above "about" saying
"Use camera2 API (experimental)". If checked we switch to the new settings implementation.

@woheller69
Copy link
Owner

And some day (in distant future) when everything works fine we might simple delete all the old code and only use the new API

@woheller69
Copy link
Owner

with "switch to the new settings implementation" I mean a new separate settingsFragment2, etc.

@andreasb242
Copy link
Contributor Author

And where do we switch between old camera api and new api?

The settings should be dependent on the recording mode.
There would be a new recoding mode, I didn't define a name yet.

If you click to "Kamera Einstellungen" (Sorry, phone is set to German) you get the old settings without Stop settings, which are implemented different, and therefore could be easy split, REST API, which are new, and could be easy split.

And some day (in distant future) when everything works fine we might simple delete all the old code and only use the new API

Yes, but you know how long that this usually takes, because for this you need all features in the new implementation.

with "switch to the new settings implementation" I mean a new separate settingsFragment2, etc.

Already done:
https://github.com/andreasb242/TimeLapseCamera/tree/camera2-activity-config

But this is not enough, because some startup code is also there, and this needs to moved.
This branch is my current work-in-progress state.

@andreasb242
Copy link
Contributor Author

For the planning section (duration, star time, etc) there should also be a group.

I thought about this, but didn't do it yet.

@woheller69
Copy link
Owner

I just compiled it. I have no issues to have the settings grouped. I think that is fine if also a planning section is added.

Why do we need a new recording mode? There will still be jpg, mp4, time lapse mp4, right (maybe not all of them immediately).
My idea would be to have this checkbox in the 3dots menu:

☒ use new Camera2 API (experimental)

and if this is checked the available (implemented) new recording modes and settings are shown.
If the user unchecks this box, he gets back to the old recording modes and settings.

@andreasb242
Copy link
Contributor Author

I could get a preview working with Camera 2, but it's just a sample, I need to implemented the whole configuration and at least a few new features (Focus, Camera Selection etc.) else it makes no sense to integrate it...

I'm working on this

@andreasb242
Copy link
Contributor Author

I got today the first images with Camera 2 :-)

There is still a lot to do, the most configuration is still missing. But I'm working on it.

@andreasb242
Copy link
Contributor Author

image

The Camera Preview is basically working.You can now here configure ISO and Exposure Time.
After pressing OK the values are applied to the preview. The Settings which are configured manually are highlighted in red.
Autofocus on touch is working, but it's not stored yet, and not used for the timelapse. My next Task.

So to do for now:
Focus configuration (by touching the preview)

  • Automatic
  • Focus once in the Preview, keep the focus distance
  • Focus once in the Preview, store the focus point and re-focus on this point (growing plants etc. which are ate the same place, but gets bigger and bigger)

Camera Selection: Front / Back and, if available, select the available Lens (Macro, Wide angle).

Focus will not be available in the Settings, because you cannot set it without preview.
I'm currently thinking about to configure the camera just in the Preview (Focus, ISO, Exposure, Camera / Camera Lens)

@woheller69 what do you think about?

It's still in development, but if you like to test it, the screenshot is from camera2-mode branch on my Repo.

@woheller69
Copy link
Owner

Configuring camera in preview sounds good.
For any application a preview will be needed anyway.

@andreasb242
Copy link
Contributor Author

This will be solved with #39

@andreasb242
Copy link
Contributor Author

Merged into beta branch

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