Background technology
Increasingly expansion with the rapid development and user of information technology to mobile terminal equipment performance demand, mainstream mobile phone
Screen size show continuous increased trend.Before recalling 5 years, first Android intelligent Google G1 are with 3.2 English
When very little screen appears, who is also unimaginable, the developing direction of smart mobile phone and track.With mobile interchange application and social media
Rapid development, the increase of smart mobile phone screen size obtained the response of application, and consumer is also unconsciously gradually
Gradually receive size constantly increased " big mobile phone ".
Large-screen mobile phone brings the incomparable advantage of small screen mobile phone to user, allows user that can enjoy large-size screen monitors whenever and wherever possible
The experience brought.For example navigated on map with large-size screen monitors, more contents can be seen in a screen, and can be seen ground
More places on figure eliminate the mobile operation of many scalings, this is a kind of convenience;Or viewing film, read books,
When with friend's share photos, large-size screen monitors possess advantageous advantage, or even have many users to indicate, after getting used to large-size screen monitors, very
The difficult use for adapting to smaller screen.
While large-screen mobile phone increases user experience, also difficulty is brought to the normal operating of user.General user
It is accustomed to and is pleased with the one-handed performance of mobile phone, and large-screen mobile phone then can bring fingers of single hand that can not cover most of operating area
Problem.For this problem, there are many solutions, for example Samsung increases Smart in S4 this product
Scroll functions realize eyeball control.
Invention content
The present invention is directed to deficiencies of the prior art, proposes a kind of watching attentively for locking eyeball based on mobile terminal
The method in region identifies the pupil position of user in camera video stream first, by analyzing the variation of eyeball position, to speculate
The watching area of eyes of user, so as to adjust the display strategy of mobile phone.Method used in the present invention is based on opencv
It increases income library, there is very high computational efficiency, calculating task can be efficiently completed very much.
The present invention is achieved by the following technical solutions:
The method for the watching area for locking eyeball based on mobile terminal that the present invention relates to a kind of, by being adopted from video flowing
Collect face area, and therefrom marks off eye estimation region, eye-shaped region is obtained after subdivision and handled by binarization of gray value
Pupil center location is obtained, current fixation region is obtained finally by the comparison with normal condition position.
The face area identifies to obtain by cascade classifier, preferably by moving average and fixed facial regions
The mode of domain size obtains.
The division refers to:It is divided in the following way from face area and obtains eye rectangle estimation region:It is left and right
The upper edge of eye rectangular area and the upper edge of face area are at a distance of height/3.7;The width of images of left and right eyes rectangular area is respectively
width/3;Images of left and right eyes rectangular area is adjacent and center is on screen level direction;The height of images of left and right eyes rectangular area
For height/4, wherein:Height is the video height captured, and width is the video width captured, and unit is pixel.
The subdivision refers to:It is identified from eye estimation region using cascade classifier and obtains eye-shaped region.
The normal condition position refers to:Under normal condition, the position of pupil center and the ratio value of face area.
The comparison refers to:Record the ratio of the position and face area of user pupil center in real time in the study stage
Value;In the control stage, current region-of-interest is calculated by comparing the variation of ratio value.
Embodiment 1
As shown in Figure 1, the present embodiment includes the following steps:
The first step obtains video flowing from front camera.
Video flowing is obtained by the method that opencv for android image libraries are provided in the present embodiment, in layout
Using org.opencv.android.JavaCameraView controls, by existing to the setting of this view in activity
Each frame picture is obtained in onCameraFrame.
Second step, the video flowing obtained according to the first step analyze the face area of user.
The face area identifies to obtain by the cascade classifier that opencv for android image libraries are provided,
The lbpcascade_frontalface.xml grader files increased income are loaded, to identify the region of face.
Since what above-mentioned grader cannot be stablized identifies that face, the present embodiment use following two methods to overcome this
A problem:
1) moving average:The face area that preceding 3 frame picture recognition goes out is preserved, this recognition result uses current knowledge
The average value of other result and preceding recognition result three times, to realize the effect for stablizing the face area identified.
2) fixed face area size:Due to user in operating handset at a distance from mobile phone it is substantially stationary, so using
Fixed face area is sized to satisfy the use demand, and plays the role of stablizing the face area identified.
The face's ratio for the face area and ordinary user that third step, basis analyze, the eye for calculating user are estimated
Count region.
Since face's organ ratio of mediocrity is in a reasonable range, this is provided calculating rough ocular
Foundation.
The ratio that the present embodiment uses is as shown in figure 5, i.e.:The upper edge of images of left and right eyes rectangular area and face area it is upper
Edge is at a distance of height/3.7;The width of images of left and right eyes rectangular area is respectively width/3;Images of left and right eyes rectangular area is adjacent and is shielding
It is in center in curtain horizontal direction;The height of images of left and right eyes rectangular area is height/4, wherein:Height is regarding for capture
Frequency height, width are the video width captured, and unit is pixel.
4th step, the ocular obtained from third step analyze two eye-shaped regions.
Above-mentioned rectangular area also uses the cascade classifier that opencv for android image libraries are provided, load
Grader file (the http of the images of left and right eyes of Shiqi Yu training://yushiqi.cn/research/eyedetection), this
What sample can be stablized identifies the region of eyes.
5th step carries out binarization operation to the gray level image of the rectangular area of the 4th step, finds out the center of black region,
That is the center of pupil, specially:Obtain the gray level image of eye areas first, then with gray value 30 be domain, by ocular into
The result of row binaryzation, binaryzation becomes 0 for the gray value of pupil region, other regions are 255;By being to all gray values
The coordinate of 0 point is averaged, you can obtains the center of pupil.
6th step, according to the variation of pupil center location and normal condition position, analyze the watching area of eyes of user,
Specially:Record the ratio value of the position and face area of user pupil center in real time in the study stage;In the control stage, pass through
Current region-of-interest is calculated in the variation of compared proportions value.
Ratio value obtains calculation formula:
The width of the abscissa of Rate_X=Liang Ge pupil center/face rectangular area
The height of the ordinate of Rate_Y=Liang Ge pupil center/face rectangular area
The comparison of ratio value and judgment method are:
Rate_X (current)-Rate_X (standard)>Bound_X && Rate_Y (current)-Rate_Y (standard)>bound_
Y → be just look at lower right region
Rate_X (current)-Rate_X (standard)<- bound_X && Rate_Y (current)-Rate_Y (standard)>
Bound_Y → be just look at bottom-left quadrant
Rate_X (current)-Rate_X (standard)>Bound_X && Rate_Y (current)-Rate_Y (standard)<‐
Bound_Y → be just look at upper right side region
Rate_X (current)-Rate_X (standard)<- bound_X && Rate_Y (current)-Rate_Y (standard)<‐
Bound_Y → be just look at upper left region domain
Above-mentioned image coordinate system is laterally X-axis using the image upper left corner as coordinate origin, and longitudinal is Y-axis
Implementation result
According to above-mentioned steps, the present embodiment tests 5 male users and 3 female users.All experiments are being carried
It is realized on the mobile phone of android4.4 operating systems, the major parameter of the mobile phone is:Central processing unit:Think Kirin 910T in sea
(1.8GHz), memory 2GB.
The results show that all users, it is good in light, watch attentively using the locking eyes of user that can stablize
Region, will produce error, error rate 9% once in a while.This experiment shows the locking human eye watching area method of the present embodiment
Requirement can be effectively accomplished.