How to detect BLINKS using OpenCV for Android? - android

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.

Related

Orientation corners of a QR-code

As of now, when Android Vision detects a QR-code, the array "Barcode.cornerPoints" (which contains the code's corner points) is populated in a seemingly random order. I need is to determine which 3 out of the 4 corner points that contains "orientation squares".
The current approach I am using is very unsatisfying:
For every detected QR-code, I am forced to create a bitmap and attempt to find the QR-code again with another library (Zxing) that always returns the corner points in a consistent order with respect to rotation.
If Zxing finds the QR-code (which sadly doesn't happen about four times out of five), I need to cross-check and match the Zxing-corners with Android Vision corners.
What I would like is to get the array "Barcode.cornerPoints" populated with respect to orientation.
For example and clarification:
cornerPoints[0] = //First corner-point with an orientation square
cornerPoints[1] = //Second corner-point with an orientation square
cornerPoints[2] = //Third corner-point with an orientation square
cornerPoints[3] = //The corner-point that does not contain a orientation square
> Like in this picture <
I have been trying to find a clever workaround to this issue for quire a while now but I can't come up with any good solution, and it does not appear as Google has open source'd the code used when population the qrCorners array so i can't extend it...
Any help out there? I am not the only one who has been looking for a solution to this issue:
https://github.com/googlesamples/android-vision/issues/103
I am in a similar situation as well. What might help you to know is that Android Vision does not return the corner points in a completely random order.
I believe that the detector scans the image from top left to bottom right of the frame. The QR-code-corner which is detected first in the image will be returned as corner 0 and the rest in a clockwise direction.
What would be really helpful was if Android Vision returned the corners like you said, in a "static" order depending on orientation. I barely see any reason for the chosen way to return the corner points. Maybe better performance? For the QR-code to be read it has to be done according to a certain orientation which is determined by the corners of the QR-code. Which means Android Vision already has identified the orientation and corners but does not give this information to us.
Maybe this could be added in future updates?

Edge detection issue using OpenCV library

I am working on a project on image processing. I need to segment only the required object from the image and make the background white. For this I am detecting the edges in the image and then finding contours. I then draw the contour with the maximum area and finally copy it to a white background image.
But the issue with it is that while detecting edges, the edges are broken. On observing I realized that it is showing broken edges at that point where the intensity of foreground and background is the same. It doesn't find any change, thus no edge is detected. How do I fix this?
Actually, for this I am calculating the histogram of the image, and then finding the median from the histogram, but I am unable to find this.

opencv detect cubes (corners)

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

how to attach overlay to detected object using android and OpenCV

I'm writing an android app using OpenCV for my masters that will be something like a game. The main goal is to a detect a car in selected area. The "prize" will be triggered randomly while detecting cars. When the user will hit the proper car I want to display a 3D object overlay on the screen and attach it to the middle of the car and keep it there so when the user will change the angle of his view on the car, the object will also be seen from diffrent angle.
at the moment I have EVERYTHING beside attaching the object. I've created detection, I'm drawing the 3D overlay, I've created functions that allow me to rotate the camera etc. BUT I do not have any clue how can I attach the overlay to the specific point. Cause I don't have this I have no point to recalculate the renderer to change the overlay perspective.
Please, I really need some help, even a small idea will be fine:
How can I attach the overlay to the specific in real world
(Sorry, I couldn't comment. Need at least 50 points to do that ... :P )
I assume your image of the car is coming from a camera feed and you are drawing 3d car in opengl. If so, then you can try this:
You set the pixel format of the opengl layer as RGBA_8888, so that you can set the background of the opengl camera as a transparent color.
You take a relative layout as layout of your activity.
first you add the opencv camera layout to it as full height and width.
then you add opengl layer as full height and width.
you get the position of the real car from opencv layer as pixel value or something you did.
then scale it to your opengl parameters so that you can draw it on the right spot.
it worked for me. hope it works for you too.

Positioning an image on top of an image with specific coordinates in Android

End Goal: Getting a speedometer style needle to move around a dial according to test results.
Current Issue: At the moment I have placed the needle on top of the speed dial as a sperate image using FrameLayout. I have been scouring the web for a way to position the needle with coordinates so I can have it exactly where I want it on the dial. I would post an image but I'm new to the forum and I'm not allowed!
So in short can I position an image over another image with exact coordinates (allowing for rotation etc)? Am I going the right way about solving my problem?
There is the AbsoluteLayout, which lets you use absolute positions, but it is not recommended that you use it.
Instead, you should create your own extension of a View, that draws your dial and needle. For more info on this, look at Maurycy's comment, which recommends this part of the manual.
Calculate measurements and rotate image of indicator accordingly.

Categories

Resources