I am using MLKit for face detection, it is working fine. But there is a use case in which I am getting trouble.
MLKit is too Fast, it can detect half face too.
I want to detect whole face, I want to know whether there is the complete face in the frame or not?
E.g: I apply MLKit' Face Detection on the attached Image, it is returning me all the Landmarks positions, all the contours etc. It is also returning me the smiling probability even there are no lips in the image.
I think you can call face.getBoundingBox() to get the coordinates of the bounding box, and check whether all the corners are in the frame.
I used MediaPipe' Face Mesh solution. Through it, I am getting Face contours, these (36) points are in oval, from 0 to 35.
Related
I am trying to detect with OpenCv for Android hexagon fields of a map for a board game. The map looks something like that:
[Sample map]
I tried getting contours using only Value from HSV and I managed to get some of the hexagons, but unfortunately not all of them, I had mostly trouble detecting hexagons that had rivers or roads passing through them.
I managed to get something like that:
[Detected hexagons]
I even tried to make the borders thicker, but it didn't help a lot.
To detect all of the hexagons I thought of averaging the approximite size of the detected and then go on pixel by pixel trying to detect a change in the color (close to black). Later I would like to detect hexagons even on photos of a map, so then I couldn't really rely on the size of other hexagons.
What do you think would be the best way to solve this problem?
EDIT:
Thank you
I just began to implement your idea and it works great, for now i got the horizontal lines:
You deal with regular grid, so you just need to detect just a few, or even one, to compute all others. More will be better, because you'll be able to compute mean, and it will be more accurate. To find contours, it might be useful to find color gradient.
In my case, I have an image which detects a face using face-detection. now I want to try to create a face mask of detected face but I have no idea how to create a face mask of detected faces.so please help me how can I create a face mask of the original image. In face detection, I can use google-vision to detect a face like an oval. I can use this to detect a face.
Thank you in advance.
Problem that I am trying to solve is to detect cubes and get colours from them. I use live images from camera captured by Android phone. Recognition has to be fast (<1s) Example of a cube:
I also have differently coloured cubes. They can be placed randomly (for example when they touch each other).
I can easily detect one cube, in same cases even two cubes, but the problem is when I have 3 or more and for 2 cubes when they are really close to each other.
Currently processing looks like this:
blur image with Gaussian
convert to hsv and use only s channel
detect edges with Canny
dilate and erode edges
use HoughLinesP to get lines
from lines (I reject too long and too short lines) calculate intersection points and from that get corners of cubes
knowing corners (must be precise) get colours
nothing detected
2 cubes detected (red and orange points are corners and cyan points are intersection points, black lines are detected lines by hough lines)
nothing detected, some lines found
Basically what I need is to find correct corners of the cubes. I tried using Imgproc.goodFeaturesToTrack and Imgproc.cornerHarris, but it finds too many of them and usually not the most important ones.
I also tried using findContours with no success even for two objects. findContours was also crashing my app after minute of running. At some point I tried using Feature Matching + Homography to find matches to a grayscale image of a cube with the one from camera, but results were messy. Also Template Matching didn't give me good results.
Do you have any idea how to make detection more reliable and precise?
Thanks for help
What is the best way to detect blinks from an up close image of an eye? I am getting the frames from a head mounted camera as shown before.
I have tried:
Template Matching which doesnt always give accurate results.
Looking for frames in which the pupil is not visible - also not always accurate.
Hi you can use HoughTransform for circle detection.
it returns a list of circles found in the image.
the first circle in the list should be the pupil.
then if the list is empty or the circle found is smaller then x pixels the eye is closed.
I am trying to make a AR app for android in witch the user points the camera to a square marker and a 3d model should show on top of the marker.
I am using OpenCV to get the rotation and translation of the marker but..
To get these 2 matrices, I use solvePnP for which I have to provide a camera matrix and a
distortion matrix which (from my understanding) are specific for each camera type.
Unfortunately, this is a huge drawback for me since the app should be supported by most Android devices and I also can't ask the user to run the camera calibration procedure (functions provided by openCV).
So the question: is there a way to eliminate the camera and distortion matrices? Or, is there another way to calculate the marker 3D position relative to the device?
I tried QCAR and Unity AR but (since the 3D models are downloaded form a server and are changing constantly), I was forced to go with OpenCV.
Any help will be really appreciated.
Thanks.
Bad news for you. The answer is no.
You can't know anything about your image if you don't know anything about your camera. The camera is described by the two matrices: camera mat and distortions mat.
But.. along with the bad news, there are some good news. You can do something, maybe.
Distortion matrix can be ignored in many AR applications. You just don't care about the small distortions.
And the camera matrix can be constructed if you know camera's field of view.
Camera matrix:
w/(2*tan(camera.fovX())), 0, w/2, 0,
0, h/(2*tan(camera.fovY())), h/2, 0,
0, 0, 1, 0
On Android there's an API for retrieving the aperture: getHorizontalAperture() and getVerticalAperture(). Aperture is field of view.
However, on many phones, the returned value isn't correct, because the manufacturers did not care to set it right. It might return bogus angles like 10 or 180 degrees. There's no good way to fix this apart from testing individual phone models.
Good luck!