Four-neighborhood centroid positioning method and device for serial image stream

By using serial image stream and information of the left and upper neighbors in the four-neighborhood center of mass positioning method, a single image traversal is realized to complete the center of mass positioning, solving the problem of low computing efficiency in the prior art, and is suitable for high codes rate image stream transmission.

CN119399265APending Publication Date: 2025-02-07CHINESE PEOPLES LIBERATION ARMY UNIT 92941
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410802084.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-20
Publication Date
2025-02-07

AI Technical Summary

Technical Problem

The existing four-neighborhood centroid positioning method requires cache of images, resulting in low computing efficiency and difficult to meet the transmission requirements of high-code rate image streams.

Method used

Through a four-neighborhood center of mass positioning method for serial image stream, the information of the left neighborhood and the upper neighborhood can be used to realize a sequential traversal to complete the center of mass positioning of the whole picture, avoiding the traditional method of the upper, lower, left and right neighborhoods Reverse access.

Benefits of technology

It realizes the determination of four neighborhood communication domains and calculation of center of mass position directly using serial image data for single image traversal, which improves the computing efficiency and is suitable for application scenarios such as high frame rate point target measurement and high dynamic weak target continuous tracking.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119399265A_ABST
    Figure CN119399265A_ABST
Patent Text Reader

Abstract

The invention discloses a four-neighborhood centroid positioning method and a four-neighborhood centroid positioning device for a serial image stream. The method comprises the following steps of: initializing row section statistical information to be empty and connected domain information to be empty; acquiring a serial image stream in real time and analyzing the serial image stream; acquiring a current pixel point of the serial image flow, if the current pixel point is not the last pixel of the serial image flow, performing judgment processing of a left side connected domain of the current pixel and processing of an upper side connected domain of the current pixel for the current pixel, and updating row section statistical information and connected domain information according to a processing result; taking the next pixel point of the serial image flow as the current pixel point; and if the current pixel point is the last pixel of the serial image flow, traversing each connected domain, and calculating the centroid position of each connected domain based on the information of the connected domain. According to the method, all four-neighborhood connected domains can be judged through single image traversal, and the centroid positions of all targets can be obtained.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of real-time processing of image data, and in particular to a method and device for locating centroids of four neighborhoods for serial image streams. Background Art

[0002] Under the hardware platform, images are generally transmitted on the bus in the form of serial streaming media, first row and then column. Centroid positioning is applied to sub-pixel positioning of point or small target images. For example, infinitely far small target detection or sub-pixel positioning of point targets is generally obtained by calculating the energy center of gravity, so segmenting the target from the background is the most critical part. The common method for segmenting small targets or point target images is to use the grayscale threshold to segment the ones greater than the threshold as targets, and then obtain several target individuals based on the characteristics of the four-neighborhood connected domain.

[0003] There is no public patent for the four-neighborhood centroid positioning method applicable to serial image streams. The current four-neighborhood centroid positioning method requires first implementing region segmentation, and then traversing the segmentation results to perform centroid positioning calculations. Moreover, during the region segmentation process, the connected domain of each pixel is determined. The judgment of the four-neighborhood connected domain includes not only the left neighbor and upper neighbor that can be checked in the same direction as the streaming media output, but also the unknown right neighbor and lower neighbor. Therefore, the general connected domain judgment must cache the entire image for reverse judgment, that is, it is necessary to traverse the information of the four surrounding neighborhoods, which will generate a large number of non-sequential storage accesses. For this reason, the entire image needs to be stored in the cache to meet the large number of non-sequential accesses of the algorithm.

[0004] It can be seen that the existing four-neighborhood centroid positioning method needs to traverse the entire image at least twice, and there will be multiple non-sequential pixel accesses during the connected domain identification process. Such data access requirements cannot meet the requirements of serial image streams being transmitted in row-first and column-later order.

[0005] A compromise method is to build a cache for the entire image and access pixels in this cache, and then release the memory after completion. In order to achieve pipeline operation, a ping-pong operation structure can be used, and the clock frequency of the image algorithm side needs to be increased several times to avoid congestion.

[0006] In summary, there is currently no method for locating the centroid of four neighborhoods that can complete the segmentation of the image's four neighborhoods and the centroid location of these connected domain targets under the condition of a single sequential traversal of the entire image. Existing methods require the image to be cached before calculation, which has low computational efficiency and is difficult to meet the transmission of high-bitrate image streams. Summary of the invention

[0007] In view of this, the present invention provides a four-neighborhood centroid positioning method and device for serial image streams, which can solve the technical problems of needing to cache images before calculation, low computational efficiency, and difficulty in meeting the transmission requirements of high-bitrate image streams.

[0008] In order to solve the above technical problems, the present invention is implemented as follows.

[0009] A four-neighborhood centroid positioning method for a serial image stream, comprising:

[0010] Step S1: Initialize row segment statistics information to be empty and connected domain information to be empty, wherein the row segment statistics information is used to record segment information of each row composed of pixels of an image corresponding to the serial image stream; obtain the serial image stream in real time and parse the serial image stream;

[0011] Step S2: obtaining the current pixel of the serial image stream, if the current pixel is not the last pixel of the serial image stream, proceeding to step S3, otherwise, proceeding to step S4;

[0012] Step S3: for the current pixel, the judgment processing of the connected domain on the left side of the current pixel and the processing of the connected domain on the upper side are performed, and the row segment statistical information and the connected domain information are updated according to the processing results; the next pixel point of the serial image stream is taken as the current pixel point, and the process goes to step S2;

[0013] Step S4: traverse each connected domain, and calculate the centroid position of each connected domain based on the connected domain information.

[0014] Preferably, the step S3: for the current pixel, the judgment processing of the connected domain on the left side of the current pixel and the processing of the connected domain on the upper side are performed, and the row segment statistical information and the connected domain information are updated according to the processing results; the next pixel point of the serial image stream is taken as the current pixel point, and the process proceeds to step S2, including:

[0015] Step S31: if the current pixel is a line-break pixel, the segment information of the previous line of the current pixel is used as the final segment information of the previous line, and is incrementally stored in the line segment statistics information, and the segment information of the line where the current pixel is located is added to the line segment statistics information, the segment information includes the line segment start column number, the line segment end column number, the line segment connected domain number and the line segment number, and the segment refers to a set of pixels in a row whose grayscale of several consecutive and uninterrupted columns is greater than a preset threshold;

[0016] Step S32: amplify the current pixel in the segment of the row where the current pixel is located, and update the segment information of the row where the current pixel is located; if the current pixel causes a discontinuity of pixels in the same row, the current pixel is recorded as having no left neighbor, otherwise, the current pixel is recorded as having a left neighbor; for the current pixel with a left neighbor, amplify the current pixel in the left neighbor, and update the connected domain information, the connected domain information records the sum of the product of the X coordinate of each pixel in the connected domain and its gray value, the sum of the product of the Y coordinate of each pixel in the connected domain and its gray value, the sum of the gray values ​​of each pixel in the connected domain, and the number of pixels in the connected domain;

[0017] Step S33: If the segment of the row where the current pixel is located is connected to the segment of the previous row of the current pixel, the row segment of the previous row containing the current column is used as the upper neighbor of the current pixel, and it is determined again whether the current pixel has a left neighbor. If the current pixel does not have a left neighbor, the current pixel is amplified in the upper neighborhood and the connected domain information is updated; if the current pixel has a left neighbor, the left neighborhood is merged with the upper neighborhood as the left neighborhood, and the current pixel is amplified in the left neighborhood to update the connected domain information;

[0018] Step S34: Determine again whether the current pixel has a left neighboring region, if so, update the connected region information; if not, take the next pixel point of the serial image stream as the current pixel point and go to step S2.

[0019] Preferably, the current pixel of the serial image stream is accumulated, and if the accumulated sum exceeds a first preset threshold, the image corresponding to the serial image stream is overexposed, the processing is stopped, and an error prompt is output;

[0020] Accumulating all pixels of the serial image stream, if the accumulated sum is less than a second preset threshold, the image corresponding to the serial image stream is too dark, the processing is stopped, and an error prompt is output;

[0021] If the grayscale value of the current pixel of the serial image stream exceeds the third preset threshold, the image corresponding to the serial image stream is wrong, the processing is stopped, and an error prompt is output.

[0022] Preferably, if the number of segments in the same row of the serial image stream exceeds a fourth preset threshold, the image corresponding to the serial image stream is erroneous, processing is stopped, and an error prompt is output;

[0023] If the total number of the connected domains exceeds a fifth preset threshold, the image corresponding to the serial image stream is erroneous, processing is stopped, and an error prompt is output.

[0024] Preferably, the connected domain information includes left neighbor information and upper neighbor information.

[0025] The present invention provides a device for locating centroids of four neighborhoods for serial image streams, comprising:

[0026] Initialization module: configured to initialize row segment statistics information to be empty and connected domain information to be empty, wherein the row segment statistics information is used to record segment information of each row composed of pixels of the image corresponding to the serial image stream; acquire the serial image stream in real time and parse the serial image stream;

[0027] A judgment module: configured to obtain a current pixel of the serial image stream, and if the current pixel is not the last pixel of the serial image stream, trigger an update module; otherwise, trigger a calculation module;

[0028] Update module: configured to perform judgment processing of the connected domain on the left side of the current pixel and processing of the connected domain on the upper side for the current pixel, and update the row segment statistical information and the connected domain information according to the processing results; take the next pixel point of the serial image stream as the current pixel point to trigger the judgment module;

[0029] Calculation module: configured to traverse each connected domain and calculate the centroid position of each connected domain based on the connected domain information.

[0030] The present invention provides a computer-readable storage medium, wherein a plurality of instructions are stored in the storage medium; the plurality of instructions are used for a processor to load and execute the method as described above.

[0031] An electronic device provided by the present invention is characterized in that the electronic device comprises:

[0032] A processor, which is used to execute multiple instructions;

[0033] A memory for storing a plurality of instructions;

[0034] The plurality of instructions are used to be stored by the memory and loaded and executed by the processor to implement the method as described above.

[0035] The present invention replaces the traditional method of judging the four upper, lower, left and right neighbors with the left neighbor and upper neighbor judgment, and there is no need to access the image in reverse order. In the specific processing method, in addition to using the connected domain statistics, the row segment information is also used to realize the judgment of the upper neighborhood connection characteristics. The present invention is mostly a simple branch judgment, which can be slightly applied to large-scale logic processing devices. Therefore, it can be widely used in occasions with high real-time requirements and no image caching, and is very suitable for application scenarios such as high frame rate point target measurement and continuous tracking of high-dynamic weak targets.

[0036] Beneficial effects:

[0037] (1) The present invention can directly use serial image data as input, and can complete the determination of all four-neighborhood connected domains and obtain the centroid positions of all targets through a single image traversal.

[0038] (2) The present invention uses only the information of the left and upper neighbors, and achieves the effect of locating the centroid of the entire image in one sequential traversal. The present invention uses the row segment statistical information to retain the feature judgment of the upper neighbor, and uses the connected domain statistical information to perform real-time calculation of the key quantity of centroid positioning.

[0039] (3) The present invention is simple and easy to implement, and is particularly suitable for outputting image information in a streaming form on a real-time hardware image platform. It can be applied to logic devices such as FPGA, and is very suitable for application scenarios such as high frame rate point target measurement and continuous tracking of high-dynamic small and weak targets. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] Figure 1 It is a schematic diagram of the flow of the method for locating centroids of four neighborhoods for serial image streams of the present invention;

[0041] Figure 2 It is another schematic diagram of the method for locating centroids of four neighborhoods for serial image streams according to the present invention;

[0042] Figure 3 A schematic diagram of the pixel order of the serial image stream output of the present invention;

[0043] Figure 4 The figure is a structural block diagram of the four-neighborhood centroid positioning device for serial image streams according to the present invention. DETAILED DESCRIPTION

[0044] The present invention is described in detail below in conjunction with the accompanying drawings and embodiments.

[0045] The present invention proposes a four-neighborhood centroid positioning method for serial image streams.

[0046] like Figure 1 As shown, the four-neighborhood centroid positioning method for a serial image stream provided by the present invention includes:

[0047] Step S1: Initialize row segment statistics information to be empty and connected domain information to be empty, wherein the row segment statistics information is used to record segment information of each row composed of pixels of an image corresponding to the serial image stream; obtain the serial image stream in real time and parse the serial image stream;

[0048] Step S2: obtaining the current pixel of the serial image stream, if the current pixel is not the last pixel of the serial image stream, proceeding to step S3, otherwise, proceeding to step S4;

[0049] Step S3: for the current pixel, the judgment processing of the connected domain on the left side of the current pixel and the processing of the connected domain on the upper side are performed, and the row segment statistical information and the connected domain information are updated according to the processing results; the next pixel point of the serial image stream is taken as the current pixel point, and the process goes to step S2;

[0050] Step S4: traverse each connected domain, and calculate the centroid position of each connected domain based on the connected domain information.

[0051] The connected domain information includes left neighbor information and upper neighbor information.

[0052] The step S3: for the current pixel, the judgment processing of the connected domain on the left side of the current pixel and the processing of the connected domain on the upper side are performed, and the row segment statistical information and the connected domain information are updated according to the processing results; the next pixel point of the serial image stream is taken as the current pixel point, and the step S2 is entered, including:

[0053] Step S31: if the current pixel is a line-break pixel, the segment information of the previous line of the current pixel is used as the final segment information of the previous line, and is incrementally stored in the line segment statistics information, and the segment information of the line where the current pixel is located is added to the line segment statistics information, the segment information includes the line segment start column number, the line segment end column number, the line segment connected domain number and the line segment number, and the segment refers to a set of pixels in a row whose grayscale of several consecutive and uninterrupted columns is greater than a preset threshold;

[0054] Step S32: amplify the current pixel in the segment of the row where the current pixel is located, and update the segment information of the row where the current pixel is located; if the current pixel causes a discontinuity of pixels in the same row, the current pixel is recorded as having no left neighbor, otherwise, the current pixel is recorded as having a left neighbor; for the current pixel with a left neighbor, amplify the current pixel in the left neighbor, and update the connected domain information, the connected domain information records the sum of the product of the X coordinate of each pixel in the connected domain and its gray value, the sum of the product of the Y coordinate of each pixel in the connected domain and its gray value, the sum of the gray values ​​of each pixel in the connected domain, and the number of pixels in the connected domain;

[0055] Step S33: If the segment of the row where the current pixel is located is connected to the segment of the previous row of the current pixel, the row segment of the previous row containing the current column is used as the upper neighbor of the current pixel, and it is determined again whether the current pixel has a left neighbor. If the current pixel does not have a left neighbor, the current pixel is amplified in the upper neighborhood and the connected domain information is updated; if the current pixel has a left neighbor, the left neighborhood is merged with the upper neighborhood as the left neighborhood, and the current pixel is amplified in the left neighborhood to update the connected domain information;

[0056] Step S34: Determine again whether the current pixel has a left neighboring region, if so, update the connected region information; if not, take the next pixel point of the serial image stream as the current pixel point and go to step S2.

[0057] Furthermore, the current pixel of the serial image stream is accumulated, and if the accumulated sum exceeds a first preset threshold, the image corresponding to the serial image stream is overexposed, the processing is stopped, and an error prompt is output.

[0058] All pixels of the serial image stream are accumulated. If the accumulated sum is less than a second preset threshold, the image corresponding to the serial image stream is too dark, and the processing is stopped and an error prompt is output.

[0059] If the grayscale value of the current pixel of the serial image stream exceeds the third preset threshold, the image corresponding to the serial image stream is wrong, the processing is stopped, and an error prompt is output.

[0060] If the number of segments in the same row of the serial image stream exceeds a fourth preset threshold, the image corresponding to the serial image stream is erroneous, processing is stopped, and an error prompt is output.

[0061] If the total number of the connected domains exceeds a fifth preset threshold, the image corresponding to the serial image stream is erroneous, processing is stopped, and an error prompt is output.

[0062] In the present invention, the serial image stream passes through a threshold comparator in the order of rows first and columns later, and pixels greater than the threshold value will enter the main processing flow.

[0063] Secondly, in the main processing flow, overexposure, too dark, grayscale value out of range, number of segments out of range, and connected domain out of range are monitored. Once they occur, an error prompt is returned.

[0064] Again, in actual judgment, updates are mainly made for row segment conditions and connected domain conditions. (1) The method first determines the row break situation: when a row break occurs, the segment information of the previous row is immediately updated, and the segment information of the current row is initialized, and the current pixel point is regarded as an isolated point without a left neighbor. (2) The method then determines the situation of disconnection in the same row: if the current pixel is disconnected from the previous pixel in the same row, it is determined that there is no left neighbor. (3) After determining the left neighbor situation, for the current pixel with a left neighbor, the connected domain statistics are accumulated and the segment interval is expanded. (4) After processing the left neighbor situation, the upper neighbor is processed. If the current pixel row is adjacent to the previous valid row, the segment of the previous row is traversed. If the current pixel column is in a segment, there is an upper neighbor relationship. (5) Furthermore, if it has no left neighbor relationship, the current pixel is directly classified as being in the connected domain where the upper neighbor is located. (6) If there is a left neighbor relationship, but the connected domain where the left neighbor is located is inconsistent with the connected domain where the upper neighbor is located, a connected domain merging operation is performed.

[0065] Finally, after the whole image is serially output, the information of the connected domain is traversed. The centroid of each connected domain with non-zero pixel number is calculated to obtain the sub-pixel position of all centroids.

[0066] The present invention provides a specific embodiment of a four-neighborhood centroid positioning method for a serial image stream.

[0067] 1. Introduction to intermediate variables

[0068] Intermediate variables are divided into pixel-level intermediate variables, segment-level intermediate variables, and connected domain-level intermediate variables. They are defined in detail below:

[0069] (1) Pixel-level intermediate variables

[0070] curPixRow: current pixel row number;

[0071] curPixCol: current pixel column number;

[0072] curPixHui: current pixel grayscale;

[0073] leftLabel: the label of the connected domain on the left side of the current pixel;

[0074] prePixRow: the row number of the previous valid pixel;

[0075] prePixCol: The column number of the previous valid pixel.

[0076] (2) Segment-level intermediate variables

[0077] The concept of a segment is explained as follows: a segment is a section of pixels in a row that are all larger than a decision threshold. A small segment may include only one pixel, while a large segment may include a whole row of pixels.

[0078] curLeftList[]: array of starting column numbers of the current row segment;

[0079] curRightList[]: array of column numbers at the end of the current row segment;

[0080] curLabelList[]: the connected domain label array of the current row segment;

[0081] curSectNum: the current row segment number;

[0082] preLeftList[]: the starting column number array of the previous row segment;

[0083] preRightList[]: the end column number array of the previous row segment;

[0084] preLabelList[]: the label array of the connected domain in the previous row;

[0085] lastSectNum: The current row section number.

[0086] (3) Intermediate variables at the connected domain level

[0087] lastestSectNum: the latest connected domain number;

[0088] sectXHui[]: array of sum of products of X coordinates and grayscale in the connected domain;

[0089] sectYHui[]: array of the sum of the products of Y coordinates and grayscale in the connected domain;

[0090] sectHui[]: grayscale sum array in connected domain;

[0091] sectPixNum[]: Array of the number of pixels in the connected domain.

[0092] 2. Image stream output and correctness judgment

[0093] The image stream is output in the order of rows first and columns, from the upper left corner of the image (coordinate (0,0)) to the lower right corner of the image (coordinate (M-1,N-1)). The image has M rows and N columns. Figure 3 In this process, every time a new pixel greater than the threshold enters the processing program, a correctness judgment is required to prevent errors in the result of centroid positioning of the entire image.

[0094] (1) Image overexposure judgment

[0095] If the total number of processed pixels (i.e., the total number of pixels greater than a specific grayscale threshold) exceeds a specific upper limit Nbright, the image is considered overexposed, an error type is output, and the current image processing is stopped.

[0096] (2) Image too dark judgment

[0097] If the total number of processed pixels (i.e., the total number of pixels greater than a specific grayscale threshold) is still less than the specific lower limit NDIM after the entire image stream is traversed, the image is judged to be too dark, the error type is output, and the current image processing is stopped.

[0098] (3) Gray value out of range

[0099] If curPixHui exceeds the maximum grayscale value Hmax of the image, the image stream data is judged to be wrong, the error type is output, and the current image processing is stopped.

[0100] (4) Segment number overflow

[0101] The length of the array in the segment-level data is fixed, and its length NSECT indicates the maximum number of segments that can be recorded in a row. If the array subscript exceeds NSECT when adding a segment curSectNum, the number of segments overflows. The error type is output and the current image processing is stopped.

[0102] (5) Overflow of the number of connected domains

[0103] The length of the array in the connected domain level data is fixed, and its length NCONN represents the maximum number of connected domains that can be recorded in the image. If the array subscript exceeds NCONN when adding a connected domain lastestSectNum, the number of connected domains overflows. Output the error type and stop the current image processing.

[0104] 3. Code implementation

[0105] The specific data operations of each part operation (rectangular frame) and judgment (diamond frame) are explained.

[0106] Step 1:

[0107] prePixRow=curPixRow

[0108] prePixCol=curPixCol

[0109] Step 2:

[0110] if curPixHui>specific grayscale threshold

[0111] Step 3:

[0112] Empty

[0113] Step 4:

[0114] curPixRow = current pixel row number, curPixCol = current pixel column number, curPixHui = current pixel gray value

[0115] Step 5:

[0116] if prePixRow != curPixRow

[0117] Step 6:

[0118]

[0119] Step 7:

[0120] if (prePixRow == curPixRow) && (prePixCol + 1 != curPixCol)

[0121] Step 8:

[0122] leftLabel = 0

[0123] Step 9:

[0124] if leftLabel != 0

[0125] Step 10:

[0126] sectXHui[leftLabel] += curPixCol * curPixHui

[0127] sectYHui[leftLabel] += curPixRow * curPixHui

[0128] sectHui[leftLabel] += curPixHui

[0129] sectPixNum[leftLabel]++

[0130] curRightList[curSectNum] = curPixCol

[0131] Step 11:

[0132] for t = 0, t < lastSectNum, t++ (Traverse each section of the previous row)

[0133] if (curPixCol >= preLeftList[t]) &&

[0134] (curPixCol<=preRightList[t])

[0135] Step 12:

[0136] if leftLabel == 0

[0137] Step 13:

[0138] curSectNum++

[0139] leftLabel = preLabelList[t]

[0140] curLeftList[curSectNum]=curPixCol

[0141] curRightList[curSectNum]=curPixCol

[0142] curLabelList[curSectNum]=leftLabel

[0143] sectXHui[leftLabel]+=curPixCol*curPixHui

[0144] sectYHui[leftLabel]+=curPixRow*curPixHui

[0145] sectHui[leftLabel]+=curPixHui

[0146] sectPixNum[leftLabel]++

[0147] Step 14:

[0148] if leftLabel! =preLabelList[t]

[0149] Step 15:

[0150] Add the values ​​of the preLabelList[t]th element in the sectXHui, sectYHui, sectHui, and sectPixNum arrays to the leftLabelth element, and clear the former elements to zero.

[0151] Change the labels from the tth position to the lastSectNumth position in preLabelList marked as preLabelList[t] to leftLabel

[0152] Step 16:

[0153] if leftLabel == 0

[0154] Step 17:

[0155] lastestSectNum++

[0156] sectXHui[lastestSectNum]+=curPixCol*curPixHui

[0157] sectYHui[lastestSectNum]+=curPixRow*curPixHui

[0158] sectHui[lastestSectNum]+=curPixHui

[0159] sectPixNum[lastestSectNum]++

[0160] leftLabel = lastSectNum

[0161] curSectNum++

[0162] curLeftList[curSectNum]=curPixCol

[0163] curRightList[curSectNum]=curPixCol

[0164] curLabelList[curSectNum]=leftLabel

[0165] Step 18:

[0166] if pixel output number == M*N

[0167] Step 19:

[0168]

[0169] The present invention also provides a four-neighborhood centroid positioning device for serial image streams, such as Figure 4 As shown, the device comprises:

[0170] Initialization module: configured to initialize row segment statistics information to be empty and connected domain information to be empty, wherein the row segment statistics information is used to record segment information of each row composed of pixels of the image corresponding to the serial image stream; acquire the serial image stream in real time and parse the serial image stream;

[0171] A judgment module: configured to obtain a current pixel of the serial image stream, and if the current pixel is not the last pixel of the serial image stream, trigger an update module; otherwise, trigger a calculation module;

[0172] Update module: configured to perform judgment processing of the connected domain on the left side of the current pixel and processing of the connected domain on the upper side for the current pixel, and update the row segment statistical information and the connected domain information according to the processing results; take the next pixel point of the serial image stream as the current pixel point to trigger the judgment module;

[0173] Calculation module: configured to traverse each connected domain and calculate the centroid position of each connected domain based on the connected domain information.

[0174] The present invention does not elaborate on some of the well-known technologies that belong to those skilled in the art.

[0175] The above specific embodiments only describe the design principle of the present invention. The shapes and names of the components in the description may be different and are not limited. Therefore, those skilled in the art in the field of the present invention may modify or replace the technical solutions recorded in the above embodiments; and these modifications and replacements do not deviate from the creative purpose and technical solutions of the present invention and should all fall within the protection scope of the present invention.

Claims

1. A four-neighborhood centroid positioning method for a serial image stream, characterized in that: include: Step S1: Initializing row segment statistics information to be empty and connected domain information to be empty, wherein the row segment statistics information is used to record segment information of each row composed of pixels of an image corresponding to the serial image stream; Acquire a serial image stream in real time and parse the serial image stream; Step S2: obtaining the current pixel of the serial image stream, if the current pixel is not the last pixel of the serial image stream, proceeding to step S3, otherwise, proceeding to step S4; Step S3: for the current pixel, the judgment processing of the connected domain on the left side of the current pixel and the processing of the connected domain on the upper side are performed, and the row segment statistical information and the connected domain information are updated according to the processing results; the next pixel point of the serial image stream is taken as the current pixel point, and the process goes to step S2; Step S4: traverse each connected domain, and calculate the centroid position of each connected domain based on the connected domain information.

2. The method according to claim 1, characterized in that The step S3: for the current pixel, the judgment processing of the connected domain on the left side of the current pixel and the processing of the connected domain on the upper side are performed, and the row segment statistical information and the connected domain information are updated according to the processing results; The next pixel point of the serial image stream is taken as the current pixel point, and step S2 is entered, including: Step S31: if the current pixel is a line-break pixel, the segment information of the previous line of the current pixel is used as the final segment information of the previous line, and is incrementally stored in the line segment statistics information, and the segment information of the line where the current pixel is located is added to the line segment statistics information, the segment information includes the line segment start column number, the line segment end column number, the line segment connected domain number and the line segment number, and the segment refers to a set of pixels in a row whose grayscale of several consecutive and uninterrupted columns is greater than a preset threshold; Step S32: amplify the current pixel in the segment of the row where the current pixel is located, and update the segment information of the row where the current pixel is located; if the current pixel causes a discontinuity of pixels in the same row, the current pixel is recorded as having no left neighbor, otherwise, the current pixel is recorded as having a left neighbor; for the current pixel with a left neighbor, amplify the current pixel in the left neighbor, and update the connected domain information, the connected domain information records the sum of the product of the X coordinate of each pixel in the connected domain and its gray value, the sum of the product of the Y coordinate of each pixel in the connected domain and its gray value, the sum of the gray values ​​of each pixel in the connected domain, and the number of pixels in the connected domain; Step S33: If the segment of the row where the current pixel is located is connected to the segment of the previous row of the current pixel, the row segment of the previous row containing the current column is used as the upper neighbor of the current pixel, and it is determined again whether the current pixel has a left neighbor. If the current pixel does not have a left neighbor, the current pixel is amplified in the upper neighborhood and the connected domain information is updated; if the current pixel has a left neighbor, the left neighborhood is merged with the upper neighborhood as the left neighborhood, and the current pixel is amplified in the left neighborhood to update the connected domain information; Step S34: Determine again whether the current pixel has a left neighboring region, if so, update the connected region information; if not, take the next pixel point of the serial image stream as the current pixel point and go to step S2.

3. The method according to claim 2, characterized in that Accumulating the current pixel of the serial image stream, if the accumulated sum exceeds a first preset threshold, the image corresponding to the serial image stream is overexposed, the processing is stopped, and an error prompt is output; Accumulating all pixels of the serial image stream, if the accumulated sum is less than a second preset threshold, the image corresponding to the serial image stream is too dark, the processing is stopped, and an error prompt is output; If the grayscale value of the current pixel of the serial image stream exceeds the third preset threshold, the image corresponding to the serial image stream is wrong, the processing is stopped, and an error prompt is output.

4. The method according to claim 3, characterized in that If the number of segments in the same row of the serial image stream exceeds a fourth preset threshold, the image corresponding to the serial image stream is wrong, processing is stopped, and an error prompt is output; If the total number of the connected domains exceeds a fifth preset threshold, the image corresponding to the serial image stream is erroneous, processing is stopped, and an error prompt is output.

5. The method according to any one of claims 1 to 4, characterized in that The connected domain information includes left neighbor information and upper neighbor information.

6. A device for locating centroids of four neighborhoods for serial image streams, characterized in that: include: Initialization module: configured to initialize row segment statistics information to be empty and connected domain information to be empty, wherein the row segment statistics information is used to record segment information of each row composed of pixels of the image corresponding to the serial image stream; Acquire a serial image stream in real time and parse the serial image stream; A judgment module: configured to obtain a current pixel of the serial image stream, and if the current pixel is not the last pixel of the serial image stream, trigger an update module; otherwise, trigger a calculation module; Update module: configured to perform judgment processing of the connected domain on the left side of the current pixel and processing of the connected domain on the upper side for the current pixel, and update the row segment statistical information and the connected domain information according to the processing results; Taking the next pixel point of the serial image stream as the current pixel point, triggering the judgment module; Calculation module: configured to traverse each connected domain and calculate the centroid position of each connected domain based on the connected domain information.

7. A computer-readable storage medium, characterized in that: The storage medium stores a plurality of instructions; the plurality of instructions are used for a processor to load and execute the method as described in any one of claims 1 to 5.

8. An electronic device, characterized in that: The electronic device comprises: A processor, which is used to execute multiple instructions; A memory for storing a plurality of instructions; The plurality of instructions are used to be stored in the memory and loaded and executed by the processor according to any one of claims 1 to 5.