How to access camera in nativescript without opening camera activity?
I used following code but it is opening device camera application. And I am expecting it should take picture without opening camera, or add camera view in application itself like whatsapp web scan.
import cameraModule = require("camera");
import imageModule = require("ui/image");
cameraModule.takePicture().then(picture => {
console.log("Result is an image source instance");
var image = new imageModule.Image();
image.imageSource = picture;
});
The "camera" module of NativeScript is an abstraction for the OS specific camera module which is why it opens that native interface.
In order to open a custom "nested" camera view a custom implementation would be required. Here comes the power of NativeScript and more specifically its plugin extensibility. You can either write such plugin yourself or looks for an existing one. As the idea of "nested" camera UI is very specific and would probably rely on app specific styles I was not able to find such existing plugin. Here for example you can see how something like this would be implemented in native Android, the same is probably possible in iOS also.
Related
Is there any way we can open camera in a custom popup in xamarin.forms? Currently I am using Xam.Plugin.Media which will open camera in an entire screen. what I am trying to mimic is open the camera inside a circular frame to show inside Rg.Plugin.Popup . How can I achieve it? Does it require platform level implementation? Any help is appreciated
First, I find a feature-request - Cropping interface of Xam.Plugin.Media and the author refused it as it should be done in a different app since it is not available out of the box on all platforms.
You can have a try with Take Photo Overlay (iOS Only) function of this plugin to add a layer in iOS camera.
I also find a useful OverlaySample of Xamarin.forms which can add overlayer to camera in Xamarin.forms.
Refer: overlayview-in-xamarin-forms
how-capture-image-using-camera-circle
any idea how I can start a native UWP page from a Xamarin Forms page?
The reason why I'm asking:
I have a XF application that needs to start a UWP library after a click event.
This library provides a special ORC reader.
Therefore I created a dependency service to run the platform specific function.
What I need now, is to open that UWP page, that contains the "Camera stream" to show the user what he is currently scanning.
And this is where I am hanging at the moment.
In my class that is called from the dep. service, I
myPage mp = new myPage();
But how can I show the new page?
Frame fr = Window.Current.Content as Frame gives me the error, that this page cannot be converted from a XF Frame to a Window Frame.
Or is there generally another way to handle this? Some advice would be great.
This sounds like a custom renderer.
Create a new OcrView class in your shared project inherited from View.
Place it on your Xamarin Forms XAML page.
Handle the OCR component in the UWP renderer.
Have a look at the Implementing a View section on this custom renderer overview
I'm pretty new to Xamarin Forms and C# in general, and need som hints on the best way to create an app for iOS and Android. I want to use the Camera to take pictures / videos and later on send them with email or something else, since I want customized controls on the camera, I'm guessing the stock camera won't be an option? Which gets us to Renderers, which is the best approach to this? Preferably in a MVVM way. I just want the camera and a few customized buttons on it.
Do I make on renderer for the different buttons objects and one for the camera, the buttons I'll do as extensions of the Button class, but what about the camera?
/Oliver
You have two options:
Create a page renderer and put your camera/buttons native in each platform.
Create a view renderer for the camera and add your view in any page of Forms, so you can put your buttons or anything you like in forms.
I have an app where the user can create an account and take a picture of himself to use as an avatar. I'm obviously using Camera module for that. Now I would like to add an option for user to choose an existing picture from the device gallery, but I've been unable to find such functionality neither in build-in Camera module or any 3-rd party plugin. I'm looking something similar to Cordova camera plugin: https://github.com/apache/cordova-plugin-camera, where one can specify PictureSourceType and on getPicture the app will show the gallery and the user can choose a picture from there, then callback will return base64-encoded string or URI for the image file. Thanks ahead for any insights!
Yes use this plugin https://github.com/NativeScript/nativescript-imagepicker
To select from the device.
I'm trying to draw new elements/images via the new skiasharp library for xamarin forms.
I got the samples working but they only change the full content page with the new canvas.
So my question would be how to implement a single view which can be placed in any place in another content page. Does anyone have experiences with skia?
How do I choose the canvas? Do I have to overwrite an existing Image or similar?
Thanks for you help.
Sure, and there is a view which you are looking for: SkiaView.
It inherited from Xamarin.Forms.View and contains some properties such as HeightRequest or Scale.
I suppose you are interested in these classes:
SkiaView
ISkiaViewController
iOS - SkiaViewRenderer
iOS - NativeSkiaView
Android - SkiaViewRenderer
Android - NativeSkiaView
EDIT:
Finally there is a NuGet package with Xamarin.Forms support: SkiaSharp.Views.Forms 1.54.1-beta1. Samples are available in SkiaSharp repository.