Pupil positioning method and apparatus
By establishing vectors and cumulative vectors of image pixels, the uniformity of pupil region distribution is determined, solving the problem of inaccurate pupil positioning in complex environments, achieving accurate positioning under various conditions, and improving the accuracy of optometric measurements and laser refractive surgery.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- BRIGHTVIEW MEDICAL TECHNOLOGIES (NANJING) CO LTD
- Filing Date
- 2022-09-22
- Publication Date
- 2026-04-14
AI Technical Summary
Existing technologies struggle to accurately locate the pupil in complex environments, affecting the precision of optometry and laser refractive surgery. This is especially true for infants and young children, as well as those with poor cooperation, where the complex and diverse imaging environment leads to inaccurate pupil localization.
The pupil localization method is implemented by establishing M vectors for the pixels to be processed in the image, obtaining the cumulative vector of the M vectors for each pixel, and determining whether it is the pupil region based on the uniformity of the directional interval distribution of the cumulative vector. The method utilizes memory and processor.
Accurately locate the pupil under various complex conditions, reduce the impact of the environment and human movement, and improve the accuracy of optometry and laser refractive surgery.
Smart Images

Figure CN117788361B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image processing, and in particular to a pupil localization method and apparatus. Background Technology
[0002] With the increasing number of people with myopia, statistics show that the number of people with myopia in my country has exceeded 600 million, and the myopia rate among teenagers is the highest in the world. Therefore, optometric instruments are becoming increasingly important. Measuring refractive power and axial length is crucial for myopia prevention and early detection of refractive problems, and also serves as an auxiliary examination for subsequent laser refractive surgery.
[0003] The pupil, the opening formed by the iris, is a crucial component of the human eye's optical system. Its primary function is to maintain a stable flow of light into the fundus under varying lighting conditions by changing its size. Furthermore, pupil size significantly impacts the depth of focus and overall eye aberrations. During refractive error measurement, the doctor or operator needs to manually or automatically align the instrument with the pupil area. Automatic methods require pupil localization to guide the moving platform in aligning the instrument with the pupil and to monitor the pupil's position in real-time to detect any misalignment. Manual methods also require pupil localization to assist the operator in aligning the instrument with the pupil, and to alert the operator if the pupil is misaligned. Real-time pupil localization is even more critical for infants and individuals with poor cooperation, allowing for adjustments in various situations to avoid affecting measurement results. In addition, in laser refractive surgery, the positioning and maintenance of the corneal ablation center are paramount. For ease of operation, real-time eye tracking is necessary during laser refractive surgery, requiring accurate and rapid pupil localization.
[0004] Considering the complex and diverse imaging environments in real-world scenarios—for example, eyelashes may obscure the eyes, eyes may be half-closed, and head movements or eye movements can also cause blurry images—providing a method for accurately locating the pupil, applicable under various complex conditions, is of great significance. Summary of the Invention
[0005] The purpose of this invention is to provide a pupil positioning method and device that can accurately locate the pupil and can be applied under various complex conditions.
[0006] To achieve the above objectives, the present invention provides the following technical solution:
[0007] A pupil localization method, comprising:
[0008] M vectors are established for the pixels to be processed in the image. Each of the M vectors corresponds to a different angle. Each vector represents the difference in pixel value between the current pixel and the L pixels at the angle corresponding to the current vector. M and L are both positive integers greater than or equal to 2. The magnitude of the vector represents the sum of the differences in pixel value between the current pixel and the L pixels at the angle corresponding to the current vector. The direction of the vector is determined according to the angle corresponding to the current vector and the sign of the sum of the differences in pixel value.
[0009] Select a preset image region of the image. For each pixel in the preset image region, obtain the sum of M vectors of each pixel and determine the direction interval to which the sum of vectors belongs. The direction interval is N intervals that are evenly divided within the circumference, where N is a positive integer greater than or equal to 2.
[0010] Obtain the average position of pixels in the preset image region whose accumulated vectors belong to the same directional interval, and establish a mapping vector for any directional interval using the preset position and the average position in the preset image region as endpoints;
[0011] Based on the uniformity of the distribution of the mapping vectors in each directional interval of the preset image region, it is determined whether the preset image region corresponds to the pupil.
[0012] Preferably, determining whether the preset image region corresponds to a pupil based on the uniformity of the distribution of the mapping vectors in each directional interval of the preset image region includes:
[0013] Calculate the angle difference between the mapping vectors of any two adjacent directional intervals of the preset image region. The angle difference is the angle difference between the mapping vector of the latter directional interval and the mapping vector of the former directional interval in the clockwise / counterclockwise direction of the two adjacent directional intervals. If the sign of at least one of the calculated angle differences is different from that of the other angle differences, then it is determined that the preset image region does not correspond to the pupil.
[0014] Preferably, determining whether the preset image region corresponds to a pupil based on the uniformity of the distribution of the mapping vectors in each directional interval of the preset image region includes:
[0015] Calculate the angle difference between the mapping vectors of any two adjacent directional intervals in the preset image region. The angle difference is the angle difference between the mapping vector of the latter directional interval and the mapping vector of the former directional interval in the clockwise / counterclockwise direction of the two adjacent directional intervals.
[0016] Calculate the absolute difference between any of the angle differences and the interval value of the direction interval, or calculate the absolute difference between each of the angle differences and the interval value of the direction interval and calculate the average of the obtained absolute differences;
[0017] If the absolute difference between any of the angle differences and the interval value of the direction interval does not meet the requirements, then it is determined that the preset image region does not correspond to the pupil; or if the average value of the obtained absolute differences does not meet the requirements, then it is determined that the preset image region does not correspond to the pupil.
[0018] Preferably, the selection of the preset image region includes:
[0019] For each pixel of the image, if the directions of all O vectors of this pixel are either away from this pixel or towards this pixel, then this pixel is determined as a candidate pixel, where O is a positive integer greater than or equal to 2.
[0020] Obtain a connected region formed by multiple candidate pixels, and use a preset range region containing the connected region as the preset image region.
[0021] Preferred options also include:
[0022] Calculate the average pixel value of the candidate pixels included in the preset image region, and use it as the pixel value mean;
[0023] If the average pixel value does not meet the requirements, then the preset image region does not correspond to the pupil.
[0024] Preferably, before obtaining the average position of pixels in the preset image region whose accumulated vectors belong to the same directional interval, the method further includes:
[0025] Obtain the number of pixels in each directional interval whose accumulated vector of pixels in the preset image region belongs to each directional interval;
[0026] For any directional interval of the preset image region, obtain the percentage of pixels in the preset image region whose accumulated vector belongs to this directional interval. If the percentage of pixels in at least one directional interval of the preset image region is less than or equal to a first threshold, then the preset image region is excluded.
[0027] Preferably, the step of obtaining the sum of M vectors for each pixel in the preset image region includes:
[0028] Obtain the size information of the preset image region, and determine the L value when establishing M vectors for the pixels in the preset image region based on the size information of the preset image region, so as to obtain the cumulative vector of the M vectors for each pixel.
[0029] Preferred options also include:
[0030] For the preset image region corresponding to the pupil, obtain the bounding rectangle of the preset image region;
[0031] In the image, an image block is cropped with the center of the outer rectangle of the preset image region as the center, the length as a first preset multiple of the length of the outer rectangle of the preset image region, and the width as a second preset multiple of the width of the outer rectangle of the preset image region as the width, and this is used as the search image block;
[0032] Pixels whose pixel values are within a second preset range are retrieved from the search image block, the connected components formed by the retrieved pixels are obtained, and the largest connected component is selected.
[0033] The pupil center is determined by mapping the largest connected component to the pupil region.
[0034] Preferably, before obtaining the average position of pixels in the same direction interval of the accumulated vector in the preset image region, the method further includes: obtaining the bounding rectangle of the preset image region; if the geometric parameters of the bounding rectangle of the preset image region are not within a first preset range, then the preset image region is excluded.
[0035] A pupil positioning device, comprising:
[0036] Memory, used to store computer programs;
[0037] A processor for executing the computer program to implement the pupil localization method as described above.
[0038] As can be seen from the above technical solution, the pupil localization method and apparatus provided by the present invention establishes M vectors for the pixels to be processed in an image. Each of the M vectors corresponds to a different angle. Each vector represents the difference in pixel values between the current pixel and the L pixels at the corresponding angle of the current vector. The magnitude of the vector represents the sum of the differences in pixel values between the current pixel and the L pixels at the corresponding angle of the current vector. The direction of the vector is determined based on the sign of the corresponding angle and the sum of the differences in pixel values. Then, a preset image region is selected. For each pixel in the preset image region, the accumulated vector of the M vectors for each pixel is obtained, and the direction interval to which the accumulated vector belongs is determined. The direction interval is N intervals evenly divided within a circle. Further, the average position of pixels in the preset image region whose accumulated vectors belong to the same direction interval is obtained. Using the preset position and the average position in the preset image region as endpoints, a mapping vector for any direction interval is established. Based on the uniformity of the distribution of the mapping vectors in each direction interval of the preset image region, it is determined whether the preset image region corresponds to a pupil, thereby achieving pupil localization.
[0039] The pupil localization method and apparatus of the present invention establish a vector reflecting the difference in pixel values between a pixel and its surrounding pixels based on the pixel values of an image. For an image region, the method determines whether the image region corresponds to a pupil based on the directional interval distribution of the pixel vectors in the image region, thereby locating the pupil. This invention can reduce the influence of complex and diverse environments in real-world scenarios, as well as the effects of head movement or eye movement responses, and can accurately locate the pupil under various complex conditions. Attached Figure Description
[0040] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0041] Figure 1 A flowchart of a pupil localization method provided in an embodiment of the present invention;
[0042] Figure 2 This is a schematic diagram illustrating the definition of pixel angles in one embodiment of the present invention;
[0043] Figures 3(a) and 3(b) are schematic diagrams of vector calculation when the angle is 90 degrees in one embodiment of the present invention;
[0044] Figure 4 This is a schematic diagram illustrating how an accumulated vector is obtained from the vectors of each pixel in one embodiment of the present invention.
[0045] Figure 5 This is a schematic diagram of the mapping vectors of the pupil region in a specific embodiment of the present invention;
[0046] Figure 6 for Figure 5 The diagram shows the directional range distribution of the corresponding pupil region.
[0047] Figures 7(a) and 7(b) are directional interval distribution diagrams of the non-pupil region in a specific embodiment of the present invention, respectively.
[0048] Figures 8(a) and 8(b) are two images obtained in a specific embodiment of the present invention, showing the detection of a preset image region.
[0049] Figure 9(a) shows the preset image area of the corresponding pupil detected in a specific example of the present invention;
[0050] Figure 9(b) is a schematic diagram of the connected components obtained after searching the preset image region based on pixel values. Detailed Implementation
[0051] To enable those skilled in the art to better understand the technical solutions of this invention, the technical solutions of the embodiments of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this invention, and not all embodiments. Based on the embodiments of this invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of this invention.
[0052] Please refer to Figure 1 , Figure 1 A flowchart of a pupil localization method provided in this embodiment is shown in the figure. The pupil localization method includes the following steps:
[0053] S11: Establish M vectors for the pixels to be processed in the image. The M vectors correspond to different angles. The vectors represent the differences in pixel values between the L pixels at the angle corresponding to the vector of the current pixel and the current pixel. M and L are both positive integers greater than or equal to 2.
[0054] The magnitude of the vector represents the sum of the differences between the pixel values of the L pixels at the angle corresponding to the vector of the current pixel and the current pixel. The direction of the vector is determined according to the angle corresponding to the vector and the sign of the sum of the differences in pixel values.
[0055] M vectors correspond to M different angles. For any pixel in the image, calculate the pixel value difference between the current pixel and the L pixels at the i-th angle, and construct the i-th vector for this pixel. The magnitude of the i-th vector represents the sum of the pixel value differences between the current pixel and the L pixels at the i-th angle. The direction of the i-th vector is determined by the i-th angle and the sign of the sum of the pixel value differences corresponding to the i-th vector. Based on this, M vectors are constructed for the current pixel corresponding to the M angles.
[0056] The image refers to the image from which the pupil needs to be located.
[0057] S12: Select a preset image region of the image, and for each pixel in the preset image region, obtain the sum of M vectors of each pixel, and determine the direction interval to which the sum of vectors belongs.
[0058] The directional intervals are defined as N intervals evenly divided within a circumference, where N is a positive integer greater than or equal to 2. Specifically, N intervals are evenly divided within a 360-degree radius of the circumference, with each directional interval having the same interval value. The interval value of a directional interval refers to the angular interval between the two endpoints of that interval.
[0059] A preset image region is selected from the image. This preset image region is a candidate image block for the pupil region (it can be a block cropped separately from the image or a portion of the original image). Further determination is made as to whether the preset image region truly corresponds to the pupil region. For any pixel within the preset image region, the M vectors of this pixel are summed to obtain the accumulated vector of this pixel. Based on the direction of the accumulated vector of this pixel, the direction interval to which the accumulated vector of this pixel belongs is determined.
[0060] S13: Obtain the average position of pixels in the preset image region whose accumulated vectors belong to the same directional interval, and establish a mapping vector for any directional interval using the preset position in the preset image region and the average position as endpoints.
[0061] Based on the accumulated vectors of each pixel in the preset image region, for pixels whose accumulated vectors belong to the same directional interval, the average position of the pixels whose accumulated vectors belong to the same directional interval is obtained.
[0062] The preset image region includes pixels belonging to various directional intervals. For each directional interval, the average position of the pixels belonging to that directional interval is obtained by accumulating the vector. Thus, for each directional interval included in the preset image region, the average pixel position corresponding to each directional interval is obtained.
[0063] For any directional interval included in the preset image region, a mapping vector for this directional interval is established, using the preset position in the preset image region and the average position corresponding to this directional interval as endpoints. For each directional interval included in the preset image region, the mapping vector for each directional interval is obtained respectively.
[0064] S14: Determine whether the preset image region corresponds to the pupil based on the uniformity of the distribution of the mapping vector in each directional interval of the preset image region.
[0065] In an eye image, the pixel values of the pupil region are lower than those of its surrounding areas. Correspondingly, the distribution of mapping vectors in each directional interval of the pupil region follows a certain pattern, and these mapping vectors are evenly distributed sequentially around the circumference. Based on this, the distribution of mapping vectors in each directional interval of a preset image region can be used to determine whether the preset image region corresponds to the pupil.
[0066] The pupil localization method of this embodiment establishes a vector reflecting the difference in pixel values between a pixel and its surrounding pixels based on the pixel values of the image. For a preset image region, it determines whether the preset image region corresponds to a pupil based on the directional interval distribution of the pixel vectors in the preset image region, thereby locating the pupil. The pupil localization method of this embodiment can reduce the influence of the complex and diverse environment in real-world scenarios, as well as the influence of head movement or eye movement responses, and can accurately locate the pupil under various complex conditions.
[0067] The pupil localization method will be described in detail below with reference to specific implementation methods.
[0068] Optionally, M vectors can be constructed from the pixels of the image using the following method, including the following process:
[0069] S111: Select M angles for the pixels to be processed in the image and determine the preset quantity L.
[0070] In this embodiment, the value of M is not limited, and can be set according to the detection requirements in practical applications. Preferably, the M angles can be selected with equal angle differences, that is, the angle difference between any two adjacent angles among the M angles is equal. An example can be found here. Figure 2 , Figure 2 This is a schematic diagram of defining the angle of a pixel in one embodiment. As shown in the figure, the vertical upward direction can be taken as 0 degrees, and various angles can be selected in a clockwise direction. The i-th angle can be expressed as: Di=360 / M*(i-1), 1≤i≤M.
[0071] The value of the preset quantity L is not limited and can be set according to the detection requirements in practical applications. In this embodiment, both M and L are positive integers greater than or equal to 2. Preferably, for each preset image region of the image, the value of the preset quantity L used when establishing vectors for pixels in each preset image region can be different, and the value of L can be adaptively set for each preset image region. Optionally, the size information of the preset image region can be obtained, and the value of L when establishing M vectors for pixels in the preset image region can be determined according to the size information of the preset image region, so as to obtain the cumulative vector of the M vectors of each pixel. In this embodiment, L is the maximum value between the length and width of the preset image region. The advantage of this adaptive selection of the L value is that it can flexibly adapt to preset image regions of different sizes, and an appropriate L value can be selected for each preset image region, so that its cumulative vector more accurately reflects the pixel distribution around each pixel, which can improve the accuracy of pupil region recognition and reduce the impact of overexposure, noise, reflection and other conditions on image processing effect.
[0072] S112: For the i-th angle of the pixel to be processed in the image, calculate the sum of the pixel value differences between the pixel and the preset number of pixels at the i-th angle of the pixel, and determine the magnitude and direction of the i-th vector of the pixel based on the sum of the pixel value differences, i∈[1,M].
[0073] For example, the vector of pixel (m,n) can be calculated according to the following formula:
[0074] vector D =∑(image(m) j ,n j )-image(m,n)), 1≤j≤L.
[0075] Wherein, image(m j ,n j ) represents pixels (m,n) and pixels (m L ,n L The pixels that pass through along angle D between ()
[0076] Optionally, the direction of the vector of pixel (m,n) can be defined according to the following: if vector D If the value is greater than 0, it means the pointer points from pixel (m,n) to pixel (m). L ,n L The direction of the vector is D; if vector D If less than 0, it means from pixel (m) L ,n L The vector points to pixel (m, n), and its direction is D+180. D | represents the magnitude of the vector.
[0077] For illustrative examples, refer to Figures 3(a) and 3(b), which are schematic diagrams illustrating vector calculation when the angle is 90 degrees in one embodiment. As shown in Figure 3(a), if ∑(image(m+j,n)-image(m,n))>0, 1≤j≤4, then the vector points from (m,n) to (m+4,n). As shown in Figure 3(b), if ∑(image(m+j,n)-image(m,n))<0, 1≤j≤4, then the vector points from (m+4,n) to (m,n).
[0078] In practical applications, a loop processing method can be used to process each pixel of the image, obtaining M vectors for each pixel. Preferably, the properties of convolution can also be utilized to construct convolution kernels to quickly process each pixel in the image. Convolution kernels can be constructed for each angle. After processing the image sequentially using each convolution kernel, M vector maps can be obtained, which can be represented as imageFi (1≤i≤M). Each vector map corresponds to an angle Di. The absolute value of each value in the vector map represents the magnitude of the vector corresponding to the pixel, and the direction of the vector is determined by the sign of the value and the angle Di.
[0079] For any pixel in the image, the accumulated vector of that pixel is obtained by summing the M vectors corresponding to that pixel. Specifically, the coordinates of the vectors can be obtained based on their directions and magnitudes. The coordinates of these vectors are then summed to obtain the coordinates of the accumulated vector, and the direction of the accumulated vector can be determined from these coordinates. An example can be found here. Figure 4 , Figure 4 This is a schematic diagram illustrating how an accumulated vector is obtained from the individual vectors of a pixel in one embodiment. Figure 4 In the left image, each solid line segment with an arrow represents a vector of pixel (m,n), and in the right image, the solid line segment with an arrow represents the accumulated vector of pixel (m,n). The direction of the accumulated vector is the direction corresponding to degree D.
[0080] For example, the accumulated vector (x,y) of pixels (m,n) can be calculated according to the following formula:
[0081] (x′ i ,y′ i )=(a i *cos(D i ),a i *sin(D i If the i-th vector is facing away from pixel (m,n);
[0082] (x′ i ,y′ i )=(a i *cos(D i +180),a i *sin(D i +180), if the i-th vector is oriented toward pixel (m,n);
[0083] (x,y)=(∑x′ i ,∑y′ i ), 1≤i≤M.
[0084] Among them, (x′ i ,y′ i ) represents the coordinates of the i-th vector of pixel (m,n), ai D represents the magnitude of the i-th vector of pixel (m,n). i This represents the direction of the i-th vector of pixel (m,n).
[0085] The direction of the accumulated vector (x, y) of pixels (m, n) can be calculated using the following formula:
[0086]
[0087] Here, abs() represents calculating the absolute value. Angle D final The direction corresponding to (m,n) represents the direction of the accumulated vector (x,y) of pixel (m,n).
[0088] In this embodiment, the value of the number N of the divided directional intervals is not limited, and can be set according to the detection requirements in practical applications. For example, the vertical upward direction can be taken as 0 degrees, and the intervals can be divided in a clockwise direction. The interval of direction i can be represented as: [(i-1)*360 / N, i*360 / N), 1≤i≤N.
[0089] For any pixel in an image, the direction interval to which the accumulated vector of this pixel belongs is determined based on the direction of the accumulated vector of this pixel and the established N direction intervals. For an image, its corresponding direction interval distribution map can be obtained, which describes the direction interval to which the accumulated vector of each pixel in the image belongs.
[0090] Optionally, in step S13, for a preset image region of the image, the average position of pixels whose accumulated vectors belong to the same directional interval in the preset image region can be obtained by the following method: for any directional interval included in the preset image region, the average position of pixels whose accumulated vectors belong to the directional interval is calculated based on the position and number of pixels in the preset image region whose accumulated vectors belong to the directional interval.
[0091] For example, image processing can be performed using the following methods:
[0092] First, construct M convolution kernels at different angles. Then, use these M kernels to convolve the image to be processed (imageBlur) to obtain the M convolved image (imageC). i (1≤i≤M).
[0093] For each convolutional image, subtract K times the pixel value of the corresponding pixel in the image to be processed (imageBlur) from the convolutional image to obtain the vector image imageF. i (1≤i≤M). Thus, M vector maps of the image to be processed are obtained. These can be calculated using the following formula:
[0094] imageF i (m,n)=imageC i (m,n)-K*imageBlur(m,n).
[0095] imageF i Let i represent the i-th vector of the image to be processed.
[0096] Preferably, the image to be processed, imageBlur, can be an image obtained after preprocessing the acquired image data. Preprocessing the acquired image data may include converting the acquired image to grayscale or performing Gaussian filtering. The directional interval distribution map imageVector of the image to be processed can be calculated according to the following formula: imageVector(m,n)=i, if (i-1)*360 / N≤D final (m,n) <i*360 / N。
[0097] Optionally, when establishing a mapping vector for any directional interval of the preset image region in step S13, the preset position in the preset image region can be the center position of the image block, the intersection point of the distribution of various directional intervals in the image block, or an arbitrarily set position. The center position of the preset image region (x...) center ,y center This can be the center position of the bounding rectangle of a predefined image region. Experimental observations show that the pupil region is roughly evenly distributed in all directions, with their ends converging at one point or more. (See reference...) Figure 5 and Figure 6 As shown, Figure 5 This is a schematic diagram of the mapping vectors of the pupil region in a specific example. Figure 6 for Figure 5 The directional interval distribution diagram of the corresponding pupil region shown indicates that the intervals are roughly evenly distributed, with their ends converging at the middle. Referring to Figures 7(a) and 7(b), which respectively show the directional interval distribution diagrams of the non-pupil region in a specific example, it can be seen that the directional interval distribution diagram of the non-pupil region does not follow the above distribution pattern. Therefore, the intersection point of the distribution of each directional interval in the preset image region, i.e., the intersection point of each region in the preset image region, can be used as the preset position to establish the mapping vector of each directional interval.
[0098] Optionally, the intersection point of the distribution of each directional interval in a preset image region can be obtained by the following method: marking the pixels of two adjacent directional intervals in the preset image region, obtaining the connected components formed by the marked pixels, and determining the intersection point of each directional interval in the preset image region based on the corner position of the largest connected component. For example, based on the directional interval distribution map of the preset image region, which describes the directional interval to which the cumulative vector of each pixel in the preset image region belongs, the pixels belonging to the Nth directional interval and the (N-1)th directional interval are marked. For example, the value of the pixels belonging to the Nth directional interval and the (N-1)th directional interval can be set to 255, and the value of the remaining pixels can be set to 0. Connected components are detected for the marked pixels, and one or more connected components can be obtained, where the largest connected component is located at the upper left corner of the image block, and the pixel at the lower right corner of this connected component is the intersection point.
[0099] For any directional interval of a preset image region, a mapping vector can be established with a preset position of the preset image region as the starting point and the average position corresponding to this directional interval as the ending point; alternatively, the mapping vector can also be established with the average position corresponding to this directional interval as the starting point and the preset position of the preset image region as the ending point. In practical applications, the setting can be based on the definition of the vector direction when establishing vectors for image pixels or on the correspondence between the directional interval distribution of image blocks and the pupil region.
[0100] In an eye image, the pixel value of the pupil region is lower than that of its surrounding regions. The mapping vectors of the pupil region in each direction are evenly distributed sequentially around the circumference. Therefore, if the mapping vectors of the preset image region in each direction are distributed sequentially according to the order of the direction intervals, and the uniformity of the distribution of the mapping vectors in each direction interval of the preset image region meets the requirements, then the preset image region can be determined to correspond to the pupil; otherwise, it can be determined that the preset image region does not correspond to the pupil.
[0101] Optionally, in step S14, the following method can be used to determine whether the preset image region corresponds to the pupil based on the uniformity of the distribution of the mapping vectors of each directional interval of the preset image region: calculating the angle difference between the mapping vectors of any two adjacent directional intervals of the preset image region. The angle difference is the angle difference between the mapping vector of the latter directional interval and the mapping vector of the former directional interval in the clockwise / counterclockwise direction of the two adjacent directional intervals. If the sign of at least one of the calculated angle differences is different from that of the other angle differences, it indicates that the mapping vectors of each directional interval of the preset image region are not distributed sequentially according to the order of each directional interval. Therefore, it is considered that the preset image region does not correspond to the pupil.
[0102] Exemplarily, if each direction interval is divided and defined in the clockwise order, then correspondingly for the preset image region, the angular difference between the mapping vectors of any two adjacent direction intervals can be calculated in the clockwise direction. It can be calculated according to the following formula:
[0103]
[0104] Where angleSub[i] represents the angular difference between the mapping vectors of two adjacent direction intervals, angle[i] represents the angle of the mapping vector of the i-th direction interval, and angle[i + 1] represents the angle of the mapping vector of the (i + 1)-th direction interval.
[0105] When establishing M vectors for pixels, the vertical upward direction is defined as 0 degrees and the angles are defined in the clockwise direction. Then, if at least one value of angleSub[i] (1 ≤ i < N) is less than 0, it means that the angles of the mapping vectors of each direction interval in the preset image region do not increase in an orderly manner in the clockwise direction, that is, the mapping vectors of each direction interval are not distributed in sequence according to the order of each direction interval. Then, the preset image region is not the pupil region.
[0106] In practical applications, an array angleSub[N] of float type can be defined to save the pairwise angular differences from the 1st mapping vector to the Nth mapping vector.
[0107] Optionally, in step S14, to determine whether the preset image region corresponds to a pupil according to the distribution uniformity of the mapping vectors of each direction interval in the preset image region, the following method can also be used, including: calculating the angular difference between the mapping vectors of any two adjacent direction intervals in the preset image region, where the angular difference is the angular difference between the mapping vector of the latter direction interval and the mapping vector of the former direction interval in the clockwise / counterclockwise direction between the two adjacent direction intervals; calculating the absolute difference between any one of the angular differences and the interval value of the direction interval. If the absolute difference between any one of the angular differences and the interval value of the direction interval does not meet the requirements, it is determined that the preset image region does not correspond to a pupil. Or, calculating the absolute differences between each of the angular differences and the interval value of the direction interval and calculating the average value of the obtained absolute differences. If the average value of the obtained absolute differences does not meet the requirements, it is determined that the preset image region does not correspond to a pupil.
[0108] If the preset image region corresponds to the pupil, the mapping vectors of its various directional intervals will be evenly distributed on the circumference. The absolute difference between the angle difference of the mapping vectors of any two adjacent directional intervals and the interval value of the directional interval will be small, and the average value of each absolute difference will be small. Therefore, if the absolute difference between any calculated angle difference and the interval value of the directional interval does not meet the requirements, it is considered that the preset image region does not correspond to the pupil. Alternatively, if the average value of each absolute difference, angleMean, does not meet the requirements, it is considered that the preset image region does not correspond to the pupil.
[0109] For example, it can be calculated according to the following formula:
[0110] abs(angleSub[i]-360 / N)(1<=i<=N);
[0111] angleMean=1 / N*∑abs(angleSub[i]-360 / N)(1<=i<=N).
[0112] The smaller the value of angleMean of the preset image region, the more uniformly the N mapping vectors are distributed, and the greater the probability that the preset image region is the pupil region.
[0113] Optionally, based on the above implementation, the method for determining whether a preset image region corresponds to a pupil can also employ the following method: calculating the average pixel value of the candidate pixels included in the preset image region as the average pixel value; if the average pixel value does not meet the requirements, then the preset image region is determined not to correspond to a pupil. Specifically, for a pixel in the image, if the directions of all O vectors of this pixel are either away from the pixel or towards the pixel, then this pixel is determined to be a candidate pixel, where O is a positive integer greater than or equal to 2. In an eye image, the pixel value of the pupil region is lower than the pixel value of its surrounding region. Therefore, corresponding to the definition of the vector direction of the pixel, the directions of each vector of the pupil region pixel are either away from the pixel or towards the pixel. For example, for pixel (m, n), if the direction of the vector is defined as: vector D If the value is greater than 0, then the vector points from pixel (m,n) to pixel (m). L ,n L ), vector D If the value is less than 0, then the vector is from pixel (m) L ,n L If a vector points to pixel (m,n), then if the directions of all vectors of pixel (m,n) are all pointing away from the pixel (i.e., all vectors are pointing outwards), then pixel (m,n) is considered a candidate pixel. Alternatively, if the direction of a vector is defined as: vector... D If the value is greater than 0, then the vector is from pixel (m) L ,n L) points to pixel (m,n), vector D If the value is less than 0, then the vector points from pixel (m,n) to pixel (m). L ,n L If the directions of all vectors of pixel (m,n) are all pointing towards the pixel itself, that is, all vectors are pointing inward, then pixel (m,n) is considered a candidate pixel.
[0114] The pixel values in the pupil region are lower than those in its surrounding areas. Therefore, if a preset image region corresponds to a pupil, the average pixel value of its candidate pixels is relatively small. Based on this, if the average pixel value of the candidate pixels in the preset image region does not meet the requirements, the preset image region is considered not to correspond to a pupil. Optionally, it can be determined whether the average pixel value grayMean of the preset image region is within a third preset range. If not, the preset image region is determined not to correspond to a pupil. Although the pixel values in the pupil region are relatively small, they are not close to 0. Therefore, if the calculated average pixel value grayMean is within the third preset range, the preset image region may be a pupil region; otherwise, it is determined not to be a pupil region. The third preset range can be less than the upper threshold threshTop and greater than the lower threshold threshDown.
[0115] Optionally, a decision parameter `value` can be defined, where `value = grayMean * angleMean`. For each preset image region selected from the image, the decision parameter `value` for each preset image region is obtained, and the preset image region with the smallest decision parameter `value` corresponds to the pupil. Thus, the pupil region is located in the image to be processed.
[0116] Preferably, the preset image region can be a candidate image block that may correspond to a pupil, initially selected from the image. In this embodiment, the method for initially selecting candidate image blocks corresponding to pupils from the image is not limited; it can be manual selection of candidate image blocks, or some image processing methods can be used to initially select regions that may contain pupils from the image as candidate image blocks. As an optional implementation, the preset image region can be selected from the image using the following method, including the following steps:
[0117] S21: For each pixel of the image, if the directions of all O vectors of this pixel are either away from this pixel or towards this pixel, then this pixel is determined as a candidate pixel, where O is a positive integer greater than or equal to 2.
[0118] Preferably, in order to more intuitively reflect the direction of the vector, this embodiment maps the direction of the vector to a numerical value and represents it in the form of an image, which is convenient for observation and processing. Specifically: for any pixel in the image, based on the O vector maps imageFi (1≤i≤0), it can be determined whether to include this pixel as a candidate pixel. For example, if all O vectors corresponding to pixel (m,n) are pointing outwards, and the value corresponding to this pixel in the O vector maps is greater than 0, for example, its value can be set to 1, then pixel (m,n) is a candidate pixel for the pupil.
[0119] For example, a candidate region map imageCandidate with the same size as the image to be processed imageBlur can be defined, and O vector maps imageFi (1≤i≤O) can be traversed. If all of imageFi(m,n) (1≤i≤O) are greater than 0, then pixel (m,n) is determined as a candidate pixel. To make it easier to distinguish in the image, the value of imageCandidate(m,n) can be set to 255; if not all of imageFi(m,n) (1≤i≤O) are greater than 0, then pixel (m,n) is not a candidate pixel, and the value of imageCandidate(m,n) can be set to 0.
[0120] S22: Obtain the connected region formed by multiple candidate pixels, and take the preset range region containing the connected region as the preset image region.
[0121] If multiple candidate pixels are connected, the connected components they form are obtained, and the preset range region containing the connected component is used as the preset image region, which is then used as the candidate region for the pupil. Optionally, the bounding rectangle of the obtained connected component can be used as the preset image region, or other forms of range regions containing the connected component can be used as the preset image region. For example, the obtained candidate region image imageCandidate can be detected using the findContours algorithm. For example, refer to Figures 8(a) and 8(b), which are two images obtained in a specific example where the preset image region has been detected.
[0122] The method described above filters out a preset image region from the image, achieving coarse localization of the pupil region. However, in real-world imaging environments, various interferences, such as those caused by eyebrows or other external objects, can result in localized dark areas similar to the pupil region in the acquired image. Therefore, multiple candidate regions may be detected in a single image. Thus, the accurate pupil region needs to be selected from the coarsely located candidate regions—the preset image regions filtered out using the method described above.
[0123] Since pupils in images do not exist in extremely large or small areas, preset image regions that are clearly not pupils can be excluded based on their size, thus accelerating pupil localization. Optionally, the determined preset image regions can be filtered using the following method: obtaining the bounding rectangle of the preset image region; if the geometric parameters of the bounding rectangle are not within a first preset range, the preset image region is excluded. For the determined preset image region, the geometric parameters of the bounding rectangle, such as length, width, area, or diagonal length, are obtained; if the geometric parameters of the bounding rectangle are not within a corresponding preset range, the preset image region is considered not to be a pupil region and is excluded. In other embodiments, other methods can also be used to filter preset image regions based on their size; those based on the same principle as the method in this embodiment are also within the scope of protection of this invention.
[0124] Optionally, the identified preset image region can be filtered using the following methods, including the following steps:
[0125] S31: Obtain the number of pixels in the preset image region whose accumulated vector belongs to each directional interval. For the preset image region, traverse each pixel sequentially and count the number of pixels belonging to each directional interval.
[0126] S32: For any direction interval of the preset image region, obtain the percentage of pixels in the preset image region whose cumulative vector belongs to this direction interval. If the percentage of pixels in at least one direction interval of the preset image region is less than or equal to a first threshold, then exclude the preset image region.
[0127] For any directional interval within the preset image region, the percentage of pixels belonging to that directional interval in the accumulated vector is obtained based on the number of pixels belonging to that directional interval and the total number of pixels in the preset image region. This percentage is the ratio of the number of pixels belonging to that directional interval in the accumulated vector to the total number of pixels in the preset image region. If the percentage of pixels in at least one directional interval within the preset image region is less than or equal to a first threshold, the preset image region is excluded. Since the percentage of pixels in each directional interval will not be too low or too high for the pupil region, this method excludes preset image regions that clearly do not correspond to the pupil.
[0128] Further preferably, for the determined preset image region, it can be determined whether the preset image region corresponds to the pupil by combining the uniformity of the distribution of mapping vectors in each directional interval of the preset image region and the pixel ratio in each directional interval. The uniformity of the distribution of mapping vectors can be determined by referring to the aforementioned step S14, excluding preset image regions whose uniformity does not meet the requirements, and excluding preset image regions whose pixel ratio in each directional interval does not meet the requirements.
[0129] Then, the preset image regions that remain after filtering are comprehensively evaluated by combining the average value of each absolute difference calculated based on the preset image regions and the uniformity of the pixel number ratio in each directional interval. Weights can be assigned to the average value of each absolute difference calculated based on the preset image regions and the uniformity of the pixel number ratio in each directional interval of the preset image regions. The smaller the average value of each absolute difference and the more uniform the pixel number ratio in each directional interval of the preset image regions, the more likely the preset image regions are to be pupils. Therefore, the preset image regions with the best comprehensive results calculated based on the set weights can be identified as pupils.
[0130] More preferably, before obtaining the average position of pixels in the preset image region whose accumulated vectors belong to the same directional interval and establishing the mapping vector for any directional interval in step S13, the following process can be performed, including the following steps:
[0131] S41: Obtain the outer rectangle of the preset image region. In the image, take the center of the outer rectangle of the preset image region as the center, the length of the third preset multiple of the length of the outer rectangle of the preset image region as the length, and the width of the fourth preset multiple of the width of the outer rectangle of the preset image region as the width, and cut out an image block as a blurred image block.
[0132] For the preset image region `blockCandidate`, obtain its bounding rectangle based on the length `w`, width `h`, and coordinates of the top-left corner (x, y). rect ,y rect The image block is extracted with the center of its outer rectangle (xrect+w / 2, yrect+h / 2) as the center, the length of which is a third preset multiple of the length of its outer rectangle, and the width of which is a fourth preset multiple of the width of its outer rectangle. The extracted image block is used as the blurred image block blockBlurLocal.
[0133] In this embodiment, the values of the third and fourth preset multiples are not limited. The values of the third and fourth preset multiples can be the same or different, and can be set according to the detection requirements in practical applications. For example, in a specific instance, the values of the third and fourth preset multiples can both be 2.
[0134] In this embodiment, if the operation of "cropping" an image block specifically involves cutting the image block and extracting it separately from the original image, then an image block larger than the preset image region and encompassing the preset image region is cropped from the image. This cropped image block includes pixels surrounding the preset image region, facilitating the calculation of the pixel vectors of the preset image region. If an image block larger than the preset image region and encompassing the preset image region is not cropped from the image to obtain the directional interval distribution map of the preset image region, and instead the pixel vectors of the preset image region are calculated separately, the surrounding pixels cannot be obtained, leading to inaccurate directional interval distribution maps of the preset image region. If the operation of "cropping" an image block specifically involves selection, i.e., only a portion of the original image is selected as the preset image region, then the surrounding pixels are still on the image. Therefore, the third and fourth preset multiples can also be set to 1, meaning that subsequent operations are performed directly on the original image at the original size of the image block, without affecting the accuracy of the positioning.
[0135] S42: Establish M vectors for the pixels of the blurred image block.
[0136] For any pixel in a blurred image patch, M vectors can be created using the method described above for creating M vectors from pixels. Optionally, for a blurred image patch, M filter kernels can be defined, and the blurred image patch can be processed using the M filter kernels to obtain M vector maps of the blurred image patch. The size parameter L of the filter kernel is determined by the width w and length h of the bounding rectangle of the preset image region, and the size parameter L of the filter kernel corresponds to the preset number of vectors when creating the vectors.
[0137] S43: For a pixel of the blurred image block, obtain the sum of the M vectors of the pixel, and determine the direction interval to which the sum of the vectors of the pixel belongs, to obtain the direction interval distribution map of the blurred image block.
[0138] For any pixel in a blurred image patch, obtain the sum of the M vectors of this pixel based on the M vectors of this pixel. Determine the direction interval to which the sum of the sum of the M vectors of this pixel belongs based on the direction of this sum of the M vectors.
[0139] The image processing method described above can be used to process the blurred image block to obtain the vector map imageLocalFi (1≤i≤M) of the blurred image block, and to obtain the directional interval distribution map of the blurred image block based on the vector map imageLocalFi (1≤i≤M).
[0140] S44: In the directional interval distribution map of the blurred image block, the directional interval distribution map of the preset image region is obtained by taking the center of the blurred image block as the center, the length of the outer rectangle of the preset image region as the length, and the width of the outer rectangle of the preset image region as the width. Based on the directional interval distribution map of the preset image region, the average position of the pixels in the preset image region whose accumulated vectors belong to the same directional interval is obtained.
[0141] Using the center of the directional interval distribution map of the blurred image patch as the center, and taking the length w and width h of the outer rectangle of the preset image region as the length and width as the width, an image patch with a rectangle of length w and width h is extracted and used as the directional interval distribution map imageVectorLocal of the preset image region.
[0142] If the orientation interval distribution map of a preset image region is obtained from the orientation interval distribution map of the image, since the orientation interval distribution map of the image is global, it is inevitable that the detection will be ineffective when dealing with pupils of different sizes. This embodiment obtains the orientation interval distribution map of the preset image region adaptively according to the above method, which can adapt to pupils of different sizes and helps to improve the accuracy of pupil positioning.
[0143] In this implementation, for a preset image region, the center position of the preset image region can be determined based on the directional interval distribution map imageVectorLocal obtained by the above method. Optionally, the center position (x...) of the preset image region... center ,y center The value () can be the center position of the directional interval distribution map of the preset image region, imageVectorLocal, and can be represented as (imageVectorLocal.cols / 2, imageVectorLocal.rows / 2). Alternatively, the center position of the preset image region (x... center ,y center Alternatively, it can be the intersection point of the directional interval distribution in the imageVectorLocal directional interval distribution map of the preset image region. The intersection point of the directional interval distribution in the imageVectorLocal directional interval distribution map can be used as the center position of the preset image region.
[0144] Based on the directional interval distribution map imageVectorLocal of the preset image region obtained by the above method, the number of pixels belonging to each directional interval in the preset image region, the percentage of pixels in each directional interval, and the average position of pixels in each directional interval included in the preset image region can be counted. For example, this specifically includes: traversing the directional interval distribution map imageVectorLocal, counting the number of pixels in each directional interval and the sum of the corresponding pixel coordinates; then, calculating the percentage of pixels in each directional interval and the average coordinates of the pixels in each directional interval.
[0145] For a preset image region, a mapping vector can be established with the center position of the preset image region as the starting point and the average position corresponding to the direction interval as the ending point. The mapping vector is represented as (x i ,y i ), (x i ,y i )=(x center -point[i].x,y center -point[i].y), where point[i].x represents the average x-coordinate of pixels belonging to the i-th direction interval, and point[i].y represents the average y-coordinate of pixels belonging to the i-th direction interval.
[0146] Mapping vector (x) i ,y i The direction of ) is represented as:
[0147]
[0148] The direction corresponding to angle[i] represents the mapping vector (x). i ,y i (direction).
[0149] Based on the method described above, the image block corresponding to the pupil is determined in the image. That is, after the pupil region is determined in the image, the center of the pupil can be located based on the determined pupil region.
[0150] Optionally, the bounding rectangle of a preset image region corresponding to the pupil can be obtained, and the center of the bounding rectangle of the preset image region can be determined as the pupil center. This can be represented as:
[0151]
[0152] Where blockCandidate.cols and blockCandidate.rows represent the width and length of the bounding rectangle that determines the preset image region for the corresponding pupil, respectively. block ,y blockThe expression indicates that the coordinates of the upper left corner of the preset image region corresponding to the pupil are determined in the image to be processed.
[0153] The position of the pupil center obtained using the method described above can be considered a coarse position, which can be used to further obtain the precise position of the pupil center. Optionally, the precise position of the pupil center can be obtained using the following method, including the following steps:
[0154] S51: For the preset image region corresponding to the pupil, obtain the bounding rectangle of the preset image region.
[0155] S52: In the image, an image block is extracted with the center of the outer rectangle of the preset image region as the center, the length as a first preset multiple of the length of the outer rectangle of the preset image region as the length, and the width as a second preset multiple of the width of the outer rectangle of the preset image region as the width, and is used as the search image block.
[0156] The cropping method here is similar to the aforementioned method for cropping blurred image blocks; it can be done by cropping and extracting, or by selecting directly from the original image.
[0157] In this embodiment, the cropping and extraction method is used as an example. In the image, (x rough ,y rough Centered on a target area, crop an image block whose width and height are respectively a first preset multiple of the length of the bounding rectangle of the target image area and a second preset multiple of the width of the bounding rectangle of the target image area. The values of the first and second preset multiples are not limited; they can be the same or different, and can be set according to detection requirements in practical applications. For example, in a specific instance, both the first and second preset multiples can be 2, that is, a cropped image block is created centered on a target area (x...). rough ,y rough Centered on ), crop out image blocks blockB of size blockCandidate.cols*2 and blockCandidate.rows*2.
[0158] S53: Retrieve pixels whose pixel values are within a second preset range from the search image block, obtain the connected components formed by the retrieved pixels, and select the largest connected component among them.
[0159] Preferably, the second preset range can be greater than or equal to the difference between the preset average pixel value and the second threshold, and less than or equal to the sum of the preset average pixel value and the second threshold; wherein, the preset average pixel value is the average pixel value of the candidate pixels included in the preset image region. For example, a blank image block blockFinal with the same size as blockB can be defined. The search can start from the center of image block blockB and proceed outwards, or image block blockB can be traversed sequentially. This can be performed according to the following formula:
[0160]
[0161] Connected components are detected in the final image block blockFinal. One or more connected components may be obtained, with the largest connected component corresponding to the pupil. For example, refer to Figures 9(a) and 9(b). Figure 9(a) shows the preset image region corresponding to the pupil detected in a specific example, and Figure 9(b) is a schematic diagram of the connected components obtained after searching the preset image region based on pixel values.
[0162] S54: The largest connected region is mapped to the pupil region, and the pupil center is determined based on the largest connected region.
[0163] In this embodiment, the method for determining the pupil center based on the largest connected component is not limited. Optionally, the center of the bounding rectangle of the largest connected component can be used as the pupil center. This can be represented as:
[0164]
[0165] Among them, (x final ,y final (x) indicates the position of the center of the pupil. block ,y block ) represents the position of the top-left pixel of the bounding rectangle of the largest connected component, and rect.width and rect.height represent the width and height of the bounding rectangle of the largest connected component, respectively.
[0166] If the pupils in the image are perfectly symmetrical, this method can accurately locate the center of the pupil. However, if the eyes are half-closed, this method cannot accurately locate the center of the pupil.
[0167] Optionally, edge points can be detected for the largest connected component, and ellipse fitting can be performed on the obtained edge points, with the center of the resulting ellipse as the pupil center. Specifically, multiple iterations can be performed, each time selecting a subset of edge points for fitting, and substituting the remaining edge points into the fitted ellipse equation. If the calculated error for a point is less than a threshold, then that point is considered an interior point; otherwise, it is considered an exterior point. The center of the ellipse fitted in the iteration with the most interior points is selected as the pupil center. This can be represented as:
[0168]
[0169] Among them, (x final ,y final (x) indicates the position of the center of the pupil. block ,y block (x) represents the position of the top-left pixel of the bounding rectangle of the largest connected component. ellipse y dllipse ) represents the relative position of the ellipse center within the outer rectangle of the largest connected region.
[0170] Accordingly, this embodiment also provides a pupil positioning device, including:
[0171] Memory, used to store computer programs;
[0172] A processor is used to implement the pupil localization method described above when executing the computer program.
[0173] The pupil localization device in this embodiment establishes a vector reflecting the difference in pixel values between a pixel and its surrounding pixels based on the pixel values of the image. For a preset image region, it determines whether the preset image region corresponds to the pupil based on the directional interval distribution of the pixel vectors in the preset image region, thereby locating the pupil. This invention can reduce the influence of complex and diverse environments in real-world scenarios, as well as the influence of head movement or eye movement responses, and can accurately locate the pupil under various complex conditions.
[0174] Optionally, the pupil positioning device in this embodiment may include, but is not limited to, a processor, a memory, a display, or a human-computer interaction device. The memory is used to store a computer program, and the processor is used to execute the computer program to implement the steps of the pupil positioning method described above. The human-computer interaction device may include, but is not limited to, a keyboard, a mouse, or a touch screen.
[0175] The pupil positioning method and apparatus provided by the present invention have been described in detail above. Specific examples have been used to illustrate the principles and implementation methods of the present invention. The descriptions of the embodiments above are only for the purpose of helping to understand the method and core ideas of the present invention. It should be noted that those skilled in the art can make several improvements and modifications to the present invention without departing from the principles of the present invention, and these improvements and modifications also fall within the protection scope of the claims of the present invention.
Claims
1. A pupil localization method, characterized in that, include: M vectors are established for the pixels to be processed in the image. Each of the M vectors corresponds to a different angle. Each vector represents the difference in pixel value between the current pixel and the L pixels at the angle corresponding to the current vector. M and L are both positive integers greater than or equal to 2. The magnitude of the vector represents the sum of the differences in pixel value between the current pixel and the L pixels at the angle corresponding to the current vector. The direction of the vector is determined according to the angle corresponding to the current vector and the sign of the sum of the differences in pixel value. Select a preset image region of the image. For each pixel in the preset image region, obtain the sum of M vectors of each pixel and determine the direction interval to which the sum of vectors belongs. The direction interval is N intervals that are evenly divided within the circumference, where N is a positive integer greater than or equal to 2. Obtain the average position of pixels in the preset image region whose accumulated vectors belong to the same directional interval, and establish a mapping vector for any directional interval using the preset position and the average position in the preset image region as endpoints; Based on the uniformity of the distribution of the mapping vectors in each directional interval of the preset image region, it is determined whether the preset image region corresponds to the pupil.
2. The pupil localization method according to claim 1, characterized in that, Determining whether the preset image region corresponds to a pupil based on the uniformity of the distribution of the mapping vectors in each directional interval of the preset image region includes: Calculate the angle difference between the mapping vectors of any two adjacent directional intervals of the preset image region. The angle difference is the angle difference between the mapping vector of the latter directional interval and the mapping vector of the former directional interval in the clockwise / counterclockwise direction of the two adjacent directional intervals. If the sign of at least one of the calculated angle differences is different from that of the other angle differences, then it is determined that the preset image region does not correspond to the pupil.
3. The pupil localization method according to claim 1, characterized in that, Determining whether the preset image region corresponds to a pupil based on the uniformity of the distribution of the mapping vectors in each directional interval of the preset image region includes: Calculate the angle difference between the mapping vectors of any two adjacent directional intervals in the preset image region. The angle difference is the angle difference between the mapping vector of the latter directional interval and the mapping vector of the former directional interval in the clockwise / counterclockwise direction of the two adjacent directional intervals. Calculate the absolute difference between any of the angle differences and the interval value of the direction interval, or calculate the absolute difference between each of the angle differences and the interval value of the direction interval and calculate the average of the obtained absolute differences; If the absolute difference between any of the angle differences and the interval value of the direction interval does not meet the requirements, then it is determined that the preset image region does not correspond to the pupil; or if the average value of the obtained absolute differences does not meet the requirements, then it is determined that the preset image region does not correspond to the pupil.
4. The pupil localization method according to claim 1, characterized in that, The preset image region selected from the image includes: For each pixel of the image, if the directions of all O vectors of this pixel are either away from this pixel or towards this pixel, then this pixel is determined as a candidate pixel, where O is a positive integer greater than or equal to 2. Obtain a connected region formed by multiple candidate pixels, and use a preset range region containing the connected region as the preset image region.
5. The pupil localization method according to claim 4, characterized in that, Also includes: Calculate the average pixel value of the candidate pixels included in the preset image region, and use it as the pixel value mean; If the average pixel value does not meet the requirements, then the preset image region does not correspond to the pupil.
6. The pupil localization method according to claim 1, characterized in that, Before obtaining the average position of pixels in the preset image region whose accumulated vectors belong to the same directional interval, the method further includes: Obtain the number of pixels in each directional interval whose accumulated vector of pixels in the preset image region belongs to each directional interval; For any directional interval of the preset image region, obtain the percentage of pixels in the preset image region whose accumulated vector belongs to this directional interval. If the percentage of pixels in at least one directional interval of the preset image region is less than or equal to a first threshold, then the preset image region is excluded.
7. The pupil localization method according to claim 1, characterized in that, The step of obtaining the sum of M vectors for each pixel in the preset image region includes: Obtain the size information of the preset image region, and determine the L value when establishing M vectors for the pixels in the preset image region based on the size information of the preset image region, so as to obtain the cumulative vector of the M vectors for each pixel.
8. The pupil localization method according to claim 1, characterized in that, Also includes: For the preset image region corresponding to the pupil, obtain the bounding rectangle of the preset image region; In the image, an image block is cropped with the center of the outer rectangle of the preset image region as the center, the length as a first preset multiple of the length of the outer rectangle of the preset image region, and the width as a second preset multiple of the width of the outer rectangle of the preset image region as the width, and this is used as the search image block; Pixels whose pixel values are within a second preset range are retrieved from the search image block, the connected components formed by the retrieved pixels are obtained, and the largest connected component is selected. The pupil center is determined by mapping the largest connected component to the pupil region.
9. The pupil localization method according to any one of claims 1-8, characterized in that, Before obtaining the average position of pixels whose accumulated vectors belong to the same direction interval in the preset image region, the method further includes: obtaining the bounding rectangle of the preset image region; if the geometric parameters of the bounding rectangle of the preset image region are not within a first preset range, then the preset image region is excluded.
10. A pupil positioning device, characterized in that, include: Memory, used to store computer programs; A processor for executing the computer program to implement the pupil localization method as described in any one of claims 1 to 9.
Citation Information
Patent Citations
Pupil center positioning method and pupil center positioning device
CN104809458A
Pupil positioning device and method and sight line tracking equipment
CN107808397A