Regional people counting method, computer device, and computer-readable storage medium
By detecting the position of the human body parts in the image and determining its physical position in combination with the transformation relationship, the secondary comparison method is used to determine whether the human body is located in the sub-region, which solves the problem of low accuracy in the number of people statistics in the prior art, and achieves higher accuracy and speed.
Patent Information
- Application Number
- CN202080002165.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-09-29
- Publication Date
- 2025-08-15
- Estimated Expiration
- 2040-09-29
AI Technical Summary
The existing open area population statistics method has the problem of low accuracy, especially when judging that the human body is located in a sub-region, errors are easily generated.
By detecting the position of the human body in the image, and determining its position in the physical world in combination with the transformation relationship, combining the relative relationship between the image position and the physical position, a secondary comparison method is used to determine whether the human body part is in the sub-region, thereby counting the number of people in the sub-region.
The accuracy and speed of people statistics are improved, especially by detecting the position of the human head and combining deep learning algorithms, the detection speed and accuracy are enhanced.
Smart Images

Figure CN114787882B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of display technology, and in particular to a method for counting people in an area, a computer device, and a computer-readable storage medium. Background Art
[0002] In the field of video surveillance, it is often necessary to count the number of people in the monitored area. A relatively accurate headcount result is one of the important parameters for crowd safety. It can also provide valuable guidance information for industries such as resource management, public transportation, and advertising.
[0003] For counting people in an open area, the open area is usually divided into multiple sub-areas and the number of people in each sub-area is counted separately. However, the current counting method has the problem of low accuracy. Summary of the Invention
[0004] The embodiments of the present disclosure provide a method for counting people in an area, a computer device, and a computer-readable storage medium.
[0005] In a first aspect, the present disclosure provides a method for counting people, comprising:
[0006] Acquire an image to be analyzed of a target area, wherein the target area includes at least one sub-area, and the image to be analyzed includes at least one sub-image, and the sub-image corresponds to the sub-area in a one-to-one manner;
[0007] Detecting the position of each first human body part in the image to be analyzed;
[0008] determining a physical position of each first human body part in the target area based on the position of each first human body part in the image to be analyzed and a first transformation relationship; wherein the first transformation relationship is a transformation relationship between the physical position of the first human body part in the target area and the position in the image to be analyzed;
[0009] The number of people in each sub-region is determined based on the relative positional relationship between the position of the first human body part in the image to be analyzed and the sub-image, and the relative positional relationship between the physical position of the first human body part and the sub-region.
[0010] In some embodiments, the first human body part includes a head; and the regional people counting method further includes:
[0011] Acquiring a calibration image of the target area;
[0012] determining the first transformation relationship according to the physical position of the preset portion of the marker object in the target area and the image position of the preset portion of the marker object in the calibration image;
[0013] Get the physical extent of the sub-region.
[0014] In some embodiments, the height of the marking object is within the standard human height range, and the preset position of the marking object is the top of the marking object.
[0015] In some embodiments, obtaining the physical range of the sub-area includes:
[0016] Determining a second transformation relationship based on the physical position of the bottom of the marker object and the position of the bottom of the marker object in the calibration image; wherein the second transformation relationship is a transformation relationship between the physical position of the bottom of the marker object and the position of the bottom of the marker object in the calibration image;
[0017] Obtaining positions of a plurality of feature points for defining the sub-region in the calibration image;
[0018] Determining the physical position of each feature point according to the position of each feature point in the calibration image and the second transformation relationship;
[0019] The physical range of the sub-region is determined according to the physical positions of the plurality of feature points.
[0020] In some embodiments, there are multiple marker objects in the target area, and the first transformation relationship includes a first position transformation matrix, which is determined according to the following formula (1):
[0021]
[0022] Among them, H_1 is the first position transformation matrix; X is a one-dimensional vector composed of the horizontal coordinates of the tops of multiple marking objects in the physical world coordinate system; Y is a one-dimensional vector composed of the vertical coordinates of the bottoms of multiple marking objects in the physical world coordinate system; u is a one-dimensional vector composed of the horizontal coordinates of the tops of multiple marking objects in the calibration image; v is a one-dimensional vector composed of the vertical coordinates of the tops of multiple marking objects in the calibration image.
[0023] In some embodiments, the second transformation relationship includes a second position transformation matrix, and the second position transformation matrix is determined according to the following formula (2):
[0024]
[0025] Among them, H_2 is the second position transformation matrix; uu is a one-dimensional vector composed of the horizontal coordinates of the bottoms of multiple marker objects in the calibration image; vv is a one-dimensional vector composed of the vertical coordinates of the bottoms of multiple marker objects in the calibration image.
[0026] In some embodiments, determining the number of people in each sub-region based on the relative positional relationship between the position of the first human body part in the image to be analyzed and the sub-image, and the relative positional relationship between the physical position of the first human body part and the sub-region, includes:
[0027] For each of the sub-regions, a secondary comparison method is used to determine whether each of the first human body parts is located within the sub-region, and the number of people in the sub-region is determined based on the determination result;
[0028] Among them, the secondary comparison method includes: judging whether the position of the first human body part in the image to be analyzed is within the range of the sub-image; when the position of the first human body part in the image to be analyzed is within the range of the sub-image, judging whether the physical position of the first human body part is within the range of the sub-area; when the physical position of the first human body part is within the range of the sub-area, determining that the first human body part is within the sub-area.
[0029] In some embodiments, determining whether the position of the first human body part in the image to be analyzed is within the range of the sub-image includes:
[0030] Determining whether a first reference line and a boundary of the sub-image have an intersection; wherein the first reference line is a straight line passing through the position of the first human body part in the image to be analyzed;
[0031] When the first reference line intersects the boundary of the sub-image, and an odd number of intersections exist on both sides of the position of the first human body part in the image to be analyzed, determining that the position of the first human body part in the image to be analyzed is within the range of the sub-image;
[0032] Determining whether the physical location of the first human body part is within the sub-area includes:
[0033] Determining whether a second reference line intersects a boundary of the sub-region; wherein the second reference line is a straight line passing through the physical position of the first human body part;
[0034] When the second reference line intersects the boundary of the sub-region, and there are an odd number of intersections on both sides of the physical position of the first human body part, it is determined that the physical position of the first human body part is located within the sub-region.
[0035] In some embodiments, the position of the first human body part in the image to be analyzed is detected by a target detection algorithm based on deep learning.
[0036] In a second aspect, an embodiment of the present disclosure further provides a computer device, comprising:
[0037] processor;
[0038] A memory having a program stored thereon, wherein when the program is executed by the processor, the following steps are implemented:
[0039] Acquire an image to be analyzed of a target area, wherein the target area includes at least one sub-area, and the image to be analyzed includes at least one sub-image, and the sub-image corresponds to the sub-area in a one-to-one manner;
[0040] Detecting the position of each first human body part in the image to be analyzed;
[0041] determining a physical position of each first human body part in the target area based on the position of each first human body part in the image to be analyzed and a first transformation relationship; wherein the first transformation relationship is a transformation relationship between the physical position of the first human body part in the target area and the position in the image to be analyzed;
[0042] The number of people in each sub-region is determined based on the relative positional relationship between the position of the first human body part in the image to be analyzed and the sub-image, and the relative positional relationship between the physical position of the first human body part and the sub-region.
[0043] In some embodiments, the first body part includes the head;
[0044] When the program is executed by the processor, the following steps are further implemented:
[0045] Acquiring a calibration image of the target area;
[0046] determining the first transformation relationship according to the physical position of the preset portion of the marker object in the target area and the image position of the preset portion of the marker object in the calibration image;
[0047] Get the physical extent of the sub-region.
[0048] In a third aspect, an embodiment of the present disclosure further provides a computer-readable storage medium having a computer program stored thereon, wherein the program implements the above-mentioned method for counting people in an area when executed by a processor. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] The accompanying drawings are used to provide a further understanding of the present disclosure and constitute a part of the specification. Together with the following detailed description, they are used to explain the present disclosure but do not constitute a limitation of the present disclosure. In the accompanying drawings:
[0050] Figure 1 A flowchart of a method for counting people in an area provided by an embodiment of the present disclosure.
[0051] Figure 2 A flowchart of another method for counting people in an area provided by an embodiment of the present disclosure.
[0052] Figure 3 This is a flow chart of the secondary alignment method provided in an embodiment of the present disclosure.
[0053] Figure 4A This is a schematic diagram of an embodiment of the present disclosure when the image position of the first human body part on the image to be analyzed is within the range of the sub-image.
[0054] Figure 4B This is a schematic diagram showing that the image position of the first human body part on the image to be analyzed is outside the range of the sub-image provided in an embodiment of the present disclosure.
[0055] Figure 5 A schematic diagram of a device for counting people in an area provided by an embodiment of the present disclosure.
[0056] Figure 6 A schematic diagram of another device for counting people in an area provided in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0057] The following describes the specific embodiments of the present disclosure in detail with reference to the accompanying drawings. It should be understood that the specific embodiments described herein are only used to illustrate and explain the present disclosure and are not intended to limit the present disclosure.
[0058] In related art, when calculating the distribution statistics of the number of people in multiple sub-areas within an open area, an image of the open area is first captured, and the position of the human body in the image is detected. The human body position in the image is then compared with the position of the sub-areas in the image to determine which sub-area the human body is located in, and then the number of people in each sub-area is counted. However, in the captured image, the head and feet of the human body are often in different positions. As a result, the image may show a situation where part of the human body has entered a sub-area while another part of the human body is outside of the sub-area. This can easily lead to errors in determining which sub-area the human body is located in, resulting in inaccurate statistical results.
[0059] Figure 1 A flowchart of a method for counting people in an area provided by an embodiment of the present disclosure is shown in FIG. Figure 1As shown, the methods for counting people in this area include:
[0060] Step S1: Acquire an image of a target area to be analyzed, wherein the target area includes at least one sub-area, and the image to be analyzed includes at least one sub-image, with each sub-image corresponding to each sub-area. The image to be analyzed may be an image of the target area captured by an image acquisition device such as a camera, and the sub-image may be an image of the sub-area captured by the image acquisition device. Alternatively, the image acquisition device may acquire images of the target area in real time, and step S1 may be performed for each frame of image captured by the image acquisition device, or may be performed at a predetermined frequency.
[0061] For example, the number of sub-images and sub-regions is plural.
[0062] Step S2: Detecting the image position of each first human body part in the image to be analyzed.
[0063] The first human body part is a part that can represent the position of the human body. For example, the first human body part can be the head or the shoulder.
[0064] Step S3: Determine the physical position of each first human body part in the target area according to the image position of each first human body part and the first transformation relationship.
[0065] In the disclosed embodiments, the "physical position" refers to the corresponding position in the physical world. The first transformation relationship is the transformation relationship between the physical position of the first human body part in the three-dimensional physical world and its image position in the image to be analyzed. For example, the first transformation relationship is a mapping relationship table; another example is a perspective projection matrix. The first transformation relationship can be obtained in advance before step S1.
[0066] Step S4: Determine the number of people in each sub-region based on the relative positional relationship between the image position of the first human body part and the sub-image, and the relative positional relationship between the physical position of the first human body part and the sub-region.
[0067] In the embodiment of the present disclosure, the relative position relationship between the image position of the first human body part and the sub-image refers to whether the image position of the first human body part is located within the sub-image range or outside the sub-image range; the relative position relationship between the physical position of the first human body part and the sub-area refers to whether the physical position of the first human body part is located within the sub-area range or outside the sub-area range.
[0068] In step S4, when determining the number of people within a sub-region, it is possible to first determine whether each first human body part is within the sub-region, and then determine the number of people within the sub-region. When both of the following two conditions are met, the first human body part is determined to be within the sub-region; when at least one of the following two conditions is not met, the first human body part is determined to be outside the sub-region.
[0069] Condition 1: The image position of the first human body part is within the sub-image range.
[0070] Condition 2: The physical location of the first human body part is within the sub-area.
[0071] Therefore, when it is determined that the first condition is not met, it is no longer necessary to determine whether the second condition is met; or, when it is determined that the second condition is not met, it is no longer necessary to determine whether the first condition is met.
[0072] After completing step S4, the number of people in each sub-area may be sent to an output device for output. For example, the output device is a display that displays the number of people in each physical area.
[0073] In an embodiment of the present disclosure, when counting the number of people in each sub-area, the number of people in the sub-area is determined in combination with the positional relationship between the image position of the first human body part and the sub-image, as well as the positional relationship between the first human body part and the sub-area. Whether compared with a method of judging whether the human body is located in the sub-area only by the position between the image position of the first human body part and the sub-image, or compared with a method of judging whether the human body is located in the sub-area only by the position between the physical position of the first human body part and the sub-area, the statistical method of the embodiment of the present disclosure can improve the accuracy of the statistics.
[0074] In some embodiments, the first human body part includes a head. By detecting the position and physical location of the human head in the image to be analyzed to determine the number of people, the accuracy of the head count can be improved. Furthermore, when the first human body part includes the head, an object detection algorithm can be used to detect the position of the human head in the image to be analyzed, thereby improving detection speed.
[0075] Figure 2 A flowchart of another method for counting people in an area provided by an embodiment of the present disclosure is shown in FIG. Figure 2 As shown, the regional people counting method includes:
[0076] Step S01: Acquire a calibration image of a target area, wherein the calibration image may be an image of the target area acquired by an image acquisition device.
[0077] Step S02: Determine a first transformation relationship based on the physical location of the predetermined portion of the marker object in the target area and the image position of the predetermined portion of the marker object in the calibration image. For example, the image position of the predetermined portion of the marker object in the calibration image can be obtained using a target detection method; however, other methods may also be used.
[0078] Optionally, there are multiple marking objects, and the marking objects can be objects at the marking points of the target area, such as a human model, an upright pole, or a real person. The height of the marking object is within the standard human height range, and the preset position of the marking object is the top of the marking object. It should be noted that the standard human height range is the height range of a regular adult, for example, 1.5m to 2m. It should also be noted that the marking object is set on the ground in the target area, the top of the marking object is the end away from the ground, and the bottom of the marking object is the end close to the ground.
[0079] In some embodiments, the first transformation relationship includes a first position transformation matrix H_1, which is determined according to the following formula (1):
[0080]
[0081] Where X is a one-dimensional vector consisting of the horizontal coordinates of the tops of the multiple marker objects in the physical world coordinate system; Y is a one-dimensional vector consisting of the vertical coordinates of the bottoms of the multiple marker objects in the physical world coordinate system. u is a one-dimensional vector consisting of the horizontal coordinates of the tops of the multiple marker objects in the calibration image; v is a one-dimensional vector consisting of the vertical coordinates of the tops of the multiple marker objects in the calibration image. It should be noted that the physical world coordinate system is a two-dimensional plane coordinate system located on a horizontal plane. Therefore, the coordinates of the top and bottom of the marker objects in the physical world coordinate system are the same. However, since the image acquisition device does not necessarily acquire images from directly above the marker objects, the coordinates of the top and bottom of the marker objects in the calibration image are not necessarily the same. In addition, an image coordinate system can be established on the calibration image; the coordinates of the top (bottom) of the marker object in the calibration image are the coordinates of the top (bottom) of the marker object in the image coordinate system.
[0082] For example, there are four marker objects, and the coordinates of the tops of the four marker objects in the physical world coordinate system are (X1, Y1), (X2, Y2), (X3, Y3), and (X4, Y4). The coordinates of the bottom and top of each marker object in the physical world coordinate system are the same. The coordinates of the tops of the four marker objects in the calibration image are: (u1, v1), (u2, v2), (u3, v3), and (u4, v4). Then the above formula (1) is:
[0083]
[0084] Step S03: Acquire the physical range of the sub-region, that is, the range enclosed by the boundary of the sub-region in the target area.
[0085] For example, by obtaining the physical positions of multiple feature points of the boundary of the sub-region, the physical position of the boundary of the sub-region is determined based on the physical positions of the multiple feature points. Among them, multiple feature points are used to define the sub-region. For example, the sub-region is a polygonal region, and the multiple feature points are multiple corner points of the sub-region. The position of the feature point can be obtained by field measurement in the physical world, or it can be calculated based on the image position of the feature point in the calibration image and the position change relationship. In actual applications, the number of sub-regions is large and each sub-region has many feature points. In this case, it will be inconvenient to use the field measurement method. Therefore, in some embodiments, the physical position of the feature point can be obtained by calculation, and then the physical range of the sub-region can be obtained. Specifically, step S03 includes:
[0086] Step S031: Determine a second transformation relationship based on the physical position of the bottom of the marker object and its image position in the calibration image. The second transformation relationship is the transformation relationship between the physical position of the bottom of the marker object and its image position in the calibration image.
[0087] Optionally, the second transformation relationship includes a second position transformation matrix H_2, and the second position transformation matrix H_2 is determined according to the following formula (2):
[0088]
[0089] Among them, uu is a one-dimensional vector composed of the horizontal coordinates of the bottoms of multiple landmark objects in the calibration image; vv is a one-dimensional vector composed of the vertical coordinates of the bottoms of multiple landmark objects in the calibration image.
[0090] For example, there are four marker objects, and the coordinates of the bottoms of the four marker objects in the physical world coordinate system are (X1, Y1), (X2, Y2), (X3, Y3), and (X4, Y4). The coordinates of the tops of the four marker objects in the calibration image are: (uu1, vv1), (uu2, vv2), (uu3, vv3), and (uu4, vv4). Then the above formula (2) is:
[0091]
[0092] Step S032: Obtain the image positions of a plurality of feature points used to define a sub-region in the calibration image. For example, the sub-region is a polygonal region, and the feature points are corner points of the polygon.
[0093] Step S033: determining the physical position of each of the plurality of feature points according to the image position of each feature point in the calibration image and the second transformation relationship.
[0094] Step S034: Determine the physical range of the sub-region according to the physical positions of the multiple feature points.
[0095] After step S03, the method for counting people in an area further includes the following steps S1 to S4:
[0096] Step S1: Acquire an image of the target area to be analyzed. The image to be analyzed can be acquired by an image acquisition device. The image to be analyzed and the calibration image are acquired by the same image acquisition device, which is installed at the same position and angle. It should be noted that in actual applications, steps S01-S03 may be performed once after the image acquisition device is first installed, followed by performing a headcount count using steps S1-S4. If the image acquisition device is subsequently stationary, steps S01-S03 may not be performed.
[0097] Step S2: Detecting the image position of each first human body part in the image to be analyzed.
[0098] Optionally, the first human body part includes a head. The image position of the head in the image to be analyzed can be detected using a deep learning-based object detection algorithm to improve detection speed and accuracy. For example, the object detection algorithm may be SSD (Single Shot MultiBox Detector) or YOLO (You Only Look Once). The image position of the first human body part can be the coordinates of the top of the head detection frame in the image to be analyzed.
[0099] Step S3: Determine the physical position of each first human body part in the target area based on the image position of each first human body part and the first transformation relationship. The physical position of the first human body part in the target area is the coordinate of the first human body part in the target area, which is expressed as a two-dimensional coordinate.
[0100] For example, the first transformation relationship includes the above-mentioned first position transformation matrix H_1, where the image position (i.e., coordinates) of a first human body part is (ui, vi), and the physical position (i.e., coordinates) of the first human body part is (Xi, Yi), where Xi and Yi are obtained according to the following formula (3):
[0101]
[0102] Step S4: Determine the number of people in each sub-region based on the relative positional relationship between the image position of the first human body part and the sub-image, and the relative positional relationship between the physical position of the first human body part and the sub-region.
[0103] In some embodiments, step S4 includes:
[0104] For each sub-region, a determination is made as to whether each first human body part is located within the sub-region in the physical world, and the number of people within the sub-region is determined based on the determination result. A two-level comparison method may be used to determine whether any key human body part is located within the sub-region.
[0105] Figure 3 This is a flow chart of the secondary comparison method provided in the embodiment of the present disclosure, such as Figure 3 As shown, the secondary comparison method may specifically include:
[0106] Step S401, determine whether the image position of the first human body part on the image to be analyzed is within the range of the sub-image. If so, proceed to step S402; if not, determine that the first human body part is outside the sub-region in the physical world.
[0107] Figure 4A This is a schematic diagram of a case where the image position of the first human body part on the image to be analyzed is within the range of the sub-image provided in an embodiment of the present disclosure. Figure 4B This is a schematic diagram of an embodiment of the present disclosure in which the image position of the first human body part on the image to be analyzed is outside the range of the sub-image, as shown in FIG. Figure 4A and Figure 4B As shown, the image position of the first human body part on the image to be analyzed is position A. The process of determining whether the image position of the first human body part on the image to be analyzed is within the range of the sub-image may specifically include:
[0108] Determine whether the first reference line L1 passing through position A intersects with the boundary E1 of the sub-image; Figure 4A As shown, when the first reference line L1 intersects with the boundary E1 of the sub-image, and there are an odd number of intersections on both sides of position A, it is determined that the image position of the first human body part is within the range of the sub-image. Figure 4B As shown, when the first reference line L1 intersects the boundary E1 of the sub-image, and the intersection is on the same side as position A, position A is determined to be outside the range of the sub-image. When the first reference line L1 does not intersect the boundary E1 of the sub-image, position A is also determined to be outside the range of the sub-image.
[0109] Exemplarily, the first reference line L1 is: a straight line extending horizontally on the image to be analyzed, that is, the vertical coordinates of each point on the first reference line L1 are the same; or, the first reference line L1 is a straight line extending vertically, that is, the horizontal coordinates of each point on the first reference line L1 are the same.
[0110] Step S402: determine whether the physical position of the first human body part is within the range of the sub-region. If so, determine that the first human body part is within the sub-region in the physical world; if not, determine that the first human body part is outside the sub-region in the physical world. At this time, no other judgment is required to reduce the amount of calculation and improve the processing speed.
[0111] The process of determining whether the physical position of the first human body part is within the scope of the sub-area is similar to the determination process in the above-mentioned step S401, and may specifically include: determining whether there is an intersection between the second reference line and the boundary of the sub-area; wherein the second reference line is a straight line passing through the physical position of the first human body part; when there is an intersection between the second reference line and the boundary of the sub-area, and there are an odd number of intersections on both sides of the physical position of the first human body part, it is determined that the physical position of the first human body part is within the sub-area.
[0112] It should be noted that the above steps S01 to S03 may be performed before step S1 or after step S1.
[0113] Figure 5 A schematic diagram of a regional people counting device provided by an embodiment of the present disclosure, such as Figure 5 As shown, the device for counting people in an area includes: a first acquisition module 10 , a detection module 20 , a position determination module 30 and a counting module 40 .
[0114] The first acquisition module 10 is configured to acquire an image to be analyzed of a target area, where the target area includes at least one sub-area, and the image to be analyzed includes at least one sub-image, and the sub-images correspond to the sub-areas in a one-to-one manner.
[0115] The detection module 20 is configured to detect the position of each first human body part in the image to be analyzed.
[0116] The position determination module 30 is configured to determine the physical position of each first human body part in the target area based on the position of each first human body part in the image to be analyzed and a first transformation relationship, where the first transformation relationship is the transformation relationship between the physical position of the object and the position in the image to be analyzed.
[0117] The statistical module 40 is configured to determine the number of people in each sub-region based on the relative position relationship between the position of the first human body part in the image to be analyzed and the sub-image, and the relative position relationship between the physical position of the first human body part and the sub-region.
[0118] Figure 6 This is a schematic diagram of another regional people counting device provided in an embodiment of the present disclosure, such as Figure 6 As shown, in some embodiments, the regional people counting apparatus further includes: a second acquisition module 50, a relationship generation module 60, and a sub-region calibration module 70. The second acquisition module 50 is configured to acquire a calibration image of the target region. The relationship generation module 60 is configured to determine the first transformation relationship based on the physical position of the top of the landmark object in the target region. The sub-region calibration module 70 is configured to acquire the physical range of the sub-region.
[0119] The functions of each module are described in the above-mentioned regional people counting method and will not be repeated here.
[0120] The present disclosure also provides a computer device comprising a processor and a memory. The memory stores a program that, when executed by the processor, implements the method for counting people in an area according to the above embodiment.
[0121] An embodiment of the present disclosure further provides a computer-readable storage medium having a computer program stored thereon, wherein when the program is executed by a processor, the method for counting people in an area in the above embodiment is implemented.
[0122] The aforementioned memory and computer-readable storage medium include, but are not limited to, the following readable media: such as random access memory (RAM), read-only memory (ROM), non-volatile random access memory (NVRAM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable PROM (EEPROM), flash memory, magnetic or optical data storage, registers, magnetic disks or magnetic tapes, optical storage media such as compact disks (CDs) or DVDs (digital versatile disks), and other non-transitory media. Examples of processors include, but are not limited to, general-purpose processors, central processing units (CPUs), microprocessors, digital signal processors (DSPs), controllers, microcontrollers, state machines, etc.
[0123] It is understood that the above embodiments are merely exemplary embodiments for illustrating the principles of the present disclosure, and the present disclosure is not limited thereto. Those skilled in the art may make various modifications and improvements without departing from the spirit and substance of the present disclosure, and such modifications and improvements are also considered to be within the scope of protection of the present disclosure.
Claims
1. A method for counting people in an area, comprising: Acquire an image to be analyzed of a target area, wherein the target area includes at least one sub-area, and the image to be analyzed includes at least one sub-image, and the sub-image corresponds to the sub-area in a one-to-one manner; Detecting the position of each first human body part in the image to be analyzed; determining a physical position of each first human body part in the target area according to the position of each first human body part in the image to be analyzed and the first transformation relationship; The first transformation relationship is: a transformation relationship between the physical position of the first human body part in the target area and the position in the image to be analyzed; determining the number of people in each sub-region based on the relative positional relationship between the position of the first human body part in the image to be analyzed and the sub-image, and the relative positional relationship between the physical position of the first human body part and the sub-region; The step of determining the number of people in each sub-region according to the relative positional relationship between the position of the first human body part in the image to be analyzed and the sub-image, and the relative positional relationship between the physical position of the first human body part and the sub-region includes: For any of the sub-regions, when both of the following two conditions are met, it is determined that the first human body part is located within the sub-region; when at least one of the following two conditions is not met, it is determined that the first human body part is located outside the sub-region; Condition 1: The image position of the first human body part is within the sub-image range; Condition 2: The physical position of the first human body part is within the sub-region range; The number of people in the sub-region is determined according to the positional relationship between the first human body part and the sub-region range.
2. The method for counting people in an area according to claim 1, wherein: The first human body part includes a head; and the regional people counting method further includes: Acquiring a calibration image of the target area; determining the first transformation relationship according to the physical position of the preset portion of the marker object in the target area and the image position of the preset portion of the marker object in the calibration image; Get the physical extent of the sub-region.
3. The method for counting people in an area according to claim 2, wherein: The height of the marking object is within the standard human height range, and the preset position of the marking object is the top of the marking object.
4. The method for counting people in an area according to claim 3, wherein: Obtain the physical range of the sub-area, including: Determining a second transformation relationship based on the physical position of the bottom of the marker object and the position of the bottom of the marker object in the calibration image; wherein the second transformation relationship is a transformation relationship between the physical position of the bottom of the marker object and the position of the bottom of the marker object in the calibration image; Obtaining positions of a plurality of feature points for defining the sub-region in the calibration image; Determining the physical position of each feature point according to the position of each feature point in the calibration image and the second transformation relationship; The physical range of the sub-region is determined according to the physical positions of the plurality of feature points.
5. The method for counting people in an area according to claim 3, wherein: There are multiple marker objects in the target area, and the first transformation relationship includes a first position transformation matrix, which is determined according to the following formula (1): Among them, H_1 is the first position transformation matrix; X is a one-dimensional vector composed of the horizontal coordinates of the tops of multiple marking objects in the physical world coordinate system; Y is a one-dimensional vector composed of the vertical coordinates of the bottoms of multiple marking objects in the physical world coordinate system; u is a one-dimensional vector composed of the horizontal coordinates of the tops of multiple marking objects in the calibration image; v is a one-dimensional vector composed of the vertical coordinates of the tops of multiple marking objects in the calibration image.
6. The method for counting people in an area according to claim 4, wherein: The second transformation relationship includes a second position transformation matrix, and the second position transformation matrix is determined according to the following formula (2): Among them, H_2 is the second position transformation matrix; uu is a one-dimensional vector composed of the horizontal coordinates of the bottoms of multiple marker objects in the calibration image; vv is a one-dimensional vector composed of the vertical coordinates of the bottoms of multiple marker objects in the calibration image.
7. The method for counting people in an area according to any one of claims 1 to 6, wherein: Determining the number of people in each sub-region based on the relative positional relationship between the position of the first human body part in the image to be analyzed and the sub-image, and the relative positional relationship between the physical position of the first human body part and the sub-region, includes: For each of the sub-regions, a secondary comparison method is used to determine whether each of the first human body parts is located within the sub-region, and the number of people in the sub-region is determined based on the determination result; Among them, the secondary comparison method includes: judging whether the position of the first human body part in the image to be analyzed is within the range of the sub-image; when the position of the first human body part in the image to be analyzed is within the range of the sub-image, judging whether the physical position of the first human body part is within the range of the sub-area; when the physical position of the first human body part is within the range of the sub-area, determining that the first human body part is within the sub-area.
8. The method for counting people in an area according to claim 7, wherein: Determining whether the position of the first human body part in the image to be analyzed is within the range of the sub-image includes: Determining whether a first reference line and a boundary of the sub-image have an intersection; wherein the first reference line is a straight line passing through the position of the first human body part in the image to be analyzed; When the first reference line intersects the boundary of the sub-image, and an odd number of intersections exist on both sides of the position of the first human body part in the image to be analyzed, determining that the position of the first human body part in the image to be analyzed is within the range of the sub-image; Determining whether the physical location of the first human body part is within the sub-area includes: Determining whether a second reference line intersects a boundary of the sub-region; wherein the second reference line is a straight line passing through the physical position of the first human body part; When the second reference line intersects the boundary of the sub-region, and there are an odd number of intersections on both sides of the physical position of the first human body part, it is determined that the physical position of the first human body part is located within the sub-region.
9. The method for counting people in an area according to any one of claims 1 to 6, wherein: The position of the first human body part in the image to be analyzed is detected by a target detection algorithm based on deep learning.
10. A computer device comprising: processor; A memory having a program stored thereon, wherein when the program is executed by the processor, the following steps are implemented: Acquire an image to be analyzed of a target area, wherein the target area includes at least one sub-area, and the image to be analyzed includes at least one sub-image, and the sub-image corresponds to the sub-area in a one-to-one manner; Detecting the position of each first human body part in the image to be analyzed; determining a physical position of each first human body part in the target area according to the position of each first human body part in the image to be analyzed and the first transformation relationship; The first transformation relationship is: a transformation relationship between the physical position of the first human body part in the target area and the position in the image to be analyzed; determining the number of people in each sub-region based on the relative positional relationship between the position of the first human body part in the image to be analyzed and the sub-image, and the relative positional relationship between the physical position of the first human body part and the sub-region; The step of determining the number of people in each sub-region according to the relative positional relationship between the position of the first human body part in the image to be analyzed and the sub-image, and the relative positional relationship between the physical position of the first human body part and the sub-region includes: For any of the sub-regions, when both of the following two conditions are met, it is determined that the first human body part is located within the sub-region; when at least one of the following two conditions is not met, it is determined that the first human body part is located outside the sub-region; Condition 1: The image position of the first human body part is within the sub-image range; Condition 2: The physical position of the first human body part is within the sub-region range; The number of people in the sub-region is determined according to the positional relationship between the first human body part and the sub-region range.
11. The computer device according to claim 10, wherein: The first human body part includes the head; When the program is executed by the processor, the following steps are further implemented: Acquiring a calibration image of the target area; determining the first transformation relationship according to the physical position of the preset portion of the marker object in the target area and the image position of the preset portion of the marker object in the calibration image; Get the physical extent of the sub-region.
12. A computer-readable storage medium having a computer program stored thereon, wherein: When the program is executed by a processor, the method for counting people in an area as claimed in any one of claims 1 to 9 is implemented.
Citation Information
Patent Citations
Demographic method and system based on video monitoring
CN101477641A
A target measuring method in ball machine video images
CN105486235A