CN111738904B - Method and device for calculating geometric moment of target object in image - Google Patents

Method and device for calculating geometric moment of target object in image Download PDF

Info

Publication number
CN111738904B
CN111738904B CN202010554845.0A CN202010554845A CN111738904B CN 111738904 B CN111738904 B CN 111738904B CN 202010554845 A CN202010554845 A CN 202010554845A CN 111738904 B CN111738904 B CN 111738904B
Authority
CN
China
Prior art keywords
image
traversal
geometric
transverse
data stream
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202010554845.0A
Other languages
Chinese (zh)
Other versions
CN111738904A (en
Inventor
王振
洪柱
肖志康
邹洋
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Wuhan Institute of Technology
Original Assignee
Wuhan Institute of Technology
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Wuhan Institute of Technology filed Critical Wuhan Institute of Technology
Priority to CN202010554845.0A priority Critical patent/CN111738904B/en
Publication of CN111738904A publication Critical patent/CN111738904A/en
Application granted granted Critical
Publication of CN111738904B publication Critical patent/CN111738904B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T1/00General purpose image data processing
    • G06T1/20Processor architectures; Processor configuration, e.g. pipelining
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/20Analysis of motion
    • G06T7/246Analysis of motion using feature-based methods, e.g. the tracking of corners or segments
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/70Determining position or orientation of objects or cameras
    • G06T7/73Determining position or orientation of objects or cameras using feature-based methods

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Multimedia (AREA)
  • Image Analysis (AREA)

Abstract

The invention relates to a method and a device for calculating the geometric moment of a target object in an image, which comprises the steps of acquiring an image data stream corresponding to the image containing the target object by adopting a hardware description language; acquiring the size of an image and the size of a target object pixel, performing image traversal on an image data stream according to the size of the image and the size of the target object pixel according to a preset data flow direction, and respectively calculating an image geometric moment data set during each image traversal; and respectively calculating actual geometric moments of the image data stream during the image passes according to the image geometric moment data set during each image pass, outputting the actual geometric moments, and extracting and outputting target geometric moments corresponding to the target object from all the actual geometric moments. The invention provides a pure hardware solution, which realizes traversal calculation of image data stream, outputs actual geometric moment of each traversal calculation in a pipeline mode, does not occupy CPU processing capacity, and can ensure calculation accuracy and real-time performance.

Description

Method and device for calculating geometric moment of target object in image
Technical Field
The invention relates to the technical field of electronic technology, image processing and visual tracking, in particular to a method and a device for calculating the geometric moment of a target object in an image.
Background
When a known object moves in a complex background, the object can be searched and tracked from the complex background by using the principle that the second-order center normalized geometric moment (hereinafter referred to as geometric moment) of the object does not change. Such visual image tracking approaches find numerous applications in the fields of aircraft tracking, vehicle and pedestrian tracking.
The current application mode is mainly that a frame of image containing a target object and a background is read, the traversal of the line target size in the whole image size is completed through a software writing program, and the current geometric moment value is calculated and compared with a template in the traversal process to judge whether the image is the target object or not. However, this method of analyzing and calculating the geometric moment needs to consume a large amount of CPU resources, and when the frame rate of the video image is higher, the calculation speed of the CPU needs to be higher, which brings a bottleneck problem to real-time processing.
Disclosure of Invention
The technical problem to be solved by the present invention is to provide a method and a device for calculating the geometric moment of a target object in an image, and provide a pure hardware solution, to implement traversal calculation of an image data stream, and output each piece of geometric moment data of traversal calculation in a pipeline manner, without occupying CPU processing capability, and can operate in an image processing system with a higher frame rate, and simultaneously ensure calculation accuracy and real-time performance.
The technical scheme for solving the technical problems is as follows:
a method of calculating geometric moments of a target object in an image, comprising the steps of:
step 1: acquiring an image data stream corresponding to an image containing a target object by adopting a hardware description language according to a preset data flow direction;
step 2: acquiring the size of an image and the size of a target object pixel, performing image traversal on the image data stream according to the image size and the size of the target object pixel according to the preset data flow direction, and respectively calculating an image geometric moment data set of the image data stream during each image traversal;
and step 3: and respectively calculating and outputting the actual geometric moments of the image data stream during each image pass according to the image geometric moment data set of the image data stream during each image pass, and extracting and outputting the target geometric moments corresponding to the target object in the image data stream from all the actual geometric moments.
According to another aspect of the present invention, there is also provided a device for calculating geometric moments of a target object in an image, which is applied to the method for calculating geometric moments of a target object in an image of the present invention, and includes an integrated circuit board, and a data stream input circuit, a traversal calculation circuit, a target geometric moment extraction circuit, and an output circuit, which are respectively disposed on the integrated circuit board;
the integrated circuit board is used for integrating the data stream input circuit, the traversal calculation circuit, the target geometric moment extraction circuit and the output circuit;
the data stream input circuit is used for acquiring an image data stream corresponding to an image containing a target object by adopting a hardware description language according to a preset data flow direction;
the traversal calculation circuit is used for acquiring an image size and a target object pixel size, performing image traversal on the image data stream according to the image size and the target object pixel size according to the preset data flow direction, and calculating an image geometric moment data set of the image data stream during each image traversal;
the traversal calculation circuit is further configured to calculate, according to the image geometric moment data sets of the image data streams in each image traversal, actual geometric moments of the image data streams in each image traversal respectively;
the target geometric moment extraction circuit is used for extracting a target geometric moment corresponding to the target object from all the actual geometric moments in the image data stream;
the output circuit is used for outputting the actual geometric moment of the image data stream in each image pass and outputting the target geometric moment;
the integrated circuit board is respectively electrically connected with the data stream input circuit, the traversal calculation circuit, the target geometric moment extraction circuit and the output circuit, the data stream input circuit is electrically connected with the output circuit through the traversal calculation circuit and the target geometric moment extraction circuit in sequence, and the traversal calculation circuit is electrically connected with the output circuit.
The method and the device for calculating the geometric moment of the target object in the image have the advantages that: acquiring an image data stream corresponding to an image containing a target object through a data stream input circuit, wherein one pixel of the image data stream flows into a traversal calculation circuit according to a preset data flow direction, so that after the image size and the pixel size of the target object are acquired in advance, the traversal calculation circuit performs image traversal on the image data stream according to the preset data flow direction, and calculates an image geometric moment data set related to the geometric moment of the target object contained in the image data stream during each image traversal; after an image geometric moment data set traversed by each image is obtained, the traversal calculation circuit calculates the actual geometric moment under the image traversal according to the image geometric moment data set obtained by the corresponding image traversal and outputs the actual geometric moment in real time through the output circuit; the invention provides a solution method of pure hardware (digital circuit), which realizes the traversal calculation of image data stream, and is different from the traditional method of the traversal calculation of the whole image, and outputs each piece of geometric moment data (namely, actual geometric moment) of the traversal calculation in a pipeline mode, does not occupy the processing capacity of a CPU, can operate in an image processing system with a higher frame rate, and simultaneously ensures the calculation precision and the real-time property; after the actual geometric moments computed in each traversal are output in real time, the target geometric moments corresponding to the target objects can be matched and extracted from the actual geometric moments by utilizing preset template data of the target objects, and then the target geometric moments are output through an output circuit, so that the target objects in the image data stream can be positioned; because the image data stream can be an image data stream of a static image and can also be an image data stream corresponding to one frame of image in a dynamic video, when the target object in the image data stream corresponding to each frame of image in the video is respectively positioned, the dynamic visual tracking of the target object can be realized, and the method has important significance in the fields of aircraft tracking, vehicle tracking and pedestrian tracking.
Drawings
FIG. 1 is a flowchart illustrating a method for calculating geometric moments of a target object in an image according to an embodiment of the present invention;
FIG. 2 is a diagram illustrating the relationship between image data streams and image display pixels according to one embodiment of the present invention;
FIG. 3 is a schematic diagram of a model for traversing a whole image according to a first embodiment of the present invention;
FIG. 4 is a schematic diagram of a model of transverse traversal calculation according to an embodiment of the present invention;
fig. 5 to 7 are schematic diagrams of longitudinal traversal calculation models in the first embodiment of the present invention;
FIGS. 8, 9 and 10 are circuit diagrams of the calculation of the M00 data parameter, the M01 data parameter and the M02 data parameter, respectively, during the horizontal traversal according to the first embodiment of the present invention;
FIGS. 11 and 12 are circuit diagrams of computing the M10 data parameter and the M20 data parameter, respectively, during a vertical traversal in accordance with one embodiment of the present invention;
FIGS. 13, 14 and 15 are circuit diagrams of calculating the Σ M ' 00 data parameter, Σ M ' 01 data parameter and Σ M ' 02 data parameter, respectively, during a vertical pass in accordance with one embodiment of the invention;
FIG. 16 is a circuit diagram for calculating the actual geometric distance according to a first embodiment of the present invention;
FIG. 17 is a schematic structural diagram of an apparatus for calculating geometric moments of a target object in an image according to a second embodiment of the present invention;
fig. 18 is a schematic structural diagram of a traversal calculation circuit in the second embodiment of the present invention.
In the drawings, the components represented by the respective reference numerals are listed below:
1. the device comprises an integrated circuit board 2, a data stream input circuit 3, a traversal calculation circuit 4, a target geometric moment extraction circuit 5, an output circuit 31, a transverse traversal calculation sub-circuit 32, a longitudinal traversal calculation sub-circuit 33, a buffer memory 34, a first adder 35, a second adder 36, a third processor 37 and an actual geometric moment calculation sub-circuit.
Detailed Description
The principles and features of this invention are described below in conjunction with the following drawings, which are set forth by way of illustration only and are not intended to limit the scope of the invention.
The present invention will be described with reference to the accompanying drawings.
First embodiment, as shown in fig. 1, a method for calculating a geometric moment of a target object in an image includes the following steps:
s1: acquiring an image data stream corresponding to an image containing a target object by adopting a hardware description language according to a preset data flow direction;
s2: acquiring the size of an image and the size of a target object pixel, performing image traversal on the image data stream according to the image size and the size of the target object pixel according to the preset data flow direction, and respectively calculating an image geometric moment data set of the image data stream during each image traversal;
s3: and respectively calculating and outputting the actual geometric moments of the image data stream during each image pass according to the image geometric moment data set of the image data stream during each image pass, and extracting and outputting the target geometric moments corresponding to the target object in the image data stream from all the actual geometric moments.
The embodiment provides a solution of pure hardware (digital circuit), which implements traversal calculation of an image data stream, outputs each piece of geometric moment data (i.e. actual geometric moment) of the traversal calculation in a pipeline manner, does not occupy the processing capability of a CPU, can operate in an image processing system with a higher frame rate, and simultaneously ensures the calculation accuracy and the real-time performance; after the actual geometric moments computed in each traversal are output in real time, the target geometric moments corresponding to the target objects can be matched and extracted from the actual geometric moments by utilizing preset template data of the target objects and then output, so that the target objects in the image data stream are positioned; because the image data stream can be an image data stream of a static image and can also be an image data stream corresponding to one frame of image in a dynamic video, when the target object in the image data stream corresponding to each frame of image in the video is respectively positioned, the dynamic visual tracking of the target object can be realized, and the method has important significance in the fields of aircraft tracking, vehicle tracking and pedestrian tracking.
Specifically, the hardware description language used in acquiring the image data stream in the present embodiment is Verilog HDL language. The preset data flow direction corresponding to the image data flow is that pixel data of a frame image is read from a camera or other interfaces in a mode that one image pixel starts to be input from the first line (the upper left corner of a screen) according to a first line, and the second line of data is received according to the end of the first line, wherein each pixel data is accompanied by a clock. For example, in the case of a clock frequency of 1MHz, 1M pixels of data can be received within 1 second, where the relationship between the image display pixels and the image data stream is shown in fig. 2, a0 is the first pixel in the first row, a1 is the first pixel in the second row, a92 is the first pixel in the 93 th row, and so on. It should be noted that, in the present invention, both the data in the image data stream and the pixel data refer to the gray scale data of the pixel.
Preferably, in S2, before performing the image traversal on the image data stream according to the image size and the target object pixel size, the method includes:
s21: obtaining single-row transverse traversal times and single-column longitudinal traversal times corresponding to the image data stream according to the image size and the target object pixel size;
s22: obtaining the transverse image traversing times according to the single-row transverse traversing times and the image size, and obtaining the longitudinal image traversing times according to the single-row transverse traversing times and the single-column longitudinal traversing times;
s21 further includes:
and obtaining a transverse traversal size and a longitudinal traversal size according to the pixel size of the target object.
Because the target object has a certain pixel size (namely, the pixel size of the target object), and the image data stream is input by pixel data one by one, rather than inputting multiple lines of data in parallel, the embodiment decomposes traversal calculation into two directions of transverse (namely, the width direction of the image) traversal and longitudinal (namely, the height direction of the image) traversal of the image data stream, respectively calculates the image geometric moment data involved in the two directions of traversal, namely, the corresponding image width geometric moment related data in transverse traversal and the image height geometric moment related data in longitudinal traversal, combines the image width geometric moment related data and the image height geometric moment related data to obtain the corresponding actual geometric moment in the corresponding traversal position, and finally extracts the target geometric moment of the frame image data stream from the actual geometric moment;
before image traversal, according to the image size and the pixel size of a target object, the single-row transverse traversal times (namely the traversal times required by transverse traversal of each row of data) and the single-column longitudinal traversal times (namely the traversal times required by longitudinal traversal of each column of data) corresponding to the image data stream can be determined, because the image data stream is input row by row, transverse traversal is firstly carried out, after all transverse traversal is completed, all pixel data in the whole image data stream can be obtained, then longitudinal traversal is carried out on the basis of transverse traversal, the image transverse traversal times in the whole transverse traversal process can be obtained according to the single-row transverse traversal times and the image size, and the whole image longitudinal traversal times can be obtained according to the single-row transverse traversal times and the single-column longitudinal traversal times; through the preparation work before the image traversal, the decomposition traversal in two decomposition directions and the calculation of the relevant geometric moment data obtained by the decomposition traversal in the two directions are conveniently and quickly realized, the image traversal of the whole image data stream is further realized, the image geometric moment data set of the whole image data stream in each image traversal is obtained, the whole process does not occupy the processing capacity of a CPU (Central processing Unit), the image processing system with a higher frame rate can be operated, and meanwhile, the calculation precision and the real-time property are ensured.
Specifically, as shown in fig. 3, in this embodiment, the size of the image including the target object is 26 × 93 (i.e., the pixel size of the entire image), the pixel size of the target object is 3 × 3, and if the entire image is to be tracked and matched, it is necessary to acquire the geometric moment of the target object with the size of 3 × 3 in advance as matching template data, and traverse the entire image from left to right and from top to bottom sequentially by using the pixel with the size of 3x3 as a calculation frame. Shifting one row in the transverse direction requires calculation 26-3+ 1-24 times, where 26 is the number of width pixels of the whole image, 3 is the target dimension width direction pixels, similarly shifting one row in the height direction requires calculation 93-3+ 1-91 times, and the total number of full traversal of the whole image is 24x 91-2184 times. However, the image data stream is input line by line, so that the image data stream is represented as a decomposition traversal in two decomposition directions in an actual traversal, firstly, a transverse traversal is performed, the transverse traversal size is 3 × 1, the transverse traversal times of a single line are 24 times, the transverse traversal of all lines of the whole image data stream is completed according to a preset data flow direction, and the transverse traversal times of the image are 24 × 93-2232 times; after all the horizontal traversals are completed, the vertical traversals are performed again, based on the horizontal traversals, that is, taking three pixels in the horizontal direction in one horizontal traversals as a whole (taking three pixels in one row as one pixel), and then performing vertical traversals in a traversal size of 1 × 3, so that for the whole image data stream, the actual vertical traversals are 3 × 3 equal to the pixel size of the target object, and the vertical traversals of the image are 24 × 91 equal to 2184 times equal to the total traversals of the whole image.
Preferably, in S2, the image traversal includes a lateral traversal and a longitudinal traversal; the image geometrical moment data set comprises an updated image width geometrical moment set obtained after the image width geometrical moment set of the image data stream in each transverse pass is subjected to corresponding longitudinal traversal, and an image height geometrical moment set of the image data stream in each longitudinal pass;
performing image traversal on the image data stream, and calculating an image geometric moment dataset for each image traversal respectively includes:
s23: according to the preset data flow direction, the transverse traversal size, the single-row transverse traversal times and the image transverse traversal times, carrying out transverse traversal on the image data stream line by line one by one, respectively calculating an image width geometric moment set of each row of data of the image data stream in each transverse traversal, obtaining an image width geometric moment set corresponding to each row of data one by one according to the image width geometric moment sets of each row of data in all transverse traversals, and caching all the image width geometric moment sets;
s24: after all transverse traversals are completed, sequentially performing longitudinal traversals on the image data stream according to the preset data flow direction, the longitudinal traversal size and the image longitudinal traversal times, respectively calculating an updated image width geometric moment set obtained after each image width geometric moment set is subjected to corresponding longitudinal traversal, and caching all updated image width geometric moment sets; and respectively calculating a set of image height geometric moments of the image data stream in each longitudinal pass by using the total set of all image width geometric moments.
The method comprises the steps that a preset data flow direction is a direction of transverse traversal is determined, pixel data input in each row of an image data stream are transversely traversed line by line successively according to the preset data flow direction, an image width geometric moment set calculated by three pixel data corresponding to transverse traversal sizes can be obtained in each transverse traversal, the image width geometric moment set calculated by three pixels corresponding to all transverse traversal sizes in each row forms an image width geometric moment set of the row, and data in the image width geometric moment set of each row are stored in a buffer corresponding to each row respectively and serve as a data source of subsequent longitudinal traversal in the height direction; according to the transverse traversal calculation method, the decomposition traversal of the image data stream in the width direction is realized according to the characteristics of the image data stream, so that the width geometric moment related data of the image data stream in the width direction is obtained;
after all transverse traversals are completed, all pixel data in the image data stream are input into a traversal calculation circuit, transverse decomposition traversal calculation is realized, and longitudinal traversal is performed on the basis of transverse traversal in order to further accurately determine geometric moment related data of a target object in the image data stream; similarly, longitudinal traversal calculation is carried out successively according to the preset data flow direction, the longitudinal traversal size and the image longitudinal traversal times, as the longitudinal traversal size is 3x3 for the whole actual image data flow, wherein the pixel data in transverse traversal is included, the longitudinal traversal is carried out again on the basis of each row of data in transverse traversal, each image width geometric moment set is updated after corresponding longitudinal traversal, a corresponding updated image width geometric moment set is obtained, and meanwhile, an image height geometric moment set in each longitudinal traversal is obtained through calculation by using the image width geometric moment total set corresponding to all rows; the method for longitudinal traversal calculation is based on transverse traversal, and according to the characteristics of the image data stream, the obtained updated image width geometric moment set and image height geometric moment set can accurately reflect the image geometric moment related data of the whole image data stream in each actual image traversal, and can output the geometric moment data of each traversal calculation in a pipeline mode, so that the CPU processing capacity is not occupied, and the calculation precision and the real-time performance are ensured.
Preferably, in S23, the set of image width geometric moments includes a pixel lateral zeroth order geometric moment, a pixel lateral first order geometric moment, and a pixel lateral second order geometric moment for each row of data of the image data stream on each lateral pass; in S24, the updated image width geometry moment set includes an updated pixel transverse zero-order geometry moment, an updated pixel transverse first-order geometry moment, and an updated pixel transverse second-order geometry moment, where the updated pixel transverse zero-order geometry moment is obtained after the pixel transverse zero-order geometry moment is longitudinally traversed correspondingly, the updated pixel transverse first-order geometry moment is obtained after the pixel transverse first-order geometry moment is longitudinally traversed correspondingly, and the updated pixel transverse second-order geometry moment is obtained after the pixel transverse second-order geometry moment is longitudinally traversed correspondingly; the set of image height geometric moments includes a pixel longitudinal first order geometric moment and a pixel longitudinal second order geometric moment for each longitudinal pass of the image data stream.
By calculating the pixel transverse zeroth-order geometric moment, the pixel transverse first-order geometric moment and the pixel transverse second-order geometric moment in each transverse traversal, and obtaining an updated pixel transverse zeroth-order geometric moment, an updated pixel transverse first-order geometric moment and an updated pixel transverse second-order geometric moment after corresponding longitudinal traversal, the data related to the geometric moments in the width direction can be accurately reflected; by calculating the pixel longitudinal first-order geometric moment and the pixel longitudinal second-order geometric moment during each longitudinal traversal, the geometric moment related data in the height direction can be accurately reflected; the geometric moment related data in the width direction and the geometric moment related data in the height direction are combined, so that the subsequent calculation in a pipeline mode is facilitated, the geometric moment data of the whole image during actual image passing is output in real time, the CPU processing capacity is not occupied, and the accurate positioning of a target object is facilitated.
Specifically, as shown in fig. 4, the traverse calculation process is described by taking the first row and the second row of pixel data of the image data stream as an example (other rows of data are not shown in the figure). After each row of data is subjected to transverse traversal calculation, three data are respectively obtained: m00, M01, and M02, for example, in fig. 4, when traversing to a3 × 1 pixel matrix composed of three pixel data, b0, c0, and d0, the first row data is calculated, the pixel transverse zero-order geometric moment M00, the pixel transverse first-order geometric moment M01, and the pixel transverse second-order geometric moment M02, which correspond to the pixel matrix, and then the calculation result M00 is buffered in the FIFO _1_ M00 buffer corresponding to the first row, the calculation result M01 is buffered in the FIFO _1_ M01 buffer corresponding to the first row, and the calculation result M02 is buffered in the FIFO _1_ M02 buffer corresponding to the first row; similarly, when traversing to a3 × 1 pixel matrix formed by every other adjacent three pixel data in the line, respectively calculating a corresponding pixel transverse zero-order geometric moment M00, a pixel transverse first-order geometric moment M01 and a pixel transverse second-order geometric moment M02, respectively caching each M00 in a FIFO _1_ M00 buffer corresponding to the first line, respectively caching each M01 in a FIFO _1_ M01 buffer corresponding to the first line, and caching each M02 in a FIFO _1_ M02 buffer corresponding to the first line; when traversing to the second row of data, the 3 × 1 pixel matrix is composed of three pixel data b1, c1 and d1, respectively calculating a pixel transverse zero-order geometric moment M00, a pixel transverse first-order geometric moment M01 and a pixel transverse second-order geometric moment M02 corresponding to the pixel matrix, then buffering the M00 into a FIFO _2_ M00 buffer corresponding to the second row, buffering the M01 into a FIFO _2_ M01 buffer corresponding to the second row, and buffering the calculation result M02 into a FIFO _2_ M02 buffer corresponding to the second row; similarly, during the horizontal traversal of the 3 × 1 pixel matrix formed by every adjacent three pixel data of the line, corresponding M00, M01 and M02 are respectively calculated, each M00 is respectively cached in a FIFO _2_ M00 buffer, each M01 is respectively cached in a FIFO _2_ M01 buffer, and each M02 is respectively cached in a FIFO _2_ M02 buffer.
It should be noted that, each line of calculation results needs 3 FIFI buffers (a FIFO memory, i.e. a First In First Out memory, which is a First In First Out double-port buffer, i.e. the First data entering the FIFO memory is shifted Out First, one port is an input port of the FIFO memory, and the other port is an output port of the FIFO memory), and M00, M01 and M02 calculated for each horizontal pass of each line of data are respectively stored. Since there are 24 traverse results for a line, the storage depth of each FIFO buffer must be equal to or greater than 24. Wherein, the data stored in all the FIFO buffers is used as the data source for the subsequent vertical traversal.
Specifically, when the traverse of the last row is completed according to the traverse calculation method shown in fig. 4 and there is already the result of the traverse of the last row, the height direction (longitudinal) traverse may be started, as shown in fig. 5, 6, and 7. As shown in fig. 5, the M00 parameter stored at the same pointer in all FIFO buffers storing the M00 parameter can be read out at the same time, similarly as shown in fig. 6, the M01 parameter stored at the same pointer in all FIFO buffers storing the M01 parameter can be read out at the same time, and the M02 parameter stored at the same pointer in all FIFO buffers storing the M02 parameter can be read out at the same time as shown in fig. 7; when the data parameters are read simultaneously, the three parameters of each row at the same pointer are consistent in the height direction, the data parameters are taken out and updated after corresponding longitudinal traversal, corresponding updated data are obtained, namely the updated pixel transverse zero-order geometric moment M ' 00, the updated pixel transverse first-order geometric moment M ' 01 and the updated pixel transverse second-order geometric moment Sigma M ' 02 are obtained, and the data parameters at the original corresponding storage positions are replaced.
The data parameters which are read simultaneously and updated are used for summation calculation on one hand, and the sum of the transverse zero-order geometrical moments of the updated pixels, the sum of the transverse first-order geometrical moments of the updated pixels and the sum of the transverse second-order geometrical moments of the updated pixels under the corresponding longitudinal traversal are obtained, namely sigma M ' 00, sigma M ' 01 and sigma M ' 02 under the corresponding longitudinal traversal are obtained, as shown in FIGS. 5 to 7; and on the other hand, the method is used for calculating the pixel longitudinal first-order geometrical moment and the pixel longitudinal second-order geometrical moment under the corresponding longitudinal traversal, namely M10 and M20 under the corresponding longitudinal traversal, so that the actual geometrical moment under the corresponding longitudinal traversal can be conveniently calculated subsequently.
Specifically, as shown in fig. 8, a schematic diagram of a calculation circuit for calculating the M00 data parameter for a lateral traversal is shown. In fig. 8, the dashed boxes indicate that the calculation box size is 3x1 (assuming that the target object size is 3x3), the solid boxes indicate that the circuit calculates the extraction bits, where the overflow bit indicates that the data stream is one bit before the calculation box outlet, and the accumulation bit indicates the last bit in the calculation box, because the data stream is streaming, the overflow bit and the accumulation bit indicated in the figure will traverse one line of data from beginning to end along with the data streaming, and thus, one line of data in the width direction is traversed according to the calculation size of 3x 1. The plus sign "+" and minus sign "-" in the figure correspond to an adder and a subtracter (realized by the adder), "Z-1"corresponds to a D flip-flop. When the data stream flows through, the real-time calculation of the accumulation parameter M00 can be realized by the data extraction calculation of the accumulation bit and the overflow bit position, and the M00 realizes the function of data accumulation in the width direction calculation box.
Specifically, as shown in fig. 9, for a schematic diagram of a calculation circuit for calculating M01 data parameters for a transverse pass, coefficient accumulation of width direction data is completed. In FIG. 9, the boxes, data bits, plus "+", minus "-", and "Z" + "-1"means the same as in FIG. 8, and the multiplication sign" x "corresponds to a hardware multiplier. M01 realizes a coefficient accumulation function of the data in the calculation box in the width direction, that is, if the data in the calculation box is b0, c0, and d0, M01 is b0+2c0+3d 0. In the example of fig. 9, the target dimension width dimension of the dashed box is 3x1, i.e., n is 3, which is a fixed parameter value that can be cured in advance. In the figure, the current accumulation bit data is the ith pixel data of a data stream flowing through a certain current line, i is the position of the accumulation bit in the current data line, i can be counted by a data counter of each line, and in fig. 9, the accumulation bit data d0 is the 4 th data of the current line, i equals to 4.
In addition, in the calculation circuit shown in fig. 9, each letter has the following meaning relationship:
Figure GDA0003568232010000131
where M01_ dat is i × accumulated bit data, M01_ DoverFlow is (i-n) × overflow bit data, M01_ dat, M01_ DoverFlow, M01_ subtrahend and M01_ minuend are intermediate calculation results, M01_ subtrahend (b) is data of M01_ subtrahend lagging by 1 clock cycle, and M00 in fig. 9 is a result calculated in fig. 8, and can be synchronously calculated by the circuit in fig. 8 and sent to the circuit in fig. 9.
Specifically, as shown in fig. 10, for a schematic circuit diagram of calculating the M02 data parameter during the horizontal traversal, the power coefficient accumulation of the width direction data is completed. In fig. 10, left shifting "<" corresponds to a shift register. M02 realizes the function of power coefficient accumulation for calculating data in boxes in the width direction, that is, if the data in the calculation boxes are b0, c0 and d0, M02 is b0+22c0+32d0. Similarly, in fig. 10, k is n-1, and may be cured in advance.
In the calculation circuit shown in fig. 10, each letter has the following meaning relationship:
Figure GDA0003568232010000132
wherein M02_ dat ═ i2X accumulated bit data, M02_ DoverFlow ═ (i-n)2The x overflow bit data, M02_ dat, M02_ dove flow, M02_ subtrahend and M02_ minuend are all intermediate calculation results, M02_ subtrahend (b) is data with M02_ subtrahend lagging by 1 clock cycle, in the figure, M00 is the result calculated in fig. 8, M01 is the result calculated in fig. 9, and all the data can be synchronously calculated by the circuits in fig. 8 and 9 and sent to the circuit in fig. 10.
Specifically, as shown in fig. 11, a schematic diagram of a calculation circuit for calculating the M10 data parameter for a vertical traversal is shown. Is the result of extracting updated M '00 of the parameter M00 obtained by traversing each row, multiplying the updated M' 00 by the row number of the corresponding row, and then longitudinally accumulating the sum. Assuming that the height of the target size (height of the dashed box) is 3, then the extracted M' 00 of each line is (simultaneously read from the FIFO buffer of each line by the same pointer):
m ' 00_ a1, M ' 00_ a2, M ' 00_ A3, … …, M ' 00_ a92, and M ' 00_ a 93;
and traversing the range of the height direction calculation frame through the switch matrix. The working principle of the switch matrix is as follows: by using a shift register (taking fig. 11 as an example, a 94-bit shift register is needed), then calculating the initial position of the frame, starting from the lowest bit (corresponding to the first row) of the shift register, the consecutive 3 bits (height size of the object) take 1, the rest bits take 0, and then the whole (height size of the object) is shifted by 1 bit toward the highest bit (the last row) every 1 clock pulse. When the bit equals 1, the output equals the input; when the bit equals 0, the output equals 0. The right side of the switch matrix is the calculation matrix. The calculation matrix is output by twice accumulation network, and each row output is the result M10 corresponding to the calculation height of the row. As indicated by M10_ a1 output as the first line (M' 00_ a1 input line) as the start line, the calculation result M10 of successively calculating the target height data (i.e., within the calculation box range) is output, the result of which is equal to the sum of the output data of each line multiplied by the corresponding line number. In the figure, the output of the label M10_ a2 is the second line (M' 00_ a2 input line) as the starting line, the calculation result M10 of continuously calculating the height data of the target object (namely, within the calculation box range) is output, and … … is analogized in turn. The second last row and the last row have no output significance because they are smaller than the number 3 of height dimensions of the object. The output will also stop at the last two rows according to the switch matrix shift register implementation. The above is the case of data output with the pointer position of 1 for each line of FIFO buffer. And after traversing the data with the pointer of 1 in the height direction, simultaneously reading the data with the pointer position of 2 of each FIFO buffer, representing the data as a calculation result of the target object moving 1 bit in the transverse direction, traversing in the height direction according to the above, and completing the traversing process of the whole image data stream by analogy.
Specifically, as shown in fig. 12, for a schematic diagram of a calculation circuit for calculating M20 data parameters during vertical traversal, updated M' 00 of the parameter M00 calculated by extracting the horizontal size of each row of the object is multiplied by the square of the row number of the corresponding row, and then the sum is accumulated vertically. The updated M' 00 of each line M00 can be read out from each line FIFO at the same time. Then through the switchThe matrix realizes traversal of the calculation box range in the height direction. As shown in fig. 12, the right side of the switch matrix is the calculation matrix. The calculation matrix is in left half diagonal distribution, fixed power times of input values of the row are obtained through fixed calculation, and if the first row (M '00 _ A1 input row) is only used for calculating 1 time coefficient output, the second row (M' 00_ A2 input row) needs to calculate 2 coefficient outputs which are 1 and 2 respectively2The third row (M' 00_ A3 input row) needs to calculate 3 coefficient outputs of 1 and 2 respectively2And 32Multiplication coefficient output, … … and so on, line 93 (M' 00_ A93 input line) requires calculation of 93 coefficient outputs of 1 and 2 respectively2、32、……、912、922And 932And outputting the multiplying factor. Then, the sum of the output data of the diagonal direction calculation matrix is taken, as indicated in fig. 12, the sum of all data in the diagonal virtual frame M20_ a1 is output as the M20 calculation result in the range of the first row of calculation blocks, the sum of all data in the diagonal virtual frame M20_ a2 is output as the M20 calculation result in the range of the second row of calculation blocks, and … … is analogized in turn. The second last row and the last row have no output significance because they are smaller than the number 3 of height dimensions of the object. The output will also stop at the last two rows according to the switch matrix shift register implementation. The above is the case of data output with the pointer position of 1 for each line of FIFO buffer. After the traversal of the data with the pointer of 1 in the height direction is completed, the data with the pointer position of 2 in each FIFO buffer is read at the same time, the data is expressed as a calculation result after the target object moves 1 bit in the transverse direction, and then the traversal in the height direction is performed according to the above.
Preferably, S3 specifically includes:
s31: obtaining the sum of the transverse zero-order geometric moments of the updated pixels under the corresponding longitudinal traversal of the image data stream according to all the transverse zero-order geometric moments of the updated pixels corresponding to each row of data of the image data stream; obtaining the sum of the first-order transverse geometrical moments of the updated pixels under the corresponding longitudinal traversal of the image data stream according to all the first-order transverse geometrical moments of the updated pixels corresponding to each row of data of the image data stream; obtaining the sum of the transverse second-order geometric moments of the updated pixels under the corresponding longitudinal traversal of the image data stream according to all the transverse second-order geometric moments of the updated pixels corresponding to each row of data of the image data stream;
s32: obtaining and outputting the actual geometric distance of the image data stream during each longitudinal traversal according to the pixel longitudinal first-order geometric moment and the pixel longitudinal second-order geometric moment of the image data stream during each longitudinal traversal, and the sum of the updated pixel transverse zero-order geometric moment, the sum of the updated pixel transverse first-order geometric moment and the sum of the updated pixel transverse second-order geometric moment under the corresponding longitudinal traversal;
calculating an actual geometric distance of the image data stream over a jth longitudinal pass:
Figure GDA0003568232010000161
wherein HjFor the actual geometric distance, A, of the image data stream during the jth longitudinal passjAnd BjM10, first and second intermediate parameters respectively, for calculating the actual geometric distance of the image data stream in the jth longitudinal passjAnd M20jThe pixel longitudinal first-order geometrical moment and the pixel longitudinal second-order geometrical moment in the jth longitudinal pass, sigma M' 00j、∑M′01jSum sigma M' 02jRespectively obtaining the sum of the transverse zero order geometrical moments of the update pixels, the sum of the transverse first order geometrical moments of the update pixels and the sum of the transverse second order geometrical moments of the update pixels in the jth longitudinal pass;
s33: and extracting and outputting the target geometric moment corresponding to the target object from the actual geometric distance of the image data stream during all longitudinal passes.
By the method for calculating the actual geometric moment of each longitudinal traversal, the actual geometric moment of each traversal calculation can be further ensured to be output in a pipeline mode, the CPU processing capacity is not occupied, and the calculation precision and the real-time performance are ensured at the same time.
Specifically, as shown in fig. 13, in order to calculate the summation Σ M '00 of the horizontal zeroth order geometric moments of the updated pixel, the calculation matrix on the right side of the switch matrix is a once-through summation network output, and each row outputs the result Σ M' 00 of the row in the corresponding longitudinal traversal. As Σ M '00 _ a1 is output as the first row as the start row in fig. 13, the calculation result Σ M' 00 output result within the calculation block range is successively obtained, the result of which is equal to the sum of the output data of each row; the sigma M '00 _ A2 is output as a second row as a starting row, and sigma M' 00 output results obtained continuously are obtained, and the operation is analogized in turn by … …; the second last row and the last row have no output significance because they are smaller than the number 3 of height dimensions of the object.
Specifically, as shown in fig. 14, a circuit diagram for calculating the sum Σ M '01 of the first-order geometric moments in the horizontal direction of the updated pixel, as shown in fig. 15, a circuit diagram for calculating the sum Σ M' 02 of the first-order geometric moments in the horizontal direction of the updated pixel, the same as fig. 13, and the details are not repeated herein.
Specifically, a calculation circuit diagram for calculating the actual geometric distance in the present embodiment is shown in fig. 16. In another preferred embodiment, the actual geometric distance H is calculated by multiplying by (Σ M' 00)3Amplifying it (Sigma M' 00)3Multiple, as H in FIG. 161And resources occupied by hardware can be further effectively reduced.
In a second embodiment, as shown in fig. 17, a device for calculating a geometric moment of a target object in an image, applied to the method for calculating a geometric moment of a target object in an image in the first embodiment, includes an integrated circuit board 1, and a data stream input circuit 2, a traversal calculation circuit 3, a target geometric moment extraction circuit 4, and an output circuit 5, which are respectively disposed on the integrated circuit board 1;
the integrated circuit board 1 is used for integrating the data stream input circuit 2, the traversal calculation circuit 3, the target geometric moment extraction circuit 4 and the output circuit 5 together;
the data stream input circuit 2 is configured to acquire an image data stream corresponding to an image containing a target object by using a hardware description language according to a preset data flow direction;
the traversal calculation circuit 3 is configured to obtain an image size and a target object pixel size, perform image traversal on the image data stream according to the image size and the target object pixel size in the preset data flow direction, and calculate an image geometric moment data set of the image data stream in each image traversal;
the traversal calculation circuit 3 is further configured to calculate, according to the image geometric moment data sets of the image data streams during each image traversal, actual geometric moments of the image data streams during each image traversal respectively;
the target geometric moment extraction circuit 4 is configured to extract a target geometric moment corresponding to the target object from all actual geometric moments in the image data stream;
the output circuit 5 is configured to output an actual geometric moment of the image data stream at each image pass, and is further configured to output the target geometric moment;
the integrated circuit board 1 is respectively electrically connected with the data stream input circuit 2, the traversal calculation circuit 3, the target geometric moment extraction circuit 4 and the output circuit 5, the data stream input circuit 2 is electrically connected with the output circuit 5 sequentially through the traversal calculation circuit 3 and the target geometric moment extraction circuit 4, and the traversal calculation circuit 3 is electrically connected with the output circuit 5.
Preferably, the traversal calculation circuit 3 is further specifically configured to:
obtaining single-row transverse traversal times and single-column longitudinal traversal times corresponding to the image data stream according to the image size and the target object pixel size;
obtaining the transverse image traversal times according to the transverse single-row traversal times and the image size, and obtaining the longitudinal image traversal times according to the transverse single-row traversal times and the longitudinal single-column traversal times;
the traversal calculation circuit 3 is further specifically configured to:
and obtaining a transverse traversal size and a longitudinal traversal size according to the pixel size of the target object.
Preferably, as shown in fig. 18, the traversal calculation circuit 3 includes a traverse calculation sub-circuit 31, a vertical traversal calculation sub-circuit 32, and a buffer 33;
the image geometrical moment data set comprises an updated image width geometrical moment set obtained after the image width geometrical moment set of the image data stream in each transverse pass is subjected to corresponding longitudinal traversal, and an image height geometrical moment set of the image data stream in each longitudinal pass;
the transverse traversal calculation sub-circuit 31 is specifically configured to:
according to the preset data flow direction, the transverse traversal size, the single-row transverse traversal times and the image transverse traversal times, carrying out transverse traversal on the image data stream line by line one by one, respectively calculating an image width geometric moment set of each row of data of the image data stream in each transverse traversal, and obtaining an image width geometric moment set corresponding to each row of data one by one according to the image width geometric moment sets of each row of data in all transverse traversals;
the buffer 33 is used for buffering a total set of geometric moments of all image widths;
the longitudinal traversal calculation sub-circuit 32 is specifically configured to:
after all transverse traversals are completed, sequentially performing longitudinal traversals on the image data stream according to the preset data flow direction, the longitudinal traversal size and the image longitudinal traversal times, respectively calculating an updated image width geometric moment set obtained after each image width geometric moment set is subjected to corresponding longitudinal traversal, and respectively calculating an image height geometric moment set of the image data stream during each longitudinal traversal by using a total set of all image width geometric moments;
the buffer 33 is further configured to buffer all updated image width geometric moment sets;
the transverse traversal calculation sub-circuit 31, the longitudinal traversal calculation sub-circuit 32, and the buffer 33 are electrically connected to the integrated circuit board 1, the transverse traversal calculation sub-circuit 31 is further electrically connected to the data stream input circuit 2, the longitudinal traversal calculation sub-circuit 32, and the buffer 33, the longitudinal traversal calculation sub-circuit 32 is further electrically connected to the data stream input circuit 2, the buffer 33, and the target geometric moment extraction circuit 4, and the buffer 33 is electrically connected to the target geometric moment extraction circuit 4.
Preferably, as shown in fig. 18, the traversal calculation circuit 3 further includes a first adder 34, a second adder 35, a third adder 36, and an actual geometric moment calculation sub-circuit 37;
the first adder 34 is configured to obtain a sum of the horizontal zero-order geometric moments of the updated pixels of the image data stream under the corresponding longitudinal traversal according to all the horizontal zero-order geometric moments of the updated pixels corresponding to each line of data of the image data stream;
the second adder 35 is configured to obtain a sum of first-order transverse geometric moments of the updated pixels of the image data stream under the corresponding longitudinal traversal according to all first-order transverse geometric moments of the updated pixels corresponding to each line of data of the image data stream;
the third adder 36 is configured to obtain a sum of the horizontal second-order geometric moments of the updated pixels under the corresponding longitudinal traversal of the image data stream according to all the horizontal second-order geometric moments of the updated pixels corresponding to each line of data of the image data stream;
the actual geometric moment calculating sub-circuit 37 is configured to obtain and output an actual geometric distance of the image data stream during each longitudinal pass according to the pixel longitudinal first-order geometric moment and the pixel longitudinal second-order geometric moment of the image data stream during each longitudinal pass, and a sum of updated pixel transverse zero-order geometric moments, a sum of updated pixel transverse first-order geometric moments, and a sum of updated pixel transverse second-order geometric moments under corresponding longitudinal traversal;
calculating an actual geometric distance of the image data stream over a jth longitudinal pass:
Figure GDA0003568232010000201
wherein HjFor the actual geometric distance, A, of the image data stream during the jth longitudinal passjAnd BjAre respectively asCalculating first and second intermediate parameters at an actual geometric distance of the image data stream for a jth longitudinal pass, M10jAnd M20jThe pixel longitudinal first-order geometrical moment and the pixel longitudinal second-order geometrical moment in the jth longitudinal pass, sigma M' 00j、∑M′01jSum sigma M' 02jRespectively obtaining the sum of the transverse zero order geometrical moments of the update pixels, the sum of the transverse first order geometrical moments of the update pixels and the sum of the transverse second order geometrical moments of the update pixels in the jth longitudinal pass;
the target geometric moment extraction circuit 4 is specifically configured to extract and output the target geometric moment corresponding to the target object from actual geometric distances of the image data stream during all longitudinal passes;
the first adder 34, the second adder 35, and the third adder 36 are each electrically connected to the buffer 33, the first adder 34, the second adder 35, the third adder 36, the longitudinal traversal calculating sub-circuit 32, and the target geometric moment extracting circuit 4 are each electrically connected to the actual geometric moment calculating sub-circuit 37, and the actual geometric moment calculating sub-circuit 37 is electrically connected to the output circuit 5.
Acquiring an image data stream corresponding to an image containing a target object through a data stream input circuit, wherein one pixel of the image data stream flows into a traversal calculation circuit according to a preset data flow direction, so that after the image size and the pixel size of the target object are acquired in advance, the traversal calculation circuit performs image traversal on the image data stream according to the preset data flow direction, and calculates an image geometric moment data set related to the geometric moment of the target object contained in the image data stream during each image traversal; after an image geometric moment data set traversed by each image is obtained, the traversal calculation circuit calculates the actual geometric moment under the image traversal according to the image geometric moment data set obtained by the corresponding image traversal and outputs the actual geometric moment in real time through the output circuit; the invention provides a solution method of pure hardware (digital circuit), which realizes traversal calculation of image data stream, outputs each traversal calculated geometric moment data (namely actual geometric moment) in a pipeline mode, does not occupy CPU processing capacity, can operate in an image processing system with higher frame rate, and simultaneously ensures calculation accuracy and real-time performance; after the actual geometric moments computed in each traversal are output in real time, the target geometric moments corresponding to the target objects can be matched and extracted from the actual geometric moments by utilizing preset template data of the target objects, and then the target geometric moments are output through an output circuit, so that the target objects in the image data stream can be positioned; because the image data stream can be an image data stream of a static image and can also be an image data stream corresponding to one frame of image in a dynamic video, when the target object in the image data stream corresponding to each frame of image in the video is respectively positioned, the dynamic visual tracking of the target object can be realized, and the method has important significance in the fields of aircraft tracking, vehicle tracking and pedestrian tracking.
In a specific embodiment, the circuit codes are written through a hardware description language and compiled through related compiling software to form an integrated circuit on the integrated circuit board. In this embodiment, details of each sub-circuit in the traversal calculation circuit are described in the first embodiment and the specific description in fig. 1 to 16, and are not repeated herein.
The above description is only for the purpose of illustrating the preferred embodiments of the present invention and is not to be construed as limiting the invention, and any modifications, equivalents, improvements and the like that fall within the spirit and principle of the present invention are intended to be included therein.

Claims (9)

1. A method for calculating geometric moments of a target object in an image, comprising the steps of:
step 1: acquiring an image data stream corresponding to an image containing a target object by adopting a hardware description language according to a preset data flow direction;
step 2: acquiring the size of an image and the size of a target object pixel, performing image traversal on the image data stream according to the image size and the size of the target object pixel according to the preset data flow direction, and respectively calculating an image geometric moment data set of the image data stream during each image traversal;
and step 3: respectively calculating actual geometric moments of the image data streams during each image pass according to the image geometric moment data sets of the image data streams during each image pass, outputting the actual geometric moments, extracting target geometric moments corresponding to the target object from all the actual geometric moments, and outputting the target geometric moments:
step 31: obtaining the sum of the transverse zero-order geometric moments of the updated pixels under the corresponding longitudinal traversal of the image data stream according to all the transverse zero-order geometric moments of the updated pixels corresponding to each row of data of the image data stream; obtaining the sum of the first-order transverse geometrical moments of the updated pixels under the corresponding longitudinal traversal of the image data stream according to all the first-order transverse geometrical moments of the updated pixels corresponding to each row of data of the image data stream; obtaining the sum of the transverse second-order geometric moments of the updated pixels under the corresponding longitudinal traversal of the image data stream according to all the transverse second-order geometric moments of the updated pixels corresponding to each row of data of the image data stream;
step 32: obtaining and outputting the actual geometric distance of the image data stream during each longitudinal traversal according to the pixel longitudinal first-order geometric moment and the pixel longitudinal second-order geometric moment of the image data stream during each longitudinal traversal, and the sum of the updated pixel transverse zero-order geometric moment, the sum of the updated pixel transverse first-order geometric moment and the sum of the updated pixel transverse second-order geometric moment under the corresponding longitudinal traversal;
calculating an actual geometric distance of the image data stream over a jth longitudinal pass:
Figure FDA0003568226000000021
wherein HjFor the actual geometric distance, A, of the image data stream during the jth longitudinal passjAnd BjM10, first and second intermediate parameters respectively, for calculating the actual geometric distance of the image data stream in the jth longitudinal passjAnd M20jFirst order of pixel longitudinals for jth longitudinal pass respectivelyWhich moment and pixel longitudinal second-order geometric moment, Σ M' 00j、∑M′01jSum sigma M' 02jRespectively obtaining the sum of the transverse zero order geometrical moments of the update pixels, the sum of the transverse first order geometrical moments of the update pixels and the sum of the transverse second order geometrical moments of the update pixels in the jth longitudinal pass;
step 33: and extracting and outputting the target geometric moment corresponding to the target object from the actual geometric distance of the image data stream during all longitudinal passes.
2. The method of claim 1, wherein the step 2 of image traversing the image data stream according to the image size and the target object pixel size comprises:
step 21: obtaining single-row transverse traversal times and single-column longitudinal traversal times corresponding to the image data stream according to the image size and the target object pixel size;
step 22: obtaining the transverse image traversal times according to the transverse single-row traversal times and the image size, and obtaining the longitudinal image traversal times according to the transverse single-row traversal times and the longitudinal single-column traversal times;
the step 21 further includes:
and obtaining a transverse traversal size and a longitudinal traversal size according to the pixel size of the target object.
3. The method of calculating geometric moments of a target object in an image according to claim 2, wherein in the step 2, the image traversal includes a transverse traversal and a longitudinal traversal; the image geometrical moment data set comprises an updated image width geometrical moment set obtained after the image width geometrical moment set of the image data stream in each transverse pass is subjected to corresponding longitudinal traversal, and an image height geometrical moment set of the image data stream in each longitudinal pass;
performing image traversal on the image data stream according to the image size and the target object pixel size, and respectively calculating an image geometric moment data set of the image data stream in each image traversal specifically includes:
step 23: according to the preset data flow direction, the transverse traversal size, the single-row transverse traversal times and the image transverse traversal times, carrying out transverse traversal on the image data stream line by line one by one, respectively calculating an image width geometric moment set of each row of data of the image data stream in each transverse traversal, obtaining an image width geometric moment set corresponding to each row of data one by one according to the image width geometric moment sets of each row of data in all transverse traversals, and caching all the image width geometric moment sets;
step 24: after all transverse traversals are completed, sequentially performing longitudinal traversals on the image data stream according to the preset data flow direction, the longitudinal traversal size and the image longitudinal traversal times, respectively calculating an updated image width geometric moment set obtained after each image width geometric moment set is subjected to corresponding longitudinal traversal, and caching all updated image width geometric moment sets; and respectively calculating a set of image height geometric moments of the image data stream in each longitudinal pass by using the total set of all image width geometric moments.
4. A method of calculating geometric moments of a target object in an image according to claim 3, wherein in said step 23, the set of image width geometric moments includes a pixel transverse zeroth order geometric moment, a pixel transverse first order geometric moment, and a pixel transverse second order geometric moment for each row of data of said image data stream at each transverse pass;
in step 24, updating the image width geometric moment set includes updating a pixel transverse zero-order geometric moment, updating a pixel transverse first-order geometric moment, and updating a pixel transverse second-order geometric moment, where the updating pixel transverse zero-order geometric moment is obtained after the pixel transverse zero-order geometric moment is longitudinally traversed correspondingly, the updating pixel transverse first-order geometric moment is obtained after the pixel transverse first-order geometric moment is longitudinally traversed correspondingly, and the updating pixel transverse second-order geometric moment is obtained after the pixel transverse second-order geometric moment is longitudinally traversed correspondingly;
the set of image height geometric moments includes a pixel longitudinal first order geometric moment and a pixel longitudinal second order geometric moment for each longitudinal pass of the image data stream.
5. A device for calculating the geometric moment of a target object in an image, applied to the method for calculating the geometric moment of the target object in the image according to any one of claims 1 to 4, comprising an integrated circuit board (1), and a data stream input circuit (2), a traversal calculation circuit (3), a target geometric moment extraction circuit (4) and an output circuit (5) which are respectively arranged on the integrated circuit board (1);
the integrated circuit board (1) is used for integrating the data stream input circuit (2), the traversal calculation circuit (3), the target geometric moment extraction circuit (4) and the output circuit (5);
the data stream input circuit (2) is used for acquiring an image data stream corresponding to an image containing a target object by adopting a hardware description language according to a preset data flow direction;
the traversal calculation circuit (3) is configured to acquire an image size and a target object pixel size, perform image traversal on the image data stream according to the image size and the target object pixel size in the preset data flow direction, and calculate an image geometric moment data set of the image data stream in each image traversal;
the traversal calculation circuit (3) is further configured to calculate, according to the image geometric moment data sets of the image data streams during each image traversal, actual geometric moments of the image data streams during each image traversal respectively;
the target geometric moment extraction circuit (4) is used for extracting a target geometric moment corresponding to the target object from all the actual geometric moments in the image data stream;
the output circuit (5) is used for outputting the actual geometrical moment of the image data stream in each image pass and outputting the target geometrical moment;
the integrated circuit board (1) is respectively electrically connected with the data stream input circuit (2), the traversal calculation circuit (3), the target geometric moment extraction circuit (4) and the output circuit (5), the data stream input circuit (2) is electrically connected with the output circuit (5) sequentially through the traversal calculation circuit (3) and the target geometric moment extraction circuit (4), and the traversal calculation circuit (3) is electrically connected with the output circuit (5).
6. Apparatus for computing the geometric moments of a target object in an image according to claim 5, characterized in that said traversal computation circuit (3) is further particularly adapted to:
obtaining single-row transverse traversal times and single-column longitudinal traversal times corresponding to the image data stream according to the image size and the target object pixel size;
obtaining the transverse image traversal times according to the transverse single-row traversal times and the image size, and obtaining the longitudinal image traversal times according to the transverse single-row traversal times and the longitudinal single-column traversal times;
the traversal calculation circuit (3) is further specifically configured to:
and obtaining a transverse traversal size and a longitudinal traversal size according to the pixel size of the target object.
7. The apparatus for computing geometric moments of a target object in an image according to claim 6, characterized in that said traversal computation circuit (3) comprises a transversal traversal computation sub-circuit (31), a longitudinal traversal computation sub-circuit (32) and a buffer (33);
the image geometrical moment data set comprises an updated image width geometrical moment set obtained after the image width geometrical moment set of the image data stream in each transverse pass is subjected to corresponding longitudinal traversal, and an image height geometrical moment set of the image data stream in each longitudinal pass;
the transversal traversal computation sub-circuit (31) is specifically configured to:
according to the preset data flow direction, the transverse traversal size, the single-row transverse traversal times and the image transverse traversal times, carrying out transverse traversal on the image data stream line by line one by one, respectively calculating an image width geometric moment set of each row of data of the image data stream in each transverse traversal, and obtaining an image width geometric moment set corresponding to each row of data one by one according to the image width geometric moment sets of each row of data in all transverse traversals;
the buffer (33) is used for buffering the total set of geometric moments of all image widths;
the vertical traversal calculation sub-circuit (32) is specifically configured to:
after all transverse traversals are completed, sequentially performing longitudinal traversals on the image data stream according to the preset data flow direction, the longitudinal traversal size and the image longitudinal traversal times, respectively calculating an updated image width geometric moment set obtained after each image width geometric moment set is subjected to corresponding longitudinal traversal, and respectively calculating an image height geometric moment set of the image data stream during each longitudinal traversal by using a total set of all image width geometric moments;
the buffer (33) is also used for buffering all the updated image width geometric moment sets;
the transverse traversal computation sub-circuit (31), the longitudinal traversal computation sub-circuit (32) and the buffer (33) are respectively electrically connected with the integrated circuit board (1), the transverse traversal computation sub-circuit (31) is further respectively connected with the data stream input circuit (2), the longitudinal traversal computation sub-circuit (32) and the buffer (33) are electrically connected, the longitudinal traversal computation sub-circuit (32) is further respectively connected with the data stream input circuit (2), the buffer (33) and the target geometric moment extraction circuit (4) are electrically connected, and the buffer (33) is electrically connected with the target geometric moment extraction circuit (4).
8. The apparatus according to claim 7, wherein the set of image width geometric moments comprises a pixel transverse zeroth order geometric moment, a pixel transverse first order geometric moment, and a pixel transverse second order geometric moment for each row of data of the image data stream on each transverse pass;
the updated image width geometric moment set comprises an updated pixel transverse zero-order geometric moment, an updated pixel transverse first-order geometric moment and an updated pixel transverse second-order geometric moment, wherein the updated pixel transverse zero-order geometric moment is obtained after the pixel transverse zero-order geometric moment is subjected to corresponding longitudinal traversal, the updated pixel transverse first-order geometric moment is obtained after the pixel transverse first-order geometric moment is subjected to corresponding longitudinal traversal, and the updated pixel transverse second-order geometric moment is obtained after the pixel transverse second-order geometric moment is subjected to corresponding longitudinal traversal;
the set of image height geometric moments includes a pixel longitudinal first order geometric moment and a pixel longitudinal second order geometric moment for each longitudinal pass of the image data stream.
9. The apparatus for calculating geometric moments of target objects in images according to claim 8, wherein said traversal calculation circuit (3) further comprises a first adder (34), a second adder (35), a third adder (36), and an actual geometric moment calculation sub-circuit (37);
the first adder (34) is configured to obtain a sum of the horizontal zero-order geometric moments of the updated pixels of the image data stream under the corresponding longitudinal traversal according to all the horizontal zero-order geometric moments of the updated pixels corresponding to each line of data of the image data stream;
the second adder (35) is configured to obtain a sum of first-order transverse geometrical moments of the updated pixels of the image data stream under the corresponding longitudinal traversal according to all first-order transverse geometrical moments of the updated pixels corresponding to each line of data of the image data stream;
the third adder (36) is configured to obtain a sum of the horizontal second order geometric moments of the updated pixels of the image data stream under the corresponding longitudinal traversal according to all the horizontal second order geometric moments of the updated pixels corresponding to each line of data of the image data stream;
the actual geometric moment calculation sub-circuit (37) is used for obtaining and outputting the actual geometric distance of the image data stream during each longitudinal traversal according to the pixel longitudinal first-order geometric moment and the pixel longitudinal second-order geometric moment of the image data stream during each longitudinal traversal, and the sum of the updated pixel transverse zero-order geometric moment, the sum of the updated pixel transverse first-order geometric moment and the sum of the updated pixel transverse second-order geometric moment under the corresponding longitudinal traversal;
calculating an actual geometric distance of the image data stream over a jth longitudinal pass:
Figure FDA0003568226000000071
wherein HjFor the actual geometric distance, A, of the image data stream during the jth longitudinal passjAnd BjM10, first and second intermediate parameters respectively, for calculating the actual geometric distance of the image data stream in the jth longitudinal passjAnd M20jThe pixel longitudinal first-order geometrical moment and the pixel longitudinal second-order geometrical moment in the jth longitudinal pass, sigma M' 00j、∑M′01jSum sigma M' 02jRespectively obtaining the sum of the transverse zero order geometrical moments of the update pixels, the sum of the transverse first order geometrical moments of the update pixels and the sum of the transverse second order geometrical moments of the update pixels in the jth longitudinal pass;
the target geometric moment extraction circuit (4) is specifically used for extracting and outputting the target geometric moment corresponding to the target object from the actual geometric distances of the image data stream during all longitudinal passes;
the first adder (34), the second adder (35) and the third adder (36) are electrically connected to the buffer (33), respectively, the first adder (34), the second adder (35), the third adder (36), the longitudinal traversal calculating sub-circuit (32) and the target geometric moment extracting circuit (4) are electrically connected to the actual geometric moment calculating sub-circuit (37), and the actual geometric moment calculating sub-circuit (37) is electrically connected to the output circuit (5).
CN202010554845.0A 2020-06-17 2020-06-17 Method and device for calculating geometric moment of target object in image Active CN111738904B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010554845.0A CN111738904B (en) 2020-06-17 2020-06-17 Method and device for calculating geometric moment of target object in image

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010554845.0A CN111738904B (en) 2020-06-17 2020-06-17 Method and device for calculating geometric moment of target object in image

Publications (2)

Publication Number Publication Date
CN111738904A CN111738904A (en) 2020-10-02
CN111738904B true CN111738904B (en) 2022-05-17

Family

ID=72649566

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010554845.0A Active CN111738904B (en) 2020-06-17 2020-06-17 Method and device for calculating geometric moment of target object in image

Country Status (1)

Country Link
CN (1) CN111738904B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112669296B (en) * 2020-12-31 2023-09-26 江苏南高智能装备创新中心有限公司 Defect detection method, device and equipment of numerical control punch die based on big data

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101425173A (en) * 2007-10-31 2009-05-06 中国科学院沈阳自动化研究所 Method for rapidly calculating geometric moment and central moment of rapid image
US9934590B1 (en) * 2015-06-25 2018-04-03 The United States Of America As Represented By The Secretary Of The Air Force Tchebichef moment shape descriptor for partial point cloud characterization
CN109784372A (en) * 2018-12-17 2019-05-21 北京理工大学 A kind of objective classification method based on convolutional neural networks

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101425173A (en) * 2007-10-31 2009-05-06 中国科学院沈阳自动化研究所 Method for rapidly calculating geometric moment and central moment of rapid image
US9934590B1 (en) * 2015-06-25 2018-04-03 The United States Of America As Represented By The Secretary Of The Air Force Tchebichef moment shape descriptor for partial point cloud characterization
CN109784372A (en) * 2018-12-17 2019-05-21 北京理工大学 A kind of objective classification method based on convolutional neural networks

Non-Patent Citations (4)

* Cited by examiner, † Cited by third party
Title
Geometric invariance in image wa-termarking;Alghoniemy M,Tewfik A H;《IEEE Transactions on Image Processing》;20041231;全文 *
一种计算图像几何矩的快速算法;陈优广等;《计算机应用与软件》;20071115(第11期);全文 *
图像几何特征参数快速提取算法;杨程等;《计算机工程与科学》;20120715(第07期);全文 *
通过积分图多项式方法快速计算图像中心矩和Hu距;郭宇航;《电脑与电信》;20180310(第03期);全文 *

Also Published As

Publication number Publication date
CN111738904A (en) 2020-10-02

Similar Documents

Publication Publication Date Title
KR102647858B1 (en) Low-power hardware acceleration method and system for convolution neural network computation
Yepez et al. Stride 2 1-D, 2-D, and 3-D Winograd for convolutional neural networks
US9020276B2 (en) Hardware coprocessor for stripe-based interest point detection
US11704543B2 (en) Neural network hardware acceleration with stochastic adaptive resource allocation
Tomasi et al. High-performance optical-flow architecture based on a multi-scale, multi-orientation phase-based model
Athalye et al. Generic hardware architectures for sampling and resampling in particle filters
US10402196B2 (en) Multi-dimensional sliding window operation for a vector processor, including dividing a filter into a plurality of patterns for selecting data elements from a plurality of input registers and performing calculations in parallel using groups of the data elements and coefficients
CN1987928A (en) Device for real time quick realizing Gauss formwork convolution
CN111738904B (en) Method and device for calculating geometric moment of target object in image
Tomasi et al. Massive parallel-hardware architecture for multiscale stereo, optical flow and image-structure computation
CN108717571A (en) A kind of acceleration method and device for artificial intelligence
CN107169982A (en) A kind of quantum LoG edge detection methods
CN107851088A (en) There is the two dimensional discrete Fourier transform that edge artifacts remove simultaneously for what is applied in real time
CN112396657A (en) Neural network-based depth pose estimation method and device and terminal equipment
CN103208094A (en) Method and system for applying filter to image
CN115546373A (en) NeRF renderer based on FPGA and multi-resolution Hash coding algorithm and rendering method
Schiwietz et al. GPU-PIV.
Liu et al. SURFEX: A 57fps 1080P resolution 220mW silicon implementation for simplified speeded-up robust feature with 65nm process
CN114820755B (en) Depth map estimation method and system
Ni et al. FPGA-based Binocular image feature extraction and matching system
Fathi et al. Low-cost and real-time hardware implementation of stereo vision system on FPGA
Kalms et al. FPGA based hardware accelerator for KAZE feature extraction algorithm
Nickel et al. High-performance AKAZE implementation including parametrizable and generic HLS modules
Lee et al. Hardware design of a context-preserving filter-reorganized CNN for super-resolution
CN116957908B (en) Hardware processing architecture, processor and electronic equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant