A Phase Difference Detection Method, Device, Electronic Device, and Storage Medium
By performing block processing and convolutional operations on the PD pixel rows of the graphics sensor, the problem of opaque phase difference detection in the prior art is solved, accurate phase difference detection is achieved, and focus accuracy is improved.
Patent Information
- Application Number
- CN202210478827.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-28
- Publication Date
- 2025-07-18
- Estimated Expiration
- 2042-04-28
AI Technical Summary
In the prior art, the phase difference original data detection method is opaque, resulting in inaccurate focus.
The PD pixel rows of the graphics sensor are processed in blocks, a data block is selected as the convolution kernel, and the convolution operation is performed based on the preset phase difference offset, and the phase difference detection result is obtained by fitting the difference data set.
Accurate detection of phase difference is achieved, and the accuracy and effect of focus is improved.
Smart Images

Figure CN114882117B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of image processing, and particularly relates to a phase difference detection method, device, electronic device and storage medium. Background Art
[0002] When a user takes a photo through an electronic device, the electronic device can perform focusing in a phase difference auto focus (PDAF) manner to obtain a relatively clear picture. When the electronic device performs focusing, it can calculate the phase difference through the phase difference (PD) detection pixels provided on the sensor, and convert the phase difference into the moving distance of the motor in the lens module, so as to determine the focus point according to the moving distance to achieve focusing.
[0003] However, in the prior art, focusing is usually performed according to the original phase difference data provided by the image sensor, and the detection method of the original phase difference data is not transparent. Summary of the Invention
[0004] The purpose of the present invention is to provide a phase difference detection method, device, electronic device and storage medium, aiming to provide a brand-new phase difference detection method.
[0005] On the one hand, the present invention provides a phase difference detection method, and the method includes the following steps:
[0006] Perform block processing on the left PD data row and the right PD data row in the PD pixel rows of the graphic sensor in the same manner respectively to obtain a plurality of PD data block pairs;
[0007] Select a data block in each of the PD data block pairs as a convolution kernel, and based on a preset phase difference offset, use the convolution kernel to perform convolution operation on the PD data at the same position in the PD data row where the other data block is located to obtain a difference data set corresponding to each of the PD data block pairs;
[0008] Fit the difference data set, and according to the fitting result and the phase difference offset, obtain the phase difference between the left and right PD data blocks in each of the PD data block pairs;
[0009] Generate a phase difference detection result based on the phase differences of each of the obtained PD data block pairs.
[0010] Preferably, before the step of selecting a data block in each of the PD data block pairs as a convolution kernel and performing convolution operation on the PD data at the same position in the PD data row where the other data block is located based on a preset phase difference offset, it further includes:
[0011] Denoise each of the PD data block pairs using a preset filter to obtain corresponding second PD data block pairs, where the filter is a Gaussian filter;
[0012] The step of selecting one data block from each of the PD data block pairs as a convolution kernel and performing a convolution operation on the PD data at the same position in the PD data row where the other data block is located based on a preset phase difference offset includes;
[0013] Select one data block from each of the second PD data block pairs as a convolution kernel and perform a convolution operation on the PD data at the same position in the PD data row where the other data block is located based on a preset phase difference offset.
[0014] The step of performing a convolution operation on the PD data at the same position in the PD data row where the other data block is located based on a preset phase difference offset includes:
[0015] Taking the other data block as a reference in the PD data row where the other data block is located, move forward and backward by the distance of the phase difference offset respectively to obtain PD data within the extended range;
[0016] Perform a convolution operation on the obtained PD data using the convolution kernel.
[0017] Preferably, the step of performing a convolution operation on the obtained PD data using the convolution kernel includes:
[0018] Align the starting point of the convolution kernel with each pixel in the PD data in sequence and perform convolution to obtain a difference data set corresponding to each of the PD data block pairs.
[0019] Further preferably, the step of aligning the starting point of the convolution kernel with each pixel in the PD data in sequence and performing convolution includes:
[0020] Each time, align the convolution kernel with the corresponding sized pixel to be convolved in the PD data and perform convolution to obtain the difference data for that time, and move the convolution kernel so that the convolution kernel is aligned with the next corresponding sized pixel to be convolved in the PD data and perform convolution until the difference data set corresponding to the PD data block pair is obtained.
[0021] Preferably, the step of fitting the difference data set includes:
[0022] Perform a quadratic equation fitting on the difference data set using the least squares method to obtain a corresponding quadratic function.
[0023] Preferably, the step of obtaining the phase difference between the left and right PD data blocks in each PD data block pair according to the fitting result and the phase difference offset includes:
[0024] Obtaining a target pixel point corresponding to the extreme value of the quadratic function, and subtracting the phase difference offset from the pixel offset of the target pixel point to obtain the phase difference between the left and right PD data blocks in each PD data block pair.
[0025] On the other hand, the present invention provides a phase difference detection device, which includes:
[0026] A data block division unit for dividing the left PD data row and the right PD data row in the PD pixel row of the graphic sensor in the same manner respectively to obtain a plurality of PD data block pairs;
[0027] A data convolution unit for selecting a data block as a convolution kernel in each PD data block pair, and performing a convolution operation on the PD data at the same position in the PD data row where the other data block is located based on a preset phase difference offset to obtain a difference data set corresponding to each PD data block pair;
[0028] A phase difference acquisition unit for fitting the difference data set, and obtaining the phase difference between the left and right PD data blocks in each PD data block pair according to the fitting result and the phase difference offset; and
[0029] A result generation unit for generating a phase difference detection result based on the phase difference of each obtained PD data block pair.
[0030] On the other hand, the present invention further provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the above method are implemented.
[0031] On the other hand, the present invention further provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the steps of the above method are implemented.
[0032] The present invention processes the left PD data row and the right PD data row in the PD pixel rows of the graphic sensor in the same manner respectively to obtain a plurality of pairs of PD data blocks. In each pair of PD data blocks, one data block is selected as a convolution kernel. Based on a preset phase difference offset, the convolution kernel is used to perform a convolution operation on the PD data at the same position in the PD data row where the other data block is located, so as to obtain a difference data set corresponding to each pair of PD data blocks. The difference data set is fitted, and according to the fitting result and the phase difference offset, the phase difference between the left and right PD data blocks in each pair of PD data blocks is obtained. Based on the phase differences of each pair of PD data blocks obtained, a phase difference detection result is generated, thereby realizing accurate detection of the phase difference. Description of the Drawings
[0033] Figure 1A is the implementation flowchart of the phase difference detection method provided in the first embodiment of the present invention;
[0034] Figure 1B is the layout schematic diagram of the PD pixels of the sony IMX455 sensor provided in the first embodiment of the present invention;
[0035] Figure 1C is the pixel information example diagram of the pair of PD data blocks provided in the first embodiment of the present invention;
[0036] Figure 1D is provided in the first embodiment of the present invention Figure 1C The pixel information example diagram of the convolution kernel in the pair of PD data blocks and the PD data to be convolved obtained after extension;
[0037] Figure 1E is the process example diagram of aligning the convolution kernel with the corresponding sized pixels to be convolved in the PD data provided in the first embodiment of the present invention;
[0038] Figure 1F is the pixel information example diagram of the convolution kernel and the PD data to be convolved obtained after extension when the convolution kernel starts to move in the PD data block provided in the first embodiment of the present invention;
[0039] Figure 1G is the pixel information example diagram of the convolution kernel and the PD data to be convolved obtained after extension when the convolution kernel finishes moving in the PD data block provided in the first embodiment of the present invention;
[0040] Figure 1H is the distribution example diagram of the difference data set corresponding to the pair of PD data blocks provided in the first embodiment of the present invention;
[0041] Figure 1I is provided in the first embodiment of the present invention Figure 1D The pixel information example diagram of the convolution kernel and the PD data to be convolved obtained after extension after filtering in;
[0042] Figure 2 It is a schematic structural diagram of the phase difference detection device provided in the second embodiment of the present invention; and
[0043] Figure 3 It is a schematic structural diagram of the electronic device provided in the third embodiment of the present invention. Detailed implementation manners
[0044] In order to make the objectives, technical solutions and advantages of the present invention clearer and more understandable, the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.
[0045] The following describes the specific implementation of the present invention in detail with reference to specific embodiments:
[0046] Example 1:
[0047] Figure 1A The implementation process of the phase difference detection method provided in the first embodiment of the present invention is shown. For the convenience of description, only the parts related to the embodiments of the present invention are shown and are described in detail as follows:
[0048] In step S101, the left PD data row and the right PD data row in the PD pixel row of the image sensor are respectively processed in the same manner to obtain a plurality of pairs of PD data blocks.
[0049] The embodiments of the present invention are applicable to electronic devices, and the electronic devices can be terminal devices such as mobile phones, cameras, tablet computers, wearable devices, vehicle-mounted devices, laptop computers, etc. The specific types of the electronic devices in the embodiments of the present application are not limited in any way.
[0050] In the embodiments of the present invention, after obtaining pixel data from the image sensor, the PD pixel row can be extracted, and the left and right pixels of each PD pixel row are separated to obtain the corresponding original PD data pair, that is, the original PD data pair includes the original left PD data row and the right PD data row. Then, the left PD data row and the right PD data row of each PD pixel row are respectively divided into N blocks in the same manner to obtain N left PD data blocks and N right PD data blocks. Specifically, the left PD data row and the right PD data row can be equally divided into N blocks, or the left PD data row and the right PD data row can be respectively divided into N blocks in other same manners.
[0051] Taking the sony IMX455 sensor as an example, the layout of the PD pixels of the sony IMX455 sensor is as Figure 1BAs shown, there are 31 rows of PD detection pixels in the image sensor, which are evenly distributed on the imaging surface. After partitioning, 31*N left PD pixel blocks and 31*N right PD pixel blocks can be obtained. The pixel information of the PD data block pairs obtained after partitioning is as Figure 1C shown, where the abscissa represents the coordinates of the PD pixels and the ordinate represents the pixel values of the PD pixels.
[0052] In step S102, one data block in each PD data block pair is selected as the convolution kernel. Based on the preset phase difference offset, the convolution kernel is used to perform a convolution operation on the PD data at the same position in the PD data row where the other data block is located, and a difference data set corresponding to each PD data block pair is obtained;
[0053] In the embodiment of the present invention, the convolution kernel is one data block of the PD data block pair, and the data to be convolved is the PD data at the same position in the PD data row where the other data block is located. The PD data to be convolved is obtained by expanding the other data block. Specifically, when one data block in each PD data block pair is selected as the convolution kernel, the data block selected as the convolution kernel can be the right PD data block in the PD data block pair or the left data block. At this time, the data to be convolved is the extended data block of the other data block. For example, if the data block selected as the convolution kernel is the right PD data block in the PD data block pair, the data to be convolved is located in the left PD data row where the left PD data block in the PD data block pair is located, and the data to be convolved is a data block expanded based on the left PD data block in the left PD data row.
[0054] Preferably, when obtaining the PD data to be convolved, if one data block in the PD data block pair is selected as the convolution kernel, then based on the other data block in the PD data row where the other data block is located, move forward and backward by the distance of the phase difference offset respectively to obtain the PD data within the extended range. This data is the PD data to be convolved. Among them, the phase difference offset is obtained according to the characteristics of the imaging system. For example, the phase difference interval [-PD_MAX:+PD_MAX] in pixels can be measured at a fixed focal length, where PD_MAX represents the maximum phase difference of the imaging system, and this PD_MAX is set as the phase difference offset. Therefore, preferably, when using the convolution kernel to perform a convolution operation on the PD data at the same position in the PD data row where the other data block is located, based on the other data block in the PD data row where the other data block is located, move forward and backward by the distance of the phase difference offset respectively to obtain the PD data within the extended range, and use the convolution kernel to perform a convolution operation on the obtained PD data. As an example, Figure 1D shows Figure 1C the convolution kernel in the PD data block pair and the PD data to be convolved obtained after expansion.
[0055] Further, when performing convolution operations on the obtained PD data using a convolution kernel, align the starting point of the convolution kernel with each pixel in the PD data in sequence and perform convolution to obtain the difference data set corresponding to each PD data block. Specifically, when aligning the starting point of the convolution kernel with each pixel in the PD data in sequence and performing convolution, each time align the convolution kernel with the corresponding sized pixels to be convolved in the PD data and perform convolution to obtain the difference data for that time. Move the convolution kernel so that the convolution kernel is aligned with the next corresponding sized pixels to be convolved in the PD data and perform convolution until the difference data set corresponding to the PD data block is obtained. As an example, Figure 1E shows the process of aligning the convolution kernel with the corresponding sized pixels to be convolved in the PD data, where K1 to Kn represent the convolution kernel and D1 to Dm represent the PD data to be convolved. Correspondingly, Figure 1F shows the pixel information of the convolution kernel and the extended PD data to be convolved when the convolution kernel starts to move in the PD data block. Figure 1G shows the pixel information of the convolution kernel and the extended PD data to be convolved when the convolution kernel finishes moving in the PD data block. Figure 1H shows the distribution of the difference data set corresponding to the PD data block pair.
[0056] Specifically, when performing convolution on the convolution kernel and the corresponding sized pixels to be convolved in the PD data each time, the formula can be used for convolution, where kernel i represents the convolution kernel for that time, D2 i represents the PD data to be convolved for that time, represents the difference data for that time, and n represents the size of the convolution kernel.
[0057] Considering the imperfections of the imaging system, transmission medium, recording device, etc., digital images are often contaminated by various noises during their formation, transmission, and recording processes. Preferably, before selecting a data block as the convolution kernel in each PD data block pair, a preset filter is used to denoise each PD data block pair to remove noise interference. Specifically, the preset filter can be used to denoise the left PD data block and the right PD data block in each PD data block pair respectively. As an example, Figure 1I is Figure 1DThe pixel information after filtering the convolution kernel in the middle and the convolved PD data after expansion, where the abscissa represents the coordinates of the PD pixels and the ordinate represents the pixel values of the PD pixels. After obtaining the denoised PD data block pairs, in each PD data block pair, one data block is selected as the convolution kernel, and then, based on a preset phase difference offset, the convolution kernel is used to perform a convolution operation on the PD data at the same position in the PD data row where the other data block is located. Among them, the aforementioned filter can be a mean filter or a median filter, etc. Preferably, the filter is a Gaussian filter to ensure that the edge direction of the original PD data block is not changed while ensuring the characteristics of subsequent feature points and edges, thereby improving the accuracy of subsequent phase difference detection.
[0058] In step S103, the difference data set is fitted, and according to the fitting result and the phase difference offset, the phase difference between the left and right PD data blocks in each PD data block pair is obtained;
[0059] In the embodiment of the present invention, by fitting the difference data set, the best matching position of the convolution kernel in the convolved data is obtained, and then, according to the fitting result and the phase difference offset, the phase difference between the left and right PD data blocks in each PD data block pair is obtained.
[0060] Preferably, when fitting the difference data set, the least squares method is used to perform a quadratic equation fitting on the difference data set to obtain the corresponding quadratic function. Specifically, the feature point corresponding to the minimum value in the difference data set is obtained, and this feature point is set as the first PD pixel point. The left and right neighborhood pixel points of the first PD pixel point are obtained and set as the second and third PD pixel points respectively. The least squares method is used to perform a quadratic equation fitting on the second and third PD pixel points to obtain the corresponding quadratic function. As an example, the quadratic function can be represented by y = f(x). Further, when obtaining the phase difference between the left and right PD data blocks in each PD data block pair according to the fitting result and the phase difference offset, the target pixel point corresponding to the extreme value of the quadratic function is obtained, and the pixel offset of the target pixel point is subtracted by the phase difference offset to obtain the phase difference between the left and right PD data blocks in each PD data block pair. Specifically, calculate the x value when the quadratic function y = f(x) is at the extreme value, and the x value is the pixel offset value when the minimum difference amount is fitted. Subtract this pixel offset value by the phase difference offset to obtain the phase difference between the left and right PD data blocks in each PD data block pair.
[0061] In step S104, a phase difference detection result is generated based on the phase difference of each obtained PD data block pair.
[0062] In an embodiment of the present invention, the generated phase difference detection result is a matrix, and the elements of the matrix are the phase differences of each pair of PD data blocks. Among them, the number of rows of the matrix is equal to the number of PD pixel rows, and the number of columns of the matrix is the number of pairs of PD data blocks after block processing. Taking the above-mentioned sony's IMX455 sensor as an example, if 31*N pairs of PD data blocks are obtained after block processing, the final phase difference detection result is a matrix composed of 31*N phase differences.
[0063] Further, after obtaining the above-mentioned phase difference detection result, focusing can be performed based on the above-mentioned phase difference detection result, or depth detection can be performed based on the above-mentioned phase difference detection result.
[0064] In the present invention, the left PD data row and the right PD data row in the PD pixel row of the image sensor are respectively block-processed in the same manner to obtain a plurality of pairs of PD data blocks. In each pair of PD data blocks, a data block is selected as a convolution kernel. Based on a preset phase difference offset, the convolution kernel is used to perform a convolution operation on the PD data at the same position in the PD data row where the other data block is located, to obtain a difference data set corresponding to each pair of PD data blocks. The difference data set is fitted, and according to the fitting result and the phase difference offset, the phase difference between the left and right PD data blocks in each pair of PD data blocks is obtained. Based on the phase differences of each pair of PD data blocks obtained, a phase difference detection result is generated, thereby realizing accurate detection of the phase difference.
[0065] Example 2:
[0066] Figure 2 The structure of the phase difference detection device provided in the second embodiment of the present invention is shown. For the sake of convenience of description, only the parts related to the embodiment of the present invention are shown, including:
[0067] A data block unit 21, configured to respectively perform block processing on the left PD data row and the right PD data row in the PD pixel row of the image sensor in the same manner to obtain a plurality of pairs of PD data blocks;
[0068] A data convolution unit 22, configured to select a data block as a convolution kernel in each pair of PD data blocks, and based on a preset phase difference offset, use the convolution kernel to perform a convolution operation on the PD data at the same position in the PD data row where the other data block is located, to obtain a difference data set corresponding to each pair of PD data blocks;
[0069] A phase difference acquisition unit 23 is configured to fit the difference data set, and according to the fitting result and the phase difference offset, obtain the phase difference between the left and right PD data blocks in each pair of PD data blocks; and
[0070] A result generation unit 24, configured to generate a phase difference detection result based on the phase differences of each obtained PD data block pair.
[0071] Preferably, the phase difference detection device further includes:
[0072] A filtering unit, configured to perform denoising processing on each PD data block pair by using a preset filter.
[0073] Preferably, the data convolution unit 22 includes:
[0074] A data acquisition unit, configured to move forward and backward by a distance of the phase difference offset respectively with another data block as a reference in the PD data row where another data block is located, and acquire PD data within the expanded range.
[0075] A convolution operation unit, configured to perform convolution operation on the acquired PD data by using a convolution kernel.
[0076] Preferably, the convolution operation unit includes:
[0077] An alignment convolution unit, configured to align the starting point of the convolution kernel with each pixel in the PD data in sequence and perform convolution to obtain a difference data set corresponding to each PD data block pair.
[0078] Preferably, the alignment convolution unit includes:
[0079] A sequential convolution unit, configured to align and convolve the convolution kernel with the corresponding sized pixels to be convolved in the PD data each time to obtain the difference data for the current time, and move the convolution kernel to align and convolve the convolution kernel with the next corresponding sized pixels to be convolved in the PD data until the difference data set corresponding to the PD data block pair is obtained.
[0080] Preferably, the phase difference acquisition unit 23 includes:
[0081] A fitting unit, configured to perform quadratic equation fitting on the difference data set by using the least squares method to obtain a corresponding quadratic function.
[0082] The phase difference acquisition unit 23 further includes:
[0083] A phase difference acquisition subunit, configured to acquire a target pixel point corresponding to when the quadratic function takes an extreme value, and subtract the phase difference offset from the pixel offset of the target pixel point to obtain the phase difference between the left and right PD data blocks in each PD data block pair.
[0084] In the embodiments of the present invention, each unit of the phase difference detection device can be implemented by corresponding hardware or software units. Each unit can be an independent software or hardware unit, or can be integrated into a software or hardware unit, which is not used to limit the present invention here. The specific implementation manners of each unit of the phase difference detection device can refer to the description of the foregoing method embodiments and will not be elaborated here.
[0085] Example 3:
[0086] Figure 3 The structure of the electronic device provided in the third embodiment of the present invention is shown. For the sake of convenience of description, only the parts related to the embodiment of the present invention are shown.
[0087] The electronic device 3 in the embodiment of the present invention includes a processor 30, a memory 31, and a computer program 32 stored in the memory 31 and executable on the processor 30. When the processor 30 executes the computer program 32, the steps in the above method embodiments are implemented. For example, Figure 1A the steps S101 to S105 shown. Alternatively, when the processor 30 executes the computer program 32, the functions of each unit in the above device embodiments are implemented. For example, Figure 2 the functions of the units 21 to 25 shown.
[0088] In the embodiment of the present invention, the left PD data row and the right PD data row in the PD pixel rows of the graphic sensor are respectively processed in the same manner to obtain a plurality of PD data block pairs. In each PD data block pair, a data block is selected as a convolution kernel. Based on a preset phase difference offset, the convolution kernel is used to perform a convolution operation on the PD data at the same position in the PD data row where the other data block is located, to obtain a difference data set corresponding to each PD data block pair. The difference data set is fitted, and according to the fitting result and the phase difference offset, the phase difference between the left and right PD data blocks in each PD data block pair is obtained. Based on the phase differences of each obtained PD data block pair, a phase difference detection result is generated, thereby achieving accurate detection of the phase difference.
[0089] Example 4:
[0090] In the embodiment of the present invention, a computer-readable storage medium is provided. The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in the above method embodiments are implemented. For example, Figure 1A the steps S101 to S105 shown. Alternatively, when the computer program is executed by a processor, the functions of each unit in the above device embodiments are implemented. For example, Figure 2 the functions of the units 21 to 25 shown.
[0091] In the embodiments of the present invention, the left PD data row and the right PD data row in the PD pixel rows of the graphic sensor are respectively processed in the same manner to obtain a plurality of pairs of PD data blocks. In each pair of PD data blocks, one data block is selected as the convolution kernel. Based on a preset phase difference offset, the convolution kernel is used to perform a convolution operation on the PD data at the same position in the PD data row where the other data block is located, so as to obtain a difference data set corresponding to each pair of PD data blocks. The difference data set is fitted, and according to the fitting result and the phase difference offset, the phase difference between the left and right PD data blocks in each pair of PD data blocks is obtained. Based on the phase differences of each pair of PD data blocks obtained, a phase difference detection result is generated, thereby realizing accurate detection of the phase difference.
[0092] The computer-readable storage medium in the embodiments of the present invention may include any entity or device, recording medium that can carry computer program code, for example, memories such as ROM / RAM, magnetic disks, optical disks, flash memories, etc.
[0093] The foregoing are only the preferred embodiments of the present invention and are not intended to limit the present invention. Any modifications, equivalent replacements, and improvements made within the spirit and principles of the present invention shall be included within the protection scope of the present invention.
Claims
1. A phase difference detection method, characterized in that, The method includes the following steps: The left PD data row and the right PD data row in the PD pixel row of the graphic sensor are respectively processed in the same manner to obtain a plurality of pairs of PD data blocks; In each pair of PD data blocks, a data block is selected as a convolution kernel, and based on a preset phase difference offset, the convolution kernel is used to perform a convolution operation on the PD data at the same position in the PD data row where the other data block is located, so as to obtain a difference data set corresponding to each pair of PD data blocks; The difference data set is fitted, and according to the fitting result and the phase difference offset, the phase difference between the left and right PD data blocks in each pair of PD data blocks is obtained; A phase difference detection result is generated based on the phase difference of each pair of PD data blocks obtained; Among them, the step of using the convolution kernel to perform a convolution operation on the PD data at the same position in the PD data row where the other data block is located based on a preset phase difference offset includes: Taking the other data block as a reference in the PD data row where the other data block is located, moving forward and backward by the distance of the phase difference offset respectively to obtain the PD data within the extended range; Using the convolution kernel to perform a convolution operation on the obtained PD data includes: sequentially aligning the starting point of the convolution kernel with each pixel in the PD data and performing convolution, so as to obtain a difference data set corresponding to each pair of PD data blocks. When performing convolution on the convolution kernel and the convolved pixels of the corresponding size in the PD data each time, calculate the difference value between the aligned convolution kernel and the convolved pixels, and accumulate the absolute value of the difference value to obtain the current difference data; The step of fitting the difference data set and obtaining the phase difference between the left and right PD data blocks in each pair of PD data blocks according to the fitting result and the phase difference offset includes: Performing a quadratic equation fitting on the difference data set to obtain a corresponding quadratic function, obtaining the target pixel point corresponding to the extreme value of the quadratic function, and subtracting the phase difference offset from the pixel offset of the target pixel point to obtain the phase difference between the left and right PD data blocks in each pair of PD data blocks.
2. The method according to claim 1, characterized in that Before the step of selecting a data block as a convolution kernel in each pair of PD data blocks and using the convolution kernel to perform a convolution operation on the PD data at the same position in the PD data row where the other data block is located based on a preset phase difference offset, it further includes: Performing denoising processing on each pair of PD data blocks by using a preset filter.
3. The method according to claim 1, wherein The step of sequentially aligning the starting point of the convolution kernel with each pixel in the PD data includes: Each time the convolution kernel is aligned with the convolved pixels of the corresponding size in the PD data and convolution is performed to obtain the difference data of the current time, and the convolution kernel is moved so that the convolution kernel is aligned with the next convolved pixels of the corresponding size in the PD data and convolution is performed until the difference data set corresponding to the pair of PD data blocks is obtained.
4. A phase difference detection device, characterized in that, The device includes: A data chunking unit, configured to perform chunking processing on the left PD data row and the right PD data row in the PD pixel rows of the graphic sensor respectively in the same manner, to obtain a plurality of pairs of PD data chunks; A data convolution unit, configured to select one data chunk in each pair of PD data chunks as a convolution kernel, and based on a preset phase difference offset, use the convolution kernel to perform convolution operations on PD data at the same position in the PD data row where the other data chunk is located, to obtain a difference data set corresponding to each pair of PD data chunks; A phase difference acquisition unit, configured to fit the difference data set, and based on the fitting result and the phase difference offset, obtain the phase difference between the left and right PD data chunks in each pair of PD data chunks; and A result generation unit, configured to generate a phase difference detection result based on the phase differences of each pair of PD data chunks obtained; Wherein, when the data convolution unit performs convolution operations on PD data at the same position in the PD data row where the other data chunk is located based on a preset phase difference offset using the convolution kernel, it includes: Taking the other data chunk as a reference in the PD data row where the other data chunk is located, moving forward and backward by a distance of the phase difference offset respectively, to obtain PD data within the extended range; Using the convolution kernel to perform convolution operations on the obtained PD data, including: aligning the starting point of the convolution kernel with each pixel in the PD data in sequence and performing convolution, to obtain a difference data set corresponding to each pair of PD data chunks, and when performing convolution on the convolution kernel and the convolved pixels of the corresponding size in the PD data each time, calculating the difference value between the aligned convolution kernel and the convolved pixels, and accumulating the absolute values of the difference values to obtain the current difference data; When the phase difference acquisition unit fits the difference data set and obtains the phase difference between the left and right PD data chunks in each pair of PD data chunks based on the fitting result and the phase difference offset, it includes: Performing quadratic equation fitting on the difference data set to obtain a corresponding quadratic function, obtaining a target pixel point corresponding to when the quadratic function takes an extreme value, and subtracting the phase difference offset from the pixel offset of the target pixel point, to obtain the phase difference between the left and right PD data chunks in each pair of PD data chunks.
5. An electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 3.
6. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the steps of the method according to any one of claims 1 to 3.
Citation Information
Patent Citations
Camera module calibration method and device, electronic equipment and computer readable storage medium
CN109712192A
Method and device for acquiring phase difference and electronic equipment
CN112866548A