Absolute-position measurement method, apparatus and device, and storage medium
Through the absolute position detection method based on linear optical sensors, conversion, decoding and parabolic fitting, high-precision absolute position detection of image sensing technology is achieved, solving the problem of lack of high-precision absolute position encoding in China and providing a unified detection solution .
Patent Information
- Application Number
- PCT/CN2023/083989
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-02-20
- Filing Date
- 2023-03-27
- Publication Date
- 2024-08-29
AI Technical Summary
High-precision absolute position coding based on image sensing technology has almost not been realized in China. There are few products such as grating rulers and laser displacements. Each company's technical solutions vary widely, and there is a lack of unified absolute position detection methods.
A linear optical sensor is used to obtain the sampling data of the optical code disk. By converting it into a standard grayscale space, binarizing and decoding it, and combining it with parabola fitting to determine the offset, precise positioning of the absolute position is achieved.
It realizes high-precision absolute position detection based on image sensing technology, provides a unified method, solves the problem of lack of high-precision absolute position detection in the existing technology, and improves detection accuracy and consistency.
Smart Images

Figure CN2023083989_29082024_PF_FP_ABST
Abstract
Description
Absolute position detection method, device, equipment and storage medium
[0001] This application claims priority to the Chinese patent application filed with the China Patent Office on February 20, 2023, with application number 202310184302.8 and invention name “A method, device, equipment and storage medium for absolute position detection”, the entire contents of which are incorporated by reference into this application. Technical Field
[0002] The present invention relates to the technical field of absolute position detection, and in particular to an absolute position detection method, an absolute position detection apparatus, an absolute position detection device, and a computer-readable storage medium. Background Art
[0003] Based on their working principles, encoders can be divided into photoelectric, magnetoelectric, and contact brush types, with photoelectric and magnetoelectric types being more common. These encoders primarily count different pulse signals to represent displacement, thereby obtaining information such as rotation angle. In addition to the aforementioned methods, there are also displacement calculations based on visual images, where the captured signal is image data. The CMOS (Complementary Metal Oxide Semiconductor) or CCD (charge coupled device) sensor of this type of encoder captures an image of the absolute position-encoded code disk. The data processor then performs algorithmic processing on the captured image data to obtain absolute, high-precision position information.
[0004] Currently, there are few high-precision absolute position encoders based on image sensing technology in China. Products such as grating scales and laser displacement sensors are also relatively rare, and the technical solutions adopted by various companies vary greatly. Therefore, how to provide an absolute position detection method based on image sensing technology is an urgent problem for those skilled in the art.
[0005] Summary of the Invention
[0006] An object of the present invention is to provide an absolute position detection method that can accurately detect the absolute position based on image sensing technology; another object of the present invention is to provide an absolute position detection device, an absolute position detection equipment and a computer-readable storage medium that can accurately detect the absolute position based on image sensing technology.
[0007] To solve the above technical problems, the present invention provides an absolute position detection method, comprising:
[0008] Based on the linear optical sensor, the sampling data generated by the light source irradiating the optical code disk is obtained;
[0009] According to the actual grayscale space corresponding to each pixel point in the linear optical sensor, the sampled data is converted into standard sampled data in the same standard grayscale space;
[0010] Binarizing the standard sampling data according to a binarization threshold to obtain square wave data, and decoding the square wave data to obtain a coding sequence;
[0011] determining an initial position value according to the coding sequence;
[0012] Performing parabola fitting on the bit sequence selected from the standard sampling data according to the binarization threshold, and determining the difference between the target pixel point corresponding to the highest point of the parabola and the reference pixel point as the offset;
[0013] An absolute position is determined according to the initial position value and the offset.
[0014] Optionally, converting the sampled data into standard sampled data in the same standard grayscale space includes:
[0015] Based on proportional conversion, the actual sampling values collected by the pixel points are converted into standard sampling values in the same standard grayscale space according to the corresponding actual grayscale space to determine the standard sampling data.
[0016] Optionally, before binarizing the standard sampled data, the method further includes:
[0017] According to the sampling values of the neighborhood of the noise point, the sampling value corresponding to the noise point is adjusted.
[0018] Optionally, determining the initial position value according to the coding sequence includes:
[0019] Converting the coded sequence into a decimal number;
[0020] According to a preset coding table, the initial position value corresponding to the decimal number in the coding table is searched based on the binary search method; the coding table is a table sorted according to the size of the decimal number.
[0021] Optionally, performing parabola fitting on the bit sequence selected from the standard sampled data according to the binarization threshold, and determining the difference between the target pixel point corresponding to the highest point of the parabola and the reference pixel point as the offset includes:
[0022] Using the binarization threshold as a horizontal coordinate, determining two intersection points between a parabola formed by a bit sequence selected from the standard sampled data and the horizontal coordinate;
[0023] A pixel point corresponding to the middle value of the two intersection points is used as a target pixel point, and a difference between the target pixel point and a reference pixel point is determined as the offset.
[0024] Optionally, determining two intersection points of a parabola formed by a bit sequence selected from the standard sampled data and the abscissa includes:
[0025] Based on a sub-pixel linear interpolation method, two intersection points between a bit sequence selected from the standard sampled data and the horizontal coordinate are determined.
[0026] Optionally, the method is characterized in that, before binarizing the standard sampled data, the method further comprises:
[0027] Counting the number of sampling values in the sampled data or the standard sampled data that are not within the extreme value interval and undergo continuous gradient changes;
[0028] When the number is not less than the preset number, a pollutant alarm is issued.
[0029] The present invention also provides an absolute position detection device, comprising:
[0030] An acquisition module is used to acquire sampling data generated by the light source irradiating the optical code disk based on a linear optical sensor;
[0031] a grayscale space unification module, configured to convert the sampled data into standard sampled data in the same standard grayscale space according to the actual grayscale space corresponding to each pixel point in the linear optical sensor;
[0032] A coding sequence module, configured to binarize the standard sampling data according to a binarization threshold to obtain square wave data, and decode the square wave data to obtain a coding sequence;
[0033] An initial position module, configured to determine an initial position value according to the coding sequence;
[0034] An offset module, configured to perform parabola fitting on a bit sequence selected from the standard sampled data according to the binarization threshold, and determine the difference between the target pixel point corresponding to the highest point of the parabola and the reference pixel point as an offset;
[0035] The absolute position module is used to determine the absolute position according to the initial position value and the offset.
[0036] The present invention also provides an absolute position detection device, the device comprising:
[0037] Memory: used to store computer programs;
[0038] Processor: used to implement the steps of the absolute position detection method as described in any one of the above items when executing the computer program.
[0039] The present invention also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the absolute position detection method as described in any one of the above items are implemented.
[0040] An absolute position detection method provided by the present invention includes: based on a linear optical sensor, obtaining sampling data generated by a light source irradiating an optical code disk; converting the sampling data into standard sampling data in the same standard grayscale space according to the actual grayscale space corresponding to each pixel point in the linear optical sensor; binarizing the standard sampling data according to a binarization threshold to obtain square wave data, and decoding the square wave data to obtain a coding sequence; determining an initial position value according to the coding sequence; performing parabola fitting on a bit sequence selected from the standard sampling data according to the binarization threshold, and determining the difference between a target pixel point corresponding to the highest point of the parabola and a reference pixel point as an offset; and determining the absolute position according to the initial position value and the offset.
[0041] After acquiring the sampling data through the linear optical sensor, the sampling data will first be converted into standard sampling data in the same standard grayscale space according to the actual grayscale space of each pixel point to unify the maximum and minimum values of the sampling values of each pixel point; on this basis, the standard sampling data will be binarized and decoded to obtain a coding sequence, based on which the initial position value for coarse positioning can be obtained; then a parabola fitting is performed on the selected bit sequence, and the difference between the target pixel point corresponding to the highest point of the parabola and the reference pixel point is determined as the offset. Based on this offset, the initial position value is corrected to obtain the precise absolute position, thereby realizing absolute position detection based on image sensing technology.
[0042] The present invention also provides an absolute position detection device, an absolute position detection equipment, and a computer-readable storage medium, which also have the above-mentioned beneficial effects and will not be described in detail here. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] In order to more clearly illustrate the embodiments of the present invention or the technical solutions of the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0044] FIG1 is a flow chart of an absolute position detection method provided by an embodiment of the present invention;
[0045] Figure 2 is a schematic diagram of a circular application;
[0046] Figure 3 is a schematic diagram of a linear application;
[0047] FIG4 is a first sampling data distribution diagram;
[0048] FIG5 is a schematic diagram of the grayscale space of different pixels before correction;
[0049] Figure 6 is a schematic diagram of parabola fitting;
[0050] FIG7 is a flowchart of a specific absolute position detection method provided by an embodiment of the present invention;
[0051] FIG8 is a schematic diagram of grayscale space conversion;
[0052] FIG9 is a schematic diagram of sampling data before correction;
[0053] FIG10 is a schematic diagram of the standard sampling data after correction;
[0054] Figure 11 is a schematic diagram of square wave data after binarization;
[0055] FIG12 is a schematic diagram of sub-pixel linear interpolation;
[0056] FIG13 is a schematic diagram of a contamination signal;
[0057] FIG14 is a structural block diagram of an absolute position detection device provided by an embodiment of the present invention;
[0058] FIG15 is a structural block diagram of an absolute position detection device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0059] The core of the present invention is to provide an absolute position detection method. In the existing technology, there are almost no high-precision absolute position encoders based on image sensing technology in China. Products such as grating rulers and laser displacement sensors are also relatively rare, and the technical solutions adopted by each company vary greatly.
[0060] The present invention provides an absolute position detection method, including: obtaining sampling data generated by a light source irradiating an optical code disk based on a linear optical sensor; converting the sampling data into standard sampling data in the same standard grayscale space according to the actual grayscale space corresponding to each pixel point in the linear optical sensor; binarizing the standard sampling data according to a binarization threshold to obtain square wave data, and decoding the square wave data to obtain a coding sequence; determining an initial position value according to the coding sequence; performing parabola fitting on a bit sequence selected from the standard sampling data according to the binarization threshold, and determining the difference between the target pixel point corresponding to the highest point of the parabola and the reference pixel point as an offset; and determining the absolute position according to the initial position value and the offset.
[0061] After acquiring the sampling data through the linear optical sensor, the sampling data will first be converted into standard sampling data in the same standard grayscale space according to the actual grayscale space of each pixel point to unify the maximum and minimum values of the sampling values of each pixel point; on this basis, the standard sampling data will be binarized and decoded to obtain a coding sequence, based on which the initial position value for coarse positioning can be obtained; then a parabola fitting is performed on the selected bit sequence, and the difference between the target pixel point corresponding to the highest point of the parabola and the reference pixel point is determined as the offset. Based on this offset, the initial position value is corrected to obtain the precise absolute position, thereby realizing absolute position detection based on image sensing technology.
[0062] In order to enable those skilled in the art to better understand the present invention, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments. Obviously, the embodiments described are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0063] Please refer to Figures 1 to 6, Figure 1 is a flow chart of an absolute position detection method provided by an embodiment of the present invention; Figure 2 is a schematic diagram of a circular application; Figure 3 is a schematic diagram of a linear application; Figure 4 is a first sampling data distribution diagram; Figure 5 is a schematic diagram of the grayscale space of different pixel points before correction; Figure 6 is a schematic diagram of parabola fitting.
[0064] 1 , in an embodiment of the present invention, the absolute position detection method includes:
[0065] S101: Based on a linear optical sensor, sampling data generated by a light source irradiating an optical code disk is acquired.
[0066] First, the absolute position detection method provided in this embodiment is specifically applied to absolute position encoding based on image sensing technology, and the basic structure of the absolute position encoder based on image sensing technology includes an optical scale (pseudo-random encoding code disk), a light source (usually a point light source, emitting visible light or invisible light), and a linear array optical sensor, such as a linear array CMOS or CCD sensor. The specific type of the linear array optical sensor is not specifically limited in the embodiment of the present invention and depends on the specific situation. The above-mentioned linear array optical sensor usually includes a plurality of pixel points arranged along a straight line, and the above-mentioned light source is usually a point light source, which can be an LED light source, etc. The point light source is usually set in the middle of the linear array optical sensor to provide light. In the application process, the above-mentioned light source and the linear array optical sensor need to be used in conjunction with an optical scale, such as a random encoding code disk. The above-mentioned optical scale usually includes a reflective area and a non-reflective area arranged in a preset order. The above-mentioned reflective area and non-reflective area are usually in the shape of strips. Under the illumination of the above-mentioned light source, the linear array optical sensor can obtain "white" and "black" signals. In actual situations, the optical scale, light source, and linear array optical sensor provided in this application have the following two situations: Figure 2 is a circular application, such as a rotary encoder or a motor encoder system; Figure 3 is a linear application, such as a linear encoder or a grating scale system.
[0067] In this step, the light source is specifically prompted to emit light to illuminate the optical code disk, that is, the above-mentioned optical scale, and then the light emitted by the optical code disk is obtained based on the linear optical sensor. At this time, each pixel in the linear optical sensor can generate a sampling value to form sampling data.
[0068] It should be noted that this acquisition step is applied to a high-speed AD sampling unit, such as an FPGA, connected to a linear optical sensor. The linear optical sensor collects light reflected from the optical code disk in the current environment. In this embodiment, the sampled value collected by each pixel is typically a grayscale value in its grayscale space. The following steps are typically implemented as a data processing unit in embedded system platforms such as DSP (Digital Signal Processing) or ARM (Advanced RISC Machines).
[0069] S102: Converting the sampled data into standard sampled data in the same standard grayscale space according to the actual grayscale space corresponding to each pixel point in the linear optical sensor.
[0070] In the absolute position encoder of the present application, due to the Lambertian characteristics of the light source illumination, the collected data will show the characteristics of a strong middle signal and gradually decreasing signals on both sides. Therefore, the grayscale spatial range of the physical space corresponding to each pixel point in the linear array optical sensor is inconsistent. As a whole, as the light intensity of the light source is distributed, the grayscale spatial range in the middle is wide and the grayscale spatial range on both sides is narrow.
[0071] Before this step, it is necessary to pre-measure the grayscale space of each pixel point in the linear optical sensor, that is, the actual grayscale space. When measuring, it is first necessary to prepare a measuring plate, and set a reflective area and a non-reflective area on the surface of the measuring plate. Usually, half of the surface of the correction plate is a reflective area (simulating the "white" stripes of the code disk) and the other half is a non-reflective area (simulating the "black" stripes of the code disk). When measuring the grayscale space of each pixel point of the linear optical sensor, the linear optical sensor will be controlled to straddle the reflective area and the non-reflective area of the correction plate. Usually, half of the pixel points of the linear optical sensor are placed in the reflective area and the other half are placed in the non-reflective area. After that, the linear optical sensor is controlled to collect data in the current environment to obtain the first sampling data. At this time, the overall data arrangement is basically as shown in Figure 4, and there is an obvious polarity jump process from black to white in the middle interval. At this time, the host computer 3 can analyze this data through an algorithm to detect whether there is a data jump with a large difference, and the interval size of the extreme values of the polarity end points [G min , G max ].
[0072] If the range of the two polarity values is too small, we can combine the characteristics of the built-in parameters of the linear optical sensor and adjust the exposure value, brightness gain and other shooting parameters of the linear optical sensor appropriately to make G min With G max The interval between the two values is widened, but the overall data must be kept within the interval [0, 255], while avoiding overexposure and other phenomena. The obvious sign of overexposure is that the highest point interval of the sampling curve maintains a value of 255 for multiple consecutive points.
[0073] After adjusting the linear optical sensor, it can be directed toward the reflective area of the sampling plate. The linear optical sensor then collects data from the current environment, generating second sampled data—the brightness sampled value of "white" on the code disk corresponding to each pixel. The validity of the second sampled data can then be determined based on its variance and distribution characteristics. Specifically, the variance of the entire data set can be calculated, which squares the difference between the sampled value of each pixel and the average sampled value. This variance reflects the fluctuations in light intensity from the linear optical sensor in the reflective area; larger variances indicate greater fluctuations. Furthermore, considering the overall data characteristics, if the second sampled data still exhibits large values in the middle and small values at the ends, the data is valid and can be recorded.
[0074] Similarly, after adjusting the linear optical sensor, the linear optical sensor can be controlled to face the non-reflective area of the sampling plate. The linear optical sensor then collects data in the current environment to obtain third sampled data, namely the brightness sampling value of the "black" on the code disk corresponding to each pixel. The validity of this third sampled data can be determined by referring to the validity of the second sampled data described above. Specifically, the validity of the third sampled data can be determined based on the variance and distribution characteristics of the third sampled data. Specifically, the variance of the entire set of data is calculated. This variance value reflects the fluctuation of the light amount of the linear optical sensor in the non-reflective area. The larger the variance value, the greater the fluctuation. In addition, combined with the overall data characteristics, if the third sampled data still shows the characteristic of large middle sampled values and small sampled values at both ends, it means that the third sampled data is valid and can be recorded.
[0075] Referring to FIG5 , based on the second sampling data and the third sampling data, the actual grayscale space corresponding to each pixel in the linear array optical sensor can be determined. After determining the second sampling data and the third sampling data, the entire calibration system has obtained the light intensity value from dark to bright at the physical position of each pixel, as shown in FIG5 , which can be recorded as [G min , G max After data sorting, as shown in Table 1:
[0076] Table 1. Grayscale space table after sorting
[0077] In this embodiment, the above-mentioned actual grayscale space can be specifically stored in a storage device such as a flash memory connected to the linear optical sensor, so that in this step, the standard sampling value corresponding to each pixel point in the same standard grayscale space can be determined based on the actual sampling value obtained from each pixel point in the linear array optical sensor and the corresponding actual grayscale space.
[0078] In this step, the actual grayscale space corresponding to each pixel can be directly called, and the actual sampled values obtained by each pixel in the above-mentioned sampled data can be converted into standard sampled values in the same standard grayscale space based on the corresponding actual grayscale space, thereby forming standard sampled data. The specific details will be described in detail in the following embodiments of the invention and will not be repeated here. After the sampled data is converted into standard sampled data in the same standard grayscale space in this step, each standard sampled value corresponds to the same grayscale space. That is, the maximum and minimum values of the sampled values corresponding to each pixel are now the same, thereby processing the signal with uneven local extreme value sizes into a signal with uniform and balanced extreme value sizes.
[0079] S103: binarizing the standard sampling data according to the binarization threshold to obtain square wave data, and decoding the square wave data to obtain a coding sequence.
[0080] In this step, the standard sampled data is first binarized to determine the "black" and "white" values, resulting in binarized square wave data. Based on this square wave signal, the "black" values are converted to 0 and the "white" values are converted to 1, resulting in a code sequence consisting of a series of 0s and 1s. Because optical code disks typically use a pseudorandom code with a specific code length, this code sequence is non-repeating, ensuring uniqueness.
[0081] S104: Determine an initial position value according to the coding sequence.
[0082] This step typically involves a table lookup to determine the initial position value corresponding to the code sequence using a pre-established code table. For example, if the optical code disk is circular, a table lookup can be used to determine the specific angle corresponding to the code sequence. It should be noted that the initial position value determined at this point is a rough position value; in subsequent steps, an offset must be calculated to correct this initial position value.
[0083] S105: performing parabola fitting on the bit sequence selected from the standard sampling data according to the binarization threshold, and determining the difference between the target pixel point corresponding to the highest point of the parabola and the reference pixel point as the offset.
[0084] As shown in Figure 6, since there is a fixed pixel spacing between the physical pixels of the linear array optical sensor, the image actually sampled by the linear array optical sensor is discrete data. In order to achieve high-precision offset calculation, in this step, it is necessary to first select one or more bit sequences from the standard sampling data, and then use the above-mentioned binarization threshold as the horizontal coordinate to perform parabola fitting on the selected bit sequence. The above-mentioned bit sequence is usually a coding bit. After the parabola fitting, the highest point of the parabola can be determined, and then the pixel point corresponding to the highest point of the parabola can be determined. In this embodiment, it will be called the target pixel point P i . In this embodiment, a pixel point is selected as the reference pixel point in advance. For a linear optical sensor, the pixel point at the midpoint of the linear optical sensor is usually selected as the reference pixel point. Due to the physical width that the linear optical sensor can collect and the decline in the quality of the collected signals at the two edges, the middle pixel (such as the middle pixel of a CMOS with a resolution of 512 is 256 pixels) is generally selected as the reference pixel point P0. In this step, the target pixel point P corresponding to the highest point of the parabola is specifically calculated. i , and the difference between it and the reference pixel point P0 of the image is used as the precise offset of the optical code disk in the image.
[0085] The above-mentioned sub-pixel-based parabola peak point detection method eliminates the need to determine the distance between the reference pixel and the pixel where the polarity changes. By fitting a parabola to the entire coding bit, the sub-pixel offset is calculated. Preferably, in this embodiment, the offset of each coding bit can be calculated for the entirety of multiple coding bits, and the overall offset can be determined by arithmetic averaging.
[0086] S106: Determine the absolute position according to the initial position value and the offset.
[0087] In this step, the above offset can be combined with the direction of movement of the code disk and the above calculated initial position value to perform corresponding addition and subtraction, that is, the precise positioning of the position information is completed, and the absolute position is determined and output.
[0088] An absolute position detection method provided by an embodiment of the present invention, after acquiring sampling data through a linear optical sensor, will first convert the sampling data into standard sampling data in the same standard grayscale space according to the actual grayscale space of each pixel point, so as to unify the maximum and minimum values of the sampling values of each pixel point; on this basis, the standard sampling data is binarized and decoded to obtain a coding sequence, and an initial position value for coarse positioning can be obtained based on the coding sequence; then, a parabola fitting is performed on the selected bit sequence, and the difference between the target pixel point corresponding to the highest point of the parabola and the reference pixel point is determined as an offset, and the initial position value is corrected based on the offset to obtain a precise absolute position, thereby realizing absolute position detection based on image sensing technology.
[0089] The specific content of the absolute position detection method provided by the present invention will be described in detail in the following embodiments of the invention.
[0090] Please refer to Figures 7 to 13, where Figure 7 is a flow chart of a specific absolute position detection method provided by an embodiment of the present invention; Figure 8 is a schematic diagram of grayscale space conversion; Figure 9 is a schematic diagram of sampling data before correction; Figure 10 is a schematic diagram of standard sampling data after correction; Figure 11 is a schematic diagram of square wave data after binarization; Figure 12 is a schematic diagram of sub-pixel linear interpolation; and Figure 13 is a schematic diagram of a contamination signal.
[0091] 7 , in an embodiment of the present invention, the absolute position detection method includes:
[0092] S201: Based on the linear optical sensor, sampling data generated by the light source irradiating the optical code disk is obtained.
[0093] This step is basically the same as S101 in the above-mentioned embodiment of the invention. Please refer to the above-mentioned embodiment of the invention for details, and will not be described again here.
[0094] S202: Based on proportional conversion, actual sampling values collected by pixel points are converted into standard sampling values in the same standard grayscale space according to the corresponding actual grayscale space to determine standard sampling data.
[0095] This step is mainly used to implement ISP (Image Signal Processor) correction processing for grayscale space equalization of sampled data. In this step, for a pixel point, the range interval value of its corresponding actual grayscale space is [G min , G max ], the actual sampling value of the pixel point collected in S201 is G real In this step, the actual sampling value G can be converted into realConvert to a unified standard grayscale space, such as the [0, 255] grayscale space in the general digital image field. In this step, it is necessary to first calculate the corresponding proportional coefficient k based on each actual sampling value = (G real -G min ) / (G max -G min ), and calculate the converted standard grayscale value G = k × 255. At this time, the grayscale space corresponding to each pixel point can be unified, and the result is shown in Figure 8. By comparing Figures 9 and 10, it can be seen that this step converts the original sampling data into calibrated standard sampling data, and can process the signal with uneven local extreme values into a signal with uniform and balanced extreme values, thereby realizing the correction of the sampling data. In this step, the linear proportional conversion method is used to make the signals collected under different light amounts in the same grayscale color space, so that the different maximum and minimum values in different position intervals are all balanced, and the local extreme values can reach the same size, which is convenient for the application and processing of subsequent algorithms.
[0096] S203: Adjust the sampling value corresponding to the noise point according to the sampling value of the neighborhood of the noise point.
[0097] This step allows for ISP processing from another perspective, primarily addressing noise anomalies. In actual sampling, linear array optical sensors can process anomalous pixels by filtering them using the median and mean values of the pixels within their neighborhood. This allows for a reasonable estimation of the sample values collected by the isolated noise point from its neighboring pixels. This step involves adjusting the sample values corresponding to the noise point based on the sample values of its neighborhood to eliminate the noise point. Accordingly, the specific processing steps of this step can be performed simultaneously with the above steps, using a parallel sampling and processing approach.
[0098] S204: binarizing the standard sampling data according to the binarization threshold to obtain square wave data, and decoding the square wave data to obtain a coding sequence.
[0099] In this step, pixels below the binarization threshold can be set to black and the others to white according to the global threshold method or the adaptive threshold method, and the result is shown in Figure 11. It should be noted that the waveforms and corresponding coding sequences in Figure 11 are not specific limitations and are only examples.
[0100] After obtaining the square wave data, the encoding sequence can be decoded by combining it with the basic pixel width of the minimum bit sequence of the encoding sequence. This means that the binary data is decoded into a sequence similar to 101010110010101100101010... Because optical code disks typically use a pseudo-random code with a certain code length, this encoding sequence is a non-repeating pseudo-random code, ensuring its uniqueness.
[0101] S205: Convert the coded sequence into a decimal number.
[0102] When determining the initial position value corresponding to the code sequence based on the table lookup method, in order to speed up the search, the binary search method is specifically used in this embodiment. Specifically, in this step, the code sequence obtained by the above calculation is first regarded as a binary number and converted into a decimal number.
[0103] S206: According to the preset coding table, searching for the initial position value corresponding to the decimal number in the coding table based on the binary search method.
[0104] In the embodiment of the present invention, the coding table is a table sorted by the size of the decimal number. It should be noted that the coding table used in this embodiment is not sorted in the same way as the original coding sequence table in the prior art. Taking the calculation of angle of a circular optical code disk as an example, its original coding sequence table is specifically shown in Table 2:
[0105] Table 2. Original coding sequence table
[0106] As can be seen from Table 2, the original table of the coding sequence is specifically arranged by angle value or serial number. Assuming that the optical code disk uses 1024 bits to encode one circle, then 18-bit sequences are taken in sequence, and the entire code disk coding sequence can be arranged in the manner of Table 2. When using the general table lookup method, the angles can be arranged in sequence according to the serial number. At this time, if you want to match the angle of 360°÷1024*1023, you need to search 1024 times until the last one is matched. This step will specifically use the binary search mode to first arrange the entire sequence table from small to large according to the decimal number corresponding to the coding sequence in the third column of Table 1 to obtain the coding table to be used in this step, and then search the initial position value corresponding to the decimal number in the coding table based on the binary search method.
[0107] Each search using binary search will start with a match in the middle position. Each match will eliminate half of the table, narrowing the search range until the corresponding coding sequence is matched and the current search is ended. At this point, the binary search can quickly locate the initial position value corresponding to the sequence, thereby knowing the current initial position value. For angle values, the accuracy of the current angle value is the angle value divided by the total number of coding sequences of 360° (that is, the number of equal divisions of 360, as shown in the table above, 360°÷1024°), which is a coarse angle value. Using binary search requires at most log2 nThe binary method requires at most n steps, while the simple table lookup method requires at most n steps. The binary method is more efficient and balanced. In particular, due to the limited physical width of the sensor and the reduced quality of the signals captured at the edges during binarization, the center pixel (e.g., the center pixel at 256 pixels for a 512-bit resolution CMOS image sensor) is typically selected as the base pixel position P0 for the entire algorithm. This position is used as the starting point for sequence decoding, extending the decoding to both sides before performing sequence merging.
[0108] S207: Using the binarization threshold as the abscissa, determine two intersection points between the parabola formed by the bit sequence selected from the standard sampled data and the abscissa.
[0109] S208: Taking the pixel point corresponding to the middle value of the two intersection points as the target pixel point, and determining the difference between the target pixel point and the reference pixel point as the offset.
[0110] For parabola fitting, the parabola's highest point is actually the midpoint between the horizontal coordinate (binarization threshold line) and the parabola. This intersection is actually the location where the image's grayscale flips from dark to light and from light to dark. Therefore, this embodiment can first determine the two intersections of a parabola and the binarization threshold, and then take the midpoint between the two intersections as the target pixel corresponding to the parabola's highest point.
[0111] Specifically, the above S207 may specifically include: determining two intersection points between the bit sequence selected from the standard sampled data and the horizontal coordinate based on a sub-pixel linear interpolation method. That is, the two intersection points between the above parabola and the binarization threshold may be determined by an algorithm such as a sub-pixel linear interpolation method.
[0112] As shown in Figure 12, using the sub-pixel linear interpolation method to find the intersection point (P, G) on the left side of the parabola, through the previous parabola fitting and binarization threshold, we can now obtain two points (P0, G0) and (P1, G1) with a connected pixel interval of at least 1 pixel. Using the principle of linear interpolation, we can obtain: (G-G0) / (P-P0) = (G1-G0) / (P1-P0)
[0113] When the interval between connected pixels is 1, here P1-P0=2; G is the binarization threshold; at this time, the high-precision position P=(G-G0)×(P1-P0) / (G1-G0)+P0 can be obtained; similarly, the high-precision position information of the intersection point on the right side of the parabola can be obtained. Taking the average of the two intersection points, the target pixel point P required in Figure 5 can be obtained. i location information.
[0114] Furthermore, the method of this step can be used to obtain the precise offsets of multiple parabola highest points through multiple positions where the bit sequence is 1, and then the arithmetic mean of the multiple offsets can be calculated as the offset value of the entire image.
[0115] S209: Determine the absolute position according to the initial position value and the offset.
[0116] This step is basically the same as S106 in the above embodiment. Please refer to the above invention embodiment for details, and will not be repeated here.
[0117] S210: Counting the number of sampling values that are not within the extreme value interval and undergo continuous gradient changes in the sampling data or standard sampling data.
[0118] Referring to FIG13 , this embodiment also involves detecting and processing alarm algorithms for similar anomalies. Because the aforementioned measurement system, comprised of an optical code disk, a linear optical sensor, and a light source, is extremely sensitive to code disk contamination, code disk contamination can cause the algorithm to be unable to accurately identify angles. Therefore, a keen sense of the presence of a contamination source is required. Contamination from some stains can be determined by comparing the width of the sequence decoding bit sequence. For example, if there is minor scratch contamination, since the actual image appears as shown in FIG13 , this step uses the change in gradient value magnitude within a continuous interval outside the extreme value interval to determine this contamination. That is, in this step, the number of continuous gradient changes in the sampled data or standard sampled data that are outside the extreme value interval is first counted.
[0119] In a continuous non-extreme interval, that is, the actual sampling value or the standard sampling value is not close to the maximum value G max Or minimum value G min When the gradient value continuously changes within a certain range, and the length of the interval of continuous gradient change exceeds the unit width of the code disk sequence, and the gradient changes of the middle pixel and the first and last pixels in the interval are also within the same range, it can be determined that the data in this area is abnormal and contamination has occurred, and an alarm needs to be issued. Accordingly, in this step, the number of sample values that are not within the extreme value interval and undergo continuous gradient changes needs to be counted. This number is used to reflect the length of the interval of continuous gradient change.
[0120] Of course, in addition to the above-mentioned comparison of the gradient value of the pixel in the middle with the gradient value of the pixel at the beginning and the end for judgment, it is also possible not to use the middle pixel, but to verify through a gradient transformation with a fixed step size, for example, using a step size of 5 pixels to measure whether there are continuous changes in the gradient value within the same range.
[0121] S211: When the number is not less than the preset number, a pollutant alarm is issued.
[0122] If the number of counts in S210 is not less than a preset number, it means that the length of the interval in which the gradient value continuously changes exceeds the code disk sequence unit width. In this case, a contamination alarm is required, indicating that the optical code disk is contaminated. S210 to S211 and S202 to S209 in the above-mentioned embodiment of the invention can be executed in parallel or in any order, and are not specifically limited here.
[0123] An absolute position detection method provided by an embodiment of the present invention independently constructs a pixel grayscale color space for each pixel, and balances the sampling value of each pixel through linear conversion; integrates a noise processing mechanism to filter the noise in the image field; uses a binary search mode to arrange the sequential code disk sequence codes in ascending order or from large to small, and the binary search requires at most log2 n steps, while a simple table lookup method requires at most n steps. The binary search method is more efficient and balanced. The sub-pixel parabola peak point detection method eliminates the need to determine the distance between the reference pixel and the pixel location where the polarity changes. By fitting a parabola to the entire coding bit, the sub-pixel offset is found. The offset of each coding bit can also be calculated for multiple coding bits as a whole, and the overall angle offset is determined by arithmetic averaging. During the decoding process, statistics are introduced on the number of continuous gradient changes in data that are not within the extreme value range. When the gradient change exceeds a preset number within a certain threshold range, it can be determined that the current code disk has scratches or other contamination, and a timely alarm can be issued.
[0124] An absolute position detection device provided by an embodiment of the present invention is introduced below. The absolute position detection device described below and the absolute position detection method described above can be referenced to each other.
[0125] Please refer to FIG. 14 , which is a structural block diagram of an absolute position detection device provided by an embodiment of the present invention.
[0126] Referring to FIG14 , in an embodiment of the present invention, the absolute position detection device may include:
[0127] The acquisition module 100 is configured to acquire, based on a linear optical sensor, sampling data generated when a light source illuminates an optical code disk.
[0128] The grayscale space unification module 200 is configured to convert the sampled data into standard sampled data in the same standard grayscale space according to the actual grayscale space corresponding to each pixel point in the linear optical sensor.
[0129] The coding sequence module 300 is configured to binarize the standard sampling data according to a binarization threshold to obtain square wave data, and decode the square wave data to obtain a coding sequence.
[0130] The initial position module 400 is configured to determine an initial position value according to the coding sequence.
[0131] The offset module 500 is used to perform parabola fitting on the bit sequence selected from the standard sampling data according to the binarization threshold, and determine the difference between the target pixel point corresponding to the highest point of the parabola and the reference pixel point as the offset.
[0132] The absolute position module 600 is configured to determine an absolute position according to the initial position value and the offset.
[0133] Preferably, in the embodiment of the present invention, the grayscale space unification module 200 is used to:
[0134] Based on proportional conversion, the actual sampling values collected by the pixel points are converted into standard sampling values in the same standard grayscale space according to the corresponding actual grayscale space to determine the standard sampling data.
[0135] Preferably, in an embodiment of the present invention, the method further includes:
[0136] The noise point elimination module is used to adjust the sampling value corresponding to the noise point according to the sampling value of the noise point neighborhood.
[0137] Preferably, in this embodiment of the present invention, the initial position module 400 includes:
[0138] A conversion unit is used to convert the code sequence into a decimal number.
[0139] A table lookup unit is used to look up the initial position value corresponding to the decimal number in the coding table based on a binary search according to a preset coding table; the coding table is a table sorted according to the size of the decimal number.
[0140] Preferably, in an embodiment of the present invention, the offset module 500 includes:
[0141] an intersection unit, configured to use the binarization threshold as a horizontal coordinate and determine two intersection points between a parabola formed by a bit sequence selected from the standard sampled data and the horizontal coordinate;
[0142] The offset unit is configured to use a pixel point corresponding to an intermediate value of the two intersection points as a target pixel point, and determine a difference between the target pixel point and a reference pixel point as the offset.
[0143] Preferably, in an embodiment of the present invention, the intersection unit is used to:
[0144] Based on a sub-pixel linear interpolation method, two intersection points between a bit sequence selected from the standard sampled data and the horizontal coordinate are determined.
[0145] Preferably, in an embodiment of the present invention, the method further includes:
[0146] The gradient value statistics module is used to count the number of sampling values in the sampled data or the standard sampled data that are not within the extreme value interval and undergo continuous gradient changes.
[0147] The alarm module is used to issue a pollutant alarm when the number is not less than a preset number.
[0148] The absolute position detection device of this embodiment is used to implement the aforementioned absolute position detection method. Therefore, the specific implementation methods of the absolute position detection device can be seen in the embodiment part of the absolute position detection method in the previous text. For example, the acquisition module 100, the gray space unification module 200, the encoding sequence module 300, the initial position module 400, the offset module 500, and the absolute position module 600 are respectively used to implement steps S101 to S106 in the above-mentioned absolute position detection method. Therefore, its specific implementation methods can refer to the descriptions of the corresponding embodiments of each part and will not be repeated here.
[0149] An absolute position detection device provided by an embodiment of the present invention is introduced below. The absolute position detection device described below and the absolute position detection method and absolute position detection apparatus described above can be referenced to each other.
[0150] Please refer to FIG. 15 , which is a structural block diagram of an absolute position detection device provided by an embodiment of the present invention.
[0151] 15 , the absolute position detection device may include a processor 11 and a memory 12 .
[0152] The memory 12 is used to store computer programs; the processor 11 is used to implement the absolute position detection method described in the above embodiment of the invention when executing the computer program.
[0153] The processor 11 in the absolute position detection device of this embodiment is used to implement the absolute position detection apparatus described in the aforementioned embodiments of the invention. Furthermore, the processor 11, in combination with the memory 12, can implement the absolute position detection method described in any of the aforementioned embodiments of the invention. Therefore, the specific implementation of the absolute position detection device can be found in the aforementioned embodiments of the absolute position detection method. The specific implementation of the absolute position detection device can be found in the descriptions of the corresponding embodiments, and will not be repeated here.
[0154] The present invention further provides a computer-readable storage medium storing a computer program. When executed by a processor, the computer program implements an absolute position detection method described in any of the above-mentioned embodiments of the invention. The remaining contents can be referred to the prior art and will not be described in detail here.
[0155] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from the other embodiments. Reference can be made to the descriptions of the identical or similar parts between the various embodiments. For the devices disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the descriptions are relatively simple, and the relevant parts can be referred to the descriptions of the methods.
[0156] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the above description has generally described the components and steps of each example according to their functions. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the present invention.
[0157] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), internal memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0158] Finally, it should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of additional identical elements in the process, method, article, or device comprising the element.
[0159] The above is a detailed introduction to the absolute position detection method, device, equipment and storage medium provided by the present invention. Specific examples are used herein to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only intended to help understand the method and core ideas of the present invention. It should be pointed out that for ordinary technicians in this technical field, without departing from the principles of the present invention, several improvements and modifications can be made to the present invention, and these improvements and modifications also fall within the scope of protection of the claims of the present invention.
Claims
1. An absolute position detection method, characterized in that: include: Based on the linear optical sensor, the sampling data generated by the light source irradiating the optical code disk is obtained; According to the actual grayscale space corresponding to each pixel point in the linear optical sensor, the sampled data is converted into standard sampled data in the same standard grayscale space; Binarizing the standard sampling data according to a binarization threshold to obtain square wave data, and decoding the square wave data to obtain a coding sequence; Determining an initial position value according to the coding sequence; According to the binarization threshold, a parabola is fitted to the bit sequence selected from the standard sampling data, and the difference between the target pixel point corresponding to the highest point of the parabola and the reference pixel point is determined as an offset; An absolute position is determined according to the initial position value and the offset.
2. The method according to claim 1, characterized in that Converting the sampled data into standard sampled data in the same standard grayscale space comprises: Based on proportional conversion, the actual sampling values collected by the pixel points are converted into standard sampling values in the same standard grayscale space according to the corresponding actual grayscale space to determine the standard sampling data.
3. The method according to claim 2, characterized in that Before binarizing the standard sampling data, the method further includes: According to the sampling values of the neighborhood of the noise point, the sampling value corresponding to the noise point is adjusted.
4. The method according to claim 1, characterized in that: Determining the initial position value according to the coding sequence comprises: Converting the coded sequence into a decimal number; According to a preset coding table, the initial position value corresponding to the decimal number in the coding table is searched based on binary search; the coding table is a table sorted according to the size of the decimal number.
5. The method according to claim 1, characterized in that The step of performing parabola fitting on the bit sequence selected from the standard sampling data according to the binarization threshold and determining the difference between the target pixel point corresponding to the highest point of the parabola and the reference pixel point as the offset includes: The binarization threshold is used as the horizontal coordinate to determine the bit selected from the standard sampling data. two intersection points of the parabola formed by the sequence and the abscissa; A pixel point corresponding to the middle value of the two intersection points is taken as a target pixel point, and a difference between the target pixel point and a reference pixel point is determined as the offset.
6. The method according to claim 5, characterized in that The step of determining two intersection points between a parabola formed by a bit sequence selected from the standard sampled data and the horizontal coordinate comprises: Based on the sub-pixel linear interpolation method, two intersection points between the bit sequence selected from the standard sampling data and the horizontal coordinate are determined.
7. The method according to any one of claims 1 to 6, characterized in that: Before binarizing the standard sampling data, the method further includes: Counting the number of sampling values that are not within the extreme value interval and undergo continuous gradient changes in the sampling data or the standard sampling data; When the number is not less than a preset number, a pollutant alarm is issued.
8. An absolute position detection device, characterized in that: include: An acquisition module, used for acquiring sampling data generated by irradiating the optical code disk with a light source based on a linear optical sensor; A grayscale space unification module, used for converting the sampled data into standard sampled data in the same standard grayscale space according to the actual grayscale space corresponding to each pixel point in the linear optical sensor; A coding sequence module, used for binarizing the standard sampling data according to a binarization threshold to obtain square wave data, and decoding the square wave data to obtain a coding sequence; An initial position module, used to determine an initial position value according to the coding sequence; An offset module, used to perform parabola fitting on the bit sequence selected from the standard sampling data according to the binarization threshold, and determine the difference between the target pixel point corresponding to the highest point of the parabola and the reference pixel point as an offset; The absolute position module is used to determine the absolute position according to the initial position value and the offset.
9. An absolute position detection device, characterized in that: The device comprises: Memory: used to store computer programs; Processor: used to implement any one of claims 1 to 7 when executing the computer program Describe the steps of the absolute position detection method.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the absolute position detection method according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Magneto-optic imaging defect detection method based on automatic search of binary threshold
CN105427324A
Two-dimensional absolute displacement encoder
CN107121072A
Absolute grating ruler and displacement measuring method
CN108007359A
Detector calibration
CN110741222A
Photoelectric encoder and scale therefor
JP2006226987A
Cited By
Shot put three-dimensional space trajectory analysis and score prediction method based on 2D image
CN119625055A
