Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add getter for mCamera in JavaCameraView class#16759

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
StidOfficial wants to merge1 commit intoopencv:masterfromStidOfficial:master

Conversation

@StidOfficial
Copy link

Pull Request Readiness Checklist

See details athttps://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under OpenCV (BSD) License.
  • To the best of my knowledge, the proposed patch is not based on a code under GPL or other license that is incompatible with OpenCV
  • The PR is proposed to proper branch
  • There is reference to original bug report and related work
  • There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • The feature is well documented and sample code can be built with the project CMake

Example usage :

private JavaCameraView cameraView;...Camera.Parameters params = cameraView.getCamera().getParameters();params.setFlashMode(Camera.Parameters.FLASH_MODE_TORCH);cameraView.getCamera().setParameters(params);

@asmorkalov
Copy link
Contributor

Could you provide some reason why you want to expose camera object? The protect ed camera object guarantees that application has predictable lifecycle and camera settings are done in proper state. You can use inheritance and implement own class for specific behaviour, there is no need to modify original code.

@StidOfficial
Copy link
Author

StidOfficial commentedMar 8, 2020
edited
Loading

It's more complex to create a extends class :

public class JavaCameraViewAdvanced extends JavaCameraView {    public JavaCameraViewAdvanced(Context context, int cameraId) {        super(context, cameraId);    }    public JavaCameraViewAdvanced(Context context, AttributeSet attrs) {        super(context, attrs);    }    public void enableTorch() {        Camera.Parameters parameters = mCamera.getParameters();        parameters.setFlashMode(Camera.Parameters.FLASH_MODE_TORCH);        mCamera.setParameters(parameters);    }    public void disableTorch() {        Camera.Parameters parameters = mCamera.getParameters();        parameters.setFlashMode(Camera.Parameters.FLASH_MODE_OFF);        mCamera.setParameters(parameters);    }}

Replace JavaCameraView component in xml layout and use it in normal code juste for enable/disable flash torch.
Than add getter and use it in normal code.

@asmorkalov
Copy link
Contributor

Theoretically yes, but in practice even with flash you need to check flash mode availability (there is no flash for frontal camera), handle view events (turn it of, when camera view is closed), etc. So the amount of extra code lines for real use case is very small.

@asmorkalov
Copy link
Contributor

@alalek What do you think about the patch?

@asmorkalov
Copy link
Contributor

The solution was discussed with@alalek@VadimLevin@vpisarev and the team decided to reject the patch. There are several reasons for that:

  • It's not safe to expose camera for manipulations, because particular camera options should be sent during particular camera stages. User has to handle the events and inheritance is treated as better solution, see discussion above.
  • There areJavaCamera2View and it should be consistent.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@StidOfficial@asmorkalov

[8]ページ先頭

©2009-2025 Movatter.jp