Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

[F100] Camera View #1730

Closed
rmarinho opened this issue Jan 29, 2018 · 26 comments
Closed

[F100] Camera View #1730

rmarinho opened this issue Jan 29, 2018 · 26 comments
Labels
community-sprint F100 help wanted We welcome community contributions to any issue, but these might be a good place to start! in-progress This issue has an associated pull request that may resolve it! m/high impact ⬛ proposal-accepted roadmap t/enhancement ➕ up-for-grabs We welcome community contributions to any issue, but these might be a good place to start!

Comments

@rmarinho
Copy link
Member

rmarinho commented Jan 29, 2018

Rationale

Forms does not currently contain a cross platform view which allows to use and preview the camera of the device it's running on. There are some issues to be answer still, should we support control or just a preview of the image.

Implementation.

Users should be able to choose front or rear camera and visualize the image.
Users should be able to show default controls or not.
User should be able to capture a image and use it on Xamarin.Forms
This will probably require a VideoSource class similar to the ImageSource class, with the appropriate subclasses (FileVideoSource, StreamVideoSource, UriVideoSource and their respective type converters), as talked on #1692 to Support video.

public class CameraView : View
{
	public event EventHandler<MediaCapturedEventArgs> MediaCaptured;
	public event EventHandler<EventArgs> MediaCaptureFailed;

	public static readonly BindableProperty ShutterButtonCommandProperty = BindableProperty.Create(nameof(ShutterButtonCommand), typeof(ICommand), typeof(CameraView), null);
	public ICommand ShutterButtonCommand
	{
		get { return (ICommand)GetValue(ShutterButtonCommandProperty); }
		set { SetValue(ShutterButtonCommandProperty, value); }
	}

	public static readonly BindableProperty CameraOptionsProperty = BindableProperty.Create(nameof(CameraOptions), typeof(CameraOptions), typeof(CameraView), CameraOptions.Default);

	public CameraOptions CameraOptions
	{
		get { return (CameraOptions)GetValue(CameraOptionsProperty); }
		set { SetValue(CameraOptionsProperty, value); }
	}

	public static readonly BindableProperty ControlsOptionsProperty = BindableProperty.Create(nameof(ControlsOptions), typeof(CameraControlsOptions), typeof(CameraView), CameraControlsOptions.Default);

	public CameraControlsOptions ControlsOptions
	{
		get { return (CameraControlsOptions)GetValue(ControlsOptionsProperty); }
		set { SetValue(ControlsOptionsProperty, value); }
	}

	public static readonly BindableProperty CaptureOptionsProperty = BindableProperty.Create(nameof(CaptureOptions), typeof(CameraCaptureOptions), typeof(CameraView), CameraCaptureOptions.Default);

	public CameraCaptureOptions CaptureOptions
	{
		get { return (CameraCaptureOptions)GetValue(CaptureOptionsProperty); }
		set { SetValue(CaptureOptionsProperty, value); }
	}

}

public class MediaCapturedEventArgs : EventArgs
{
	public object Data { get; set; }
	public ImageSource Image { get; set; }
       	public VideoSource Image { get; set; }
}

public enum CameraOptions
{
	Default,
	Rear,
	Front
}

public enum CameraControlsOptions
{
	Default,
	Visible,
	Hidden
}

public enum CameraCaptureOptions
{
	Default,
	Photo,
	Video,
	PhotoAndVideo
}

Expected Result

Android

iOS

UWP

Implications for CSS

None

Backward Compatibility

None

Difficulty: Hard

@StephaneDelcroix
Copy link
Member

StephaneDelcroix commented Jan 31, 2018

that's a control you're trying to create. XF shouldn't do that. the reason is that we can not change its appearance once it's released, and it'll feel awkward in a version or 2 of iOS or Android.

@rmarinho rmarinho assigned rmarinho and unassigned rmarinho Feb 5, 2018
@andreinitescu
Copy link
Contributor

In my opinion, this control should not have any UI, but have just methods/events/properties for functionality. It should be similar to the idea of MediaElement (another ticket)

@samhouts samhouts added the help wanted We welcome community contributions to any issue, but these might be a good place to start! label Jun 14, 2018
@rmarinho
Copy link
Member Author

I have talked with @paymicro and he wanted to have a go at this, so its working on a branch for this feature.

https://github.com/paymicro/Xamarin.Forms/tree/fix-gh1730-camera

@rmarinho
Copy link
Member Author

Yeah let's make sure no UI for now; we just have methods and events to play the video and a View to renderer it

@samhouts samhouts added the up-for-grabs We welcome community contributions to any issue, but these might be a good place to start! label Oct 5, 2018
@dineshmahajan
Copy link

Hi is CameraView for now is stable enough to implement I wanted it to record video

@samhouts samhouts modified the milestones: 4.4.0, 4.5.0 Nov 20, 2019
@samhouts samhouts added proposal-open and removed help wanted We welcome community contributions to any issue, but these might be a good place to start! up-for-grabs We welcome community contributions to any issue, but these might be a good place to start! labels Feb 7, 2020
@samhouts samhouts removed this from the 4.5.0 milestone Feb 11, 2020
@Phenek
Copy link

Phenek commented Apr 23, 2020

Relative #7934

@davidbuckleyni
Copy link

Relative #7934

This is not relative this is merely a camera view with nothing to do with scanning two totally diff things

@Phenek
Copy link

Phenek commented May 5, 2020

Hello @davidbuckleyni,

Has you can see CameraView is already in progress.
When it will be done, we will be able to consume the live preview stream a in our code.
This would enable us to stream the data to barcode detectors, face recognizers, etc.
That why I put this relative here to highlight the fact that we need the live stream.

Did you get it? It will be this first pillar of your Barcode recognition!

Even more you should be able at first to use native bar code scanning with a custom renderer.
And return your result to Xamarin.Forms!

Regards,

@davidbuckleyni
Copy link

@samhouts does this mean the bar code stuff will be worked on since it got an approval flag.

@samhouts
Copy link
Member

samhouts commented May 8, 2020

@davidbuckleyni There is high interest in it, but we haven't yet committed to it. In the meantime, https://github.com/Redth/ZXing.Net.Mobile/ has a new prerelease with a lot of issues resolved!

@samhouts samhouts added inactive Issue is older than 6 months and needs to be retested help wanted We welcome community contributions to any issue, but these might be a good place to start! up-for-grabs We welcome community contributions to any issue, but these might be a good place to start! and removed inactive Issue is older than 6 months and needs to be retested labels Jun 5, 2020
@joehanna
Copy link

joehanna commented Sep 4, 2020

Will CameraView allow us to take multiple pictures before dismissing camera? Thanks!

@joehanna
Copy link

joehanna commented Sep 4, 2020

I just found the Community Toolkit Sample and it is exactly what I need - thanks to all the folks involved!

https://github.com/xamarin/XamarinCommunityToolkit

@Phenek
Copy link

Phenek commented Sep 14, 2020

Hope this will come one day on Xamarin or MAUI. 👾
Any plan for a nuget package, maybe?

@jfversluis
Copy link
Member

As is clear by now, this won't be making its way into Xamarin.Forms anymore. We have a control now in the Xamarin Community Toolkit, which will also be ported to the .NET MAUI Community Toolkit. I hope we can one day get this in .NET MAUI...

Thanks for the input here everyone!

@joehanna
Copy link

joehanna commented Nov 4, 2021

Thanks for letting us know @jfversluis. As I have mentioned to you directly in the past, I thank you for your hard work and dedication to the Xamarin community.

However, I cannot convey the extent of my disappointment with this decision. We trust Microsoft to give us what we need for mobile development as we jump in boots and all to support the c#/.net story, and I have done this since 2002.

Given apple’s clear focus on delivering a better camera system each year as the main driver for people to upgrade their iPhones, I am perplexed why Microsoft cannot find the means or desire to at least support the camera natively in its toolbox rather than passing it off as an unimportant addon into the Community Toolkit.

Unbelievable.

@jfversluis
Copy link
Member

Thank you Joe! Both for your kind words as well as your honest feedback.

I share your sentiment. I think this is an important control to have and that is also why I made it a priority to include it in the Toolkit for now. It's better than not having something at all, I guess.

A bit of background here: what is holding us back mostly is in fact not iOS, but Android. The Android APIs for accessing the camera have been in alpha and beta and just not in a great state for a long time. If we were to implement this as a first-class citizen we want to make sure that the biggest platforms, at the very least, work without any rough edges.

Now, note that I am talking about Xamarin.Forms here. I don't know how fast things can go for .NET MAUI. Our first priority is getting on par with Xamarin.Forms and implement all the new improvements we have in mind architecturally and from there look at implementing new functional features. Like yourself, I hope that will be sooner than later, but I just wanted to give you a bit of context that it's not as simple as us deciding that it's not important enough to include.

I'd be happy to discus a bit more with you through email or another medium about your thoughts on this. I would be curious why it's an obstacle to use the Toolkit other than it's another dependency to add.

Thanks!

@pecadora6996
Copy link

Hi

I need close the cameraview in the event button.

how can i implement it?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
community-sprint F100 help wanted We welcome community contributions to any issue, but these might be a good place to start! in-progress This issue has an associated pull request that may resolve it! m/high impact ⬛ proposal-accepted roadmap t/enhancement ➕ up-for-grabs We welcome community contributions to any issue, but these might be a good place to start!
Projects
None yet
Development

Successfully merging a pull request may close this issue.