Camera Using custom Camera Preview Renderer is not clear - xamarin.android

I am using the following link to display the camera preview using Custom renderers
https://developer.xamarin.com/guides/xamarin-forms/application-fundamentals/custom-renderer/view/
I was able to bring up the camera preview. But the preview is not at all clear. There is no Auto focus as well.
Screenshot for reference
How can I make the camera preview clearer, because I wish to use the same later on for OCR.
Thanks,

I think you already figured this out but I'm going to post the solution here for reference.
You need to setup the "Focus Mode" in the Camera properties.
Camera Preview = Camera.Open(1);
// Set the parameters.
if (Preview != null)
{
Camera.Parameters cameraParameters = Preview.GetParameters();
// Autofocus
cameraParameters.FocusMode = Camera.Parameters.FocusModeContinuousPicture;
// Set
cameraPreview.Preview.SetParameters(cameraParameters);
}
For the example you mentioned (the one in https://developer.xamarin.com/guides/xamarin-forms/application-fundamentals/custom-renderer/view/) you should place this code in you Android Cutom Renderer (CameraPreviewRenderer method OnElementChanged).
It worked for me. Hope this helps.

//Write logic inside the RunOnUiThread.
MainActivity.Instance.RunOnUiThread(() => { SetupUserInterface(); SetupEventHandlers(); AddView(view); cameraQuality = CameraQuality.High; });

Related

3D objects click event in ARCore

How to get click event of 3D object rendered using arcore SDK in android studio?
My requirement is to click that 3D object and show pop up dialog.
This has nothing to do with ARCore. The game engine / framework that you are using is actually responsible for that.
For example, if you are using Unity, you can use Raycasting.
RaycastHit hit;
Ray ray = yourARCamera.ScreenPointToRay(Input.GetTouch(0).position);
if (Physics.Raycast(ray, out hit))
{
// Check if what is hit is the desired object
if(hit.tag == "The_Tag_Of_The_Object_You_Are_Looking_For")
{
// User clicked the object.. Do something here..
}
}
Read more here:
https://unity3d.com/learn/tutorials/topics/physics/raycasting
https://docs.unity3d.com/ScriptReference/Physics.Raycast.html
ARCore is not supporting this feature. You need to do it by yourself. Most popular way is ray picking method. There is a lot of examples how to use it
In the case of Arcore - Sceneform SDK, after creating the anchor, you simple have to set a listener on your AnchorNode like so
anchorNode.setOnTapListener((hitResult,motionEvent)->{
//Your pop up
});

How to Apply Custom Filter to Camera & Photo View in Img.ly iOS SDK? XCode 8.1 Swift 3.0.1

XCode 8.1 Swift 3.0.1
I've been playing with img.ly iOS SDK for the last few days and I'm really excited about it, especially, the full blown customization that they've offered.
Unfortunately, I'm facing a few issues which I seem to can't get my head around it.
I wanted to limit the filter effects for the user to use only 5 of them. I can make it work by using this code:
However, when I select a filter effect, the image won't apply that effect to the Camera view, like the picture below:
I've tried to hook up the filterToolControllerBuilder to the CameraViewController like below:
And I called the filterSelectedClosure to get the identifier, and I can get it. as the filter is selected like the image below:
Questions are in the picture.
How to apply the filter identifier to the photo?
How to get the filter identifier when filter in Camera View is selected?
How to apply that selected filter identifier to the live Camera preview?
It seems like this is the first question related to Img.ly iOS SDK.
Please assist. Thanks.
I used to use this framework... let try to follow my code .
builder.configureAdjustToolController({ (options) in
options.allowedAdjustTools = [.brightness]
options.adjustToolButtonConfigurationClosure = { cell , action in
cell.imageView.image = cell.imageView.image?.withRenderingMode(.alwaysTemplate)
cell.imageView.tintColor = UIColor.white
}
})

Screenshot everything on display

I am trying to take a screenshot of absolutely everything that is displayed on the iPhone display, in the same way that pressing the home + power buttons together does. The code I currently have to screenshot is this:
func screenShotMethod() {
//hide UI
buttonTrigger.hidden = true
//take screenshot
let layer = UIApplication.sharedApplication().keyWindow!.layer
let scale = UIScreen.mainScreen().scale
UIGraphicsBeginImageContextWithOptions(view.frame.size, false, scale);
layer.renderInContext(UIGraphicsGetCurrentContext()!)
let screenshot = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
UIImageWriteToSavedPhotosAlbum(screenshot, nil, nil, nil)
//show UI
buttonTrigger.hidden = false
}
The point is that I am using the camera and putting a picture over any face it detects, and the easiest way to save that to the camera roll is just to hide the UI and screenshot the screen. With this method however, I get a screenshot of the face tracking picture, in the correct position and size, but not of what the camera sees underneath - just white. I am enabling the camera using the CameraEngine framework in the viewDidLoad() like this:
override func viewDidLoad() {
super.viewDidLoad()
self.cameraEngine.startSession()
Is there a better way to screenshot everything to behave like the hardware induced method? Or how could I include what the camera sees in the screenshot?
Thank you!
UPDATE: In case anyone in the future wants to know how I fixed this, because I can't screenshot things I'm not drawing myself, I solved this issue by taking a picture with the camera and setting that image as the background of the view, and then performing the screenshot function and it works!
Starting in iOS 9 it is no longer possible to take a screenshot that includes elements of the screen not drawn by your program. You can only capture your application's views and layers. Apple doesn't expose the function that is triggered by power+home to third party developers.

Disable PSPDFKit thumbnail

I'm trying to disable the thumbnail see image that comes with PSPDFKit, I'm not sure exactly what its called so I'm having a really hardtime finding it in the code. Anyone that has used this library before have any idea where this thumbnail is coming from, what its called, or has anything that might help! Thanks.
To Disable the ScrobbleBar(Thumbnail Preview) and Position Overlay(Page no:) of the PDF in PSPDFKit
you have to do the following
PSPDFViewController *pdfController = [[PSPDFViewController alloc] initWithDocument:yourMagazine];
pdfController.scrobbleBarEnabled = NO; // Disable the Bottom Scrobble Bar
pdfController.pageLabelEnabled = NO; // Disables the bottom document site position overlay.

How to remove the "Preview" view after I take a picture in UIImagePickerController?

I'm using UIImagePickerController to take pictures. It's quite simple. But I have a problem: There is always a "Preview" view to let me "Retake" or "Use". Which is not what I want. I want to save my pictures straight away inside my photo albums.
I've found some articles about this problem, here are some of them:
Link 1
Link 2
Basically they are using a OverlayView which can solve the problem. But there is new problem. I can't use volume up key to take pictures anymore after I use OverlayView. Are there another solution to disable the stupid "Preview" ?
Thanks
You could access the camera directly and not use UIImagePickerController at all.
Check out the following classes:
AVCaptureSession
AVCaptureDevice
AVCaptureDeviceInput
AVCaptureVideoDataOutput
With these classes you can display your own camera preview and save the image when button is pressed.
There is example here:
http://developer.apple.com/library/ios/#qa/qa1702/_index.html

Resources