How to create a rectangle over camera preview - android-camera

I am working on face recognition project. I want to create a rectangle over camera preview so that a person can adjust his/her face in that box before taking an image. Is it possible with any method? I have searched but haven't got any help of rectangle, people have written text and have used images.

Related

Rectangular box to scan/analyze on the camera preview with Flutter Google-ml-kit Text Recognition

There's an example app using on-device Text Recognition of Google ML Kit: https://github.com/bharat-biradar/Google-Ml-Kit-plugin/tree/master/example
I'm using the "text recognition" part of that example app in my app and it works good. The only thing I need to do but can't do is that I want to show a rectangular box on the camera preview and only want to recognize texts inside this box. Other parts of the preview should be ignored. Otherwise, all the text in the preview would be recognized which is bad for my use case.
It's easy to show a rectangular box on the camera preview but I don't know how to only analyze the part in that rectangular box instead of the whole preview. Any help please?
There are two ideas you can consider:
(1) Crop your camera preview down to only the rectangular box and feed that cropped image to the ML Kit API.
(2) ML Kit's Text Recognition API returns a bounding box on Android (and frame on iOS). You can use that to determine if any of the text recognition results falls into or overlaps with your rectangular box. Depending on your use case and the input image, this approach may not be ideal since it can return text recognition result for text not entirely inside your rectangle.

Custom Shaped Buttons Unity UI

Hi I am trying to create custom buttons on unity (trapeziums). I successfully created the visible area on Photoshop and imported it as Sprite 2D UI as per the following image:
The issue arises, when I'm trying to select one of the buttons in game, their border overlap each other, since the transparent area is still being considered as part of the clickable button area. How can I remove this?
EDIT:
Practically when I import I want the squared boxes to not be counted with the image. I need the edges of the orange area to be cut flush with that and not the entire area(i.e. including the transparent boxes).
You may achieve this by using Alpha Hit Test Minimum Threshold. Take a look at this nice video tutorial.
There is one extra step that is not shown in the video but mentioned in the comments: you have to change "Mesh Type" to "Full Rect" and not "Tight" as it is.
Hope that helps.
The clickable area is based on the Rect Transform component of the GameObject. Adjust the width and height to the clickable area you want. You may have to crop your image in photoshop accordingly. If you select 'Gizmos' in the editor you can toggle viewing the click region.

detect coordinates of some element on image

Please tell me how to solve this problem.
Where to start and which way to go.
I have an image with some buttons :
How can i detect coordinates of blue round button for example?
The difficulty lies in the fact that these are not application buttons, but just a picture on the desktop.
I understand that this is a vast and complex question, but tell me at least the right way.
It will be useful to many people.
The first thing I can imagine is to do a desktop screen, and then try to detect pixels with blue color.
You don't need to do manual image detection because Apple's vision framework already does this. You can use it to detect rectangular regions, detect text, or recognize and image within an image, depending on your needs.
See Detecting Objects in Still Images

Unity 3D text disappears when I rotate the camera

New to Unity.
I think it's quite weird. What I was trying to do is to make the words on the newspaper flow like water. I created a plane for the newspaper, and I added a 3D Text object.
It worked well at first but when I rotate the camera(not the camera in the scene, but the camera with which you do all the editing), the text simply disappeared at some angles (particularly from below). The main camera had the same problem. It saw the text at some angle and couldn't at some other. I am sure that the texts are positioned right in the viewing frustum.
Some screenshots:
The text can be seem from here
And it cannot be seen when the camera moves a little bit down
Or from another angle, the text is selected
It is in the viewing frustum. But the main camera does not see it
It seems like your text and background are on the exact same coordinates (for example 1,1,1). By doing so, you let Unity decide which is more important to show on the foreground, which makes it dissapear sometimes.
Try to move your text a little forward (for example 1,1,1.001), so it seems to rest on, instead of in the newspaper. Most of the time, that should fix the problem.
Is there some kind of transparency on the object?
Try to set it to opaque to check if this is the problem

Build Iphone app that can recognise colour from streaming camera

I am building an iphone app to recognise a specific colour through the iphone camera when placed onto a colour board.
Note that I want it to work through the streaming camera output not just a still image or photo.
My initial thoughts were to scan series of pixels (say 4 on each corner of the camera feed) and if the colours registered in each pixel match, then display colour (in text) to user.
Can someone please point me in the right direction as far as example code or API or even if there is a better design solution to the problem.