Methods, devices, and storage media for obtaining the dwell time of the target object
By acquiring multiple frames of images and detecting the motion trajectory of the target object, the intersection point of its entry and exit areas is determined, and the motion time between the intersection points is calculated. This solves the problem of inaccurate dwell time in the prior art and achieves more accurate dwell time acquisition.
Patent Information
- Application Number
- CN202211704336.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-23
- Publication Date
- 2026-01-30
- Estimated Expiration
- 2042-12-23
AI Technical Summary
Existing methods for calculating the time a target spends within its area are inaccurate and have significant errors when the target moves quickly or the frame rate is low.
By acquiring multiple initial images, target detection is performed to determine the motion trajectory of the target object. The entry and exit positions are determined by the intersection of the motion trajectory and the region boundary, and the motion time between the intersection points is calculated as the dwell time.
It improves the accuracy of the time a target object stays within a region, and can more accurately represent the time corresponding to the movement process of the target object within the region.
Smart Images

Figure CN115908474B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of computers, in particular to a target object stay time acquisition method, device and storage medium. BACKGROUND
[0002] The target object stay time in a region is one of the main indexes in many application scenarios, such as queue management, vehicle flow statistics and the like. The current mainstream time statistics method in a region is to obtain the time by counting the frame number difference between the first frame in which the target object appears in the region and the last frame in which the target object appears, and then dividing by the frame rate. In the case that the target moves fast or the frame rate is low, the stay time obtained by this method is inaccurate and has a large error. SUMMARY
[0003] The present application provides at least a target object stay time acquisition method, device and storage medium.
[0004] The present application provides a target object stay time acquisition method, comprising: acquiring a plurality of initial images obtained by shooting a preset region containing a target region to be measured; performing target detection on each initial image to obtain a motion trajectory of a target object in the preset region; determining a first intersection point and a second intersection point of the motion trajectory and a region boundary of the target region to be measured, the first intersection point being used to represent an entering position of the target object into the target region to be measured, and the second intersection point being used to represent a leaving position of the target object from the target region to be measured; acquiring a motion time of the target object between the first intersection point and the second intersection point, and taking the motion time as a stay time of the target object in the target region to be measured.
[0005] The present application provides a target object stay time acquisition device, comprising: an image acquisition module, a motion trajectory acquisition module, an intersection point acquisition module and a motion time acquisition module; the image acquisition module is used to acquire a plurality of initial images obtained by shooting a preset region containing a target region to be measured; the motion trajectory acquisition module is used to perform target detection on each initial image to obtain a motion trajectory of a target object in the preset region; the intersection point acquisition module is used to determine a first intersection point and a second intersection point of the motion trajectory and a region boundary of the target region to be measured, the first intersection point being used to represent an entering position of the target object into the target region to be measured, and the second intersection point being used to represent a leaving position of the target object from the target region to be measured; the motion time acquisition module is used to acquire a motion time of the target object between the first intersection point and the second intersection point, and take the motion time as a stay time of the target object in the target region to be measured.
[0006] The present application provides an electronic device comprising a memory and a processor, the processor being used to execute program instructions stored in the memory to implement the above-mentioned target object stay time acquisition method.
[0007] The application provides a computer readable storage medium, which stores program instructions, and the program instructions are executed by a processor to realize the above-mentioned target object staying time acquisition method.
[0008] The above scheme can obtain multiple initial images photographed on the preset area, and then perform target detection on each initial image to obtain the motion track of the target object in the preset area, so as to determine the entering position and the leaving position of the target object in the target area to be detected according to the motion track, and obtain the motion time of the target object between the two positions as the staying time of the target object in the target area to be detected. Compared with the frame number difference between the first frame in which the target object appears in the area and the last frame in which the target object appears, and then dividing the frame rate to obtain the time, the staying time obtained by the present scheme can represent the time corresponding to the motion process of the target object in the target area to be detected, that is, the obtained staying time is more accurate.
[0009] It should be understood that the above general description and the following detailed description are only exemplary and explanatory, but not limiting the present application. BRIEF DESCRIPTION OF DRAWINGS
[0010] The accompanying drawings incorporated in the specification and constituting a part of it illustrate embodiments consistent with the present application and serve together with the specification to explain the technical solutions of the present application.
[0011] Figure 1 is a flowchart of an embodiment of the target object staying time acquisition method of the present application;
[0012] Figure 2 is Figure 1 is a sub-flowchart of step S12 in
[0013] Figure 3 is an entering track schematic diagram shown by an embodiment of the target object staying time acquisition method of the present application;
[0014] Figure 4 is a leaving track schematic diagram shown by an embodiment of the target object staying time acquisition method of the present application;
[0015] Figure 5 is a structural schematic diagram of an embodiment of the target object staying time acquisition device of the present application;
[0016] Figure 6 is a structural schematic diagram of an embodiment of the electronic device of the present application;
[0017] Figure 7 is a structural schematic diagram of an embodiment of the computer readable storage medium of the present application. DETAILED DESCRIPTION
[0018] The embodiments of this application will now be described in detail with reference to the accompanying drawings.
[0019] In the following description, specific details such as particular system architectures, interfaces, and technologies are presented for illustrative purposes rather than for limiting purposes, in order to provide a thorough understanding of this application.
[0020] In this document, the term "and / or" is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. Additionally, the character " / " generally indicates that the preceding and following related objects have an "or" relationship. Furthermore, "many" in this document means two or more. Moreover, the term "at least one" in this document means any combination of at least two of any one or more of a plurality of objects. For example, including at least one of A, B, and C can mean including any one or more elements selected from the set consisting of A, B, and C.
[0021] In this application, the entity executing the method for obtaining the dwell time of the target object described herein can be a device for obtaining the dwell time of the target object. For example, the device for obtaining the dwell time of the target object can be a terminal device, a server, or other processing device. The terminal device can be a user equipment (UE), mobile device, user terminal, terminal, cellular phone, cordless phone, personal digital assistant (PDA), handheld device, computing device, in-vehicle device, wearable device, etc. In some possible implementations, the method for obtaining the dwell time of the target object can be implemented by a processor calling computer-readable instructions stored in memory.
[0022] Please see Figure 1 , Figure 1 This is a flowchart illustrating an embodiment of the method for obtaining the dwell time of the target object in this application. Figure 1 As shown in the embodiments of this disclosure, the method for obtaining the dwell time of a target object may include the following steps:
[0023] Step S11: Acquire multiple initial images of a preset area containing the target area to be tested.
[0024] The preset area can be any area in real life, such as a body of water, a shopping mall, a sports field, a pedestrian walkway, an exit, or an entrance. The target area to be measured can be a section within the preset area. For example, the preset area is a body of water, and the target area is a specific area within the water. The device used to capture images of the preset area can be an image acquisition device such as a surveillance camera or a mobile phone. For example, several image frames captured by surveillance cameras on the preset area can be obtained as initial images. Multiple frames refer to two or more frames; the number of initial images can be obtained as needed and is not limited here.
[0025] Step S12: Perform target detection on each initial image to obtain the motion trajectory of the target object in the preset area.
[0026] For example, an object detection model can be used to detect objects in each initial image to obtain the position of the target object in each initial image, and then the motion trajectory of the target object in a preset area can be determined based on each position. Specifically, the object detection model can output a detection box for the target object in each initial image, and the center point of the detection box can be used as the position of the target object in the initial image.
[0027] Step S13: Determine the first and second intersection points between the motion trajectory and the boundary of the target area to be measured.
[0028] The first intersection point indicates the entry point of the target object into the target area under test, and the second intersection point indicates the exit point of the target object from the target area under test. That is, the target object enters the target area from the first intersection point and then leaves the target area from the second intersection point.
[0029] Step S14: Obtain the movement time of the target object between the first intersection point and the second intersection point, and use the movement time as the dwell time of the target object in the target area to be measured.
[0030] If the target object is captured at exactly the first and second intersection points in the initial images, the time interval between capturing these two initial images can be directly used as the target object's movement time. However, this is less likely. If the target object is not captured at exactly the first and second intersection points, the movement time between the first and second intersection points can still be determined based on the target object's trajectory, thus obtaining the target object's dwell time within the target area.
[0031] The above scheme acquires multiple initial images of a preset area, then performs target detection on each initial image to obtain the motion trajectory of the target object within the preset area. Based on this motion trajectory, the entry and exit positions of the target object in the target area can be determined, thus obtaining the motion time of the target object between the two positions. This motion time is used as the dwell time of the target object in the target area. Compared to calculating the difference in the number of frames between the first and last frames in which the target object appears in the area and then dividing by the frame rate to obtain the time, the dwell time obtained by this scheme is more accurately represented as the time corresponding to the motion process of the target object in the target area.
[0032] Please also see Figure 2 , Figure 2 yes Figure 1 A schematic diagram of the sub-process of step S12. (See diagram below.) Figure 2 As shown, in some embodiments, step S12 may include the following steps:
[0033] Step S121: Determine the image position of the target object in each initial image.
[0034] As mentioned above, the image position of the target object in each initial image can be determined using an object detection model. Alternatively, it can be determined through image analysis. There are many ways to perform object detection, and no specific limitation is made here. In some application scenarios, the initial image is a two-dimensional image, and the position of the target object in the initial image is represented by the center point of the bounding box using a set of two-dimensional coordinates (x, y). In other embodiments, the initial image is a three-dimensional image, and the position of the target object in the initial image is represented by three-dimensional coordinates.
[0035] Step S122: Based on the position of each image, determine several target images obtained when the target object is within the target area to be tested from multiple initial images.
[0036] For example, for each initial image, if a target object is detected within the target area to be tested, then that initial image is determined to be a target image. Specifically, all initial images in multiple frames where the target object is within the target area can be used as target images. In some application scenarios, for each initial image, the image position of the target object in the previous initial image, the image position of the target object in the current initial image, whether the current initial image is a target image, the frame number of the first target image, and the frame number of the last target image are recorded. The first target image refers to the image with the earliest capture time among several target images. The last target image refers to the image with the latest capture time among several target images.
[0037] In some embodiments, step S122 may include the following steps: forming a ray with the image position of the target object in each initial image as the endpoint. Then, in response to the fact that the number of intersections between the ray and the region boundary of the target area to be measured is odd or zero, it is determined that the target object is within the target area to be measured.
[0038] For example, a ray is drawn with the image position of the target object in each initial image as the endpoint, pointing towards a preset direction. For example, the preset direction can be the direction towards the midpoint of the target area to be measured. In other words, the midpoint of the target area to be measured lies on the ray. In other embodiments, the preset direction can also be the direction towards other positions within the target area to be measured; the direction of the ray is not specifically limited here. Wherein, if the target object is outside the target area to be measured, the number of intersections between the ray and the target area to be measured is two or more, and the number of intersections is even. If the target object is within the target area to be measured, the number of intersections between the ray and the target area to be measured is odd, or if the ray coincides with the boundary of the target area to be measured, the number of intersections is 0. That is, even if the target object is at the boundary of the target area to be measured, it is considered to be within the target area to be measured.
[0039] Optionally, the target area to be measured is a convex area. Convexity specifically refers to a shape without any concave areas. For example, a convex area can be a rectangular area, a circular area, an elliptical area, a polygonal area, etc. A concave area can be an irregularly shaped area. For example, a concave area can be an area with concavities. For instance, an area where at least one straight line intersects with two or more points is considered a concave area. If the target area to be measured is a concave area, when the target object is outside the target area, the number of intersections between the ray formed by the target object's image position in the initial image and the target area to be measured may be odd, leading to the incorrect assumption that the target object is within the target area to be measured. This results in the first or last frame target image being an incorrect first or last frame target image, and consequently, the determined motion time is also inaccurate. Therefore, before executing step S122, the following step may also be performed: in response to the original target area of multiple initial images being a concave area, the original target area is divided into at least two target areas to be measured. Based on this, the dwell time of the target object in at least two target areas to be tested is summed to obtain the dwell time of the target object in the original target area.
[0040] One method for dividing the concave region into at least two target regions is to divide it from one end of the concave region towards the other, successively obtaining several convex regions. The sum of the areas of the resulting convex regions equals the area of the original concave region. The specific division method can be determined according to requirements and is not specified here. The method for calculating the dwell time within each target region can be found below.
[0041] In some application scenarios, the target area to be measured can be an arbitrary polygon, defined by a set of two-dimensional planar coordinates (x, y, z). i ,y i A closed figure composed of (x) i-1 ,y i-1 ) and (x i ,y i Two points form the i-th side of a polygon. Its i-th side L i It follows the following linear equation: L i :A i x+B i y+1=0, x∈[x i-1 ,x i ).
[0042] Step S123: Determine the motion trajectory of the target object based on at least a portion of the target image and neighboring images of the target image.
[0043] At least a portion can be all or a portion of the target images, and the adjacent images of the target images can specifically be the adjacent images of the at least a portion of the target images. The adjacent images can be target images within a plurality of target images, or non-target images within multiple initial frames.
[0044] In some embodiments, the movement of a target object within a preset area includes an entry trajectory and an exit trajectory. The entry trajectory can be used to represent the target object entering the target area, and the exit trajectory can be used to represent the target object leaving the target area.
[0045] Step S123 above may include the following steps:
[0046] A first initial image is identified that is adjacent to and earlier than the first target image among a plurality of target images. Then, based on the first target image and the first initial image, the entry trajectory of the target object into the target area to be measured is determined. The first target image refers to the image with the earliest capture time among a plurality of target images. That is, the first initial image is the initial image that is adjacent to and earlier than the first target image among multiple initial images, and the target object in the first initial image is outside the target area to be measured.
[0047] Furthermore, step S123 may further include the following steps: determining a second initial image that is adjacent to and taken later than the last frame target image among a plurality of target images. Then, based on the last frame target image and the second initial image, determining the departure trajectory of the target object leaving the target area to be measured. The last frame target image refers to the image taken latest among the plurality of target images. That is, the target object is outside the target area to be measured in the second initial image. Since both the first frame target image and the last frame target image are target images, it will be detected that after the target object leaves the target area to be measured, its subsequent re-entry into the target area to be measured requires re-determining the dwell time according to this scheme. In other words, this scheme determines the time of a single process from the target object entering to leaving the target area to be measured.
[0048] Based on this, step S13 may include the following steps: taking the intersection point between the entering trajectory and the boundary of the target area as the first intersection point; and taking the intersection point between the leaving trajectory and the boundary of the target area as the second intersection point.
[0049] In some embodiments, the method for determining the entry trajectory of a target object into the target area to be measured based on the first frame target image and the first initial image can be as follows: Under the same coordinate system, determine the first image position of the target object in the first initial image and the second image position in the first frame target image. Then, use the first image position as one endpoint of the entry trajectory and the second image position as the other endpoint of the entry trajectory, and obtain the entry trajectory through line segment fitting. In some embodiments, the method for determining the exit trajectory of a target object leaving the target area to be measured based on the last frame target image and the second initial image can be as follows: Under the same coordinate system, determine the third image position of the target object in the second initial image and the fourth image position in the last frame target image. Then, use the third image position as one endpoint of the exit trajectory and the fourth image position as the other endpoint of the exit trajectory, and obtain the exit trajectory through line segment fitting.
[0050] The coordinate system can be an image coordinate system. For example, the image coordinate system is established with a preset position in the image as its origin. For example, the origin of the image coordinate system can be the pixel at the lower left corner of the initial image. When the initial image is a two-dimensional image, the image coordinate system is a two-dimensional image coordinate system; when the initial image is a three-dimensional image, the image coordinate system is a three-dimensional image coordinate system. This application uses a two-dimensional initial image as an example; the same applies when the initial image is a three-dimensional image. The origins of the image coordinate systems of different initial images are the same. Optionally, the image coordinate systems of different initial images are the same. For example, if pixel A in a certain initial image has coordinates (3,3) in its image coordinate system, the coordinates of pixel A in other initial images are also (3,3) in their respective image coordinate systems. That is, the same coordinate system can be the image coordinate system of any initial image. For example, the same coordinate system can be the image coordinate system corresponding to the first frame target image. That is, the position of the first image in the first initial image is the same as the position of the first image in the first frame target image.
[0051] The first and third image positions are outside the target area. The entry trajectory can be obtained by connecting the first and second image positions in this coordinate system; the resulting line segment represents the entry trajectory. Similarly, the exit trajectory can be obtained by connecting the third and fourth image positions in this coordinate system; the resulting line segment represents the exit trajectory.
[0052] In some embodiments, step S14 may include the following steps: Segmenting the frame interval time of the first initial image and the first frame target image based on the ratio between a first distance between the first intersection point and the first image position and a second distance between the first intersection point and the second image position to obtain a first interval time, wherein the first interval time represents the interval time during which the target object moves from the first intersection point to the second image position. And, segmenting the frame interval time of the last frame target image and the second initial image based on the ratio between a third distance between the second intersection point and the third image position and a fourth distance between the second intersection point and the fourth image position to obtain a second interval time, wherein the second interval time represents the interval time during which the target object moves from the fourth image position to the second intersection point. Based on obtaining the first interval time and the second interval time, the sum of the first interval time, the second interval time, and the third interval time between the first frame target image and the last frame target image is taken as the motion time.
[0053] The frame interval between the first initial image and the first target image can be determined based on the shooting frame rate, or the shooting time can be recorded when the first initial image and the first target image are captured, and the difference between the two shooting times can be used as the frame interval. Similarly, the frame interval between the second initial image and the last target image can also be determined based on the shooting frame rate, or the shooting time can be recorded when the second initial image and the last target image are captured, and the difference between the two shooting times can be used as the frame interval. Since the frame interval between two images is relatively short, it can generally be assumed that the target object is moving at a constant speed in a straight line during this period. That is, knowing the frame interval and the ratio between the two distances between frames allows us to determine the interval time corresponding to each distance.
[0054] One method to obtain the third interval time is to determine the number of image frames between the first and last target images. Then, the third interval time is determined based on the ratio between the number of image frames and the frame rate.
[0055] Here, the frame rate refers to the sent frame rate. In some application scenarios, after capturing the initial images, the image acquisition device may discard a portion of the images at a certain frequency, using only the retained images as the initial images. Here, the frame rate of the initial images is not the capturing frame rate, but the sent frame rate. If all images captured by the image acquisition device are directly used as the initial images, then the sent frame rate is the same as the capturing frame rate. The size of the sent frame rate may depend on the computing power of the device executing the solution. If the computing power of the device is low, more images may be discarded, resulting in a lower sent frame rate.
[0056] To better understand entering and leaving the trajectory, please refer to... Figure 3 and Figure 4 , Figure 3 This is a schematic diagram of the entry trajectory shown in one embodiment of the method for obtaining the dwell time of the target object in this application. Figure 4 This is a schematic diagram of the departure trajectory shown in one embodiment of the method for obtaining the dwell time of the target object in this application. Figure 3 As shown, the target area to be measured is hexagonal, and the trajectory after entering the area refers to the motion trajectory between the first frame and the last frame of the target image. The second image position P of the target object in the first frame of the target image. in For (x) in y in ), first image position P in0 For (x) in0 y in0 The resulting entry trajectory L in For: a in x+b in y+1=0, x∈[x in0 x in ].
[0057] in,
[0058] By traversing each edge in the target region to be tested, the relationship with L can be determined. in The i-th edge L of the intersecting region i It can be achieved by combining L in and L i The first intersection point P1 is calculated from the following matrix:
[0059]
[0060] The coordinates of the point P1 that enters the first intersection are calculated to be (x1, y1).
[0061] As mentioned above, the shooting interval between two frames is short, so the target object can be assumed to be moving at a constant linear speed. The first interval t1 can be determined as follows: Where f represents the frame transmission frequency. This indicates the frame interval between two adjacent images.
[0062] The third time interval t can be obtained in the following ways: F2 represents the frame number of the target image in the last frame, F1 represents the frame number of the target image in the first frame, and (F2-F1) represents the number of frames between the target image in the first frame and the target image in the last frame.
[0063] The target object's fourth image position P in the last frame target image out For (x) out y out ), at position P of the third image in the second initial image out0 For (x) out0 y out0 ), leaving trajectory L out For: a out x+b out y+1=0, x∈[x out0 x out ].in,
[0064] By traversing each edge in the target region to be tested, the relationship with L can be determined. in The intersecting regions Strip edge By combining L out and The second intersection point P2 is calculated from the following matrix: The coordinates of the second intersection point P2 are (x2, y2).
[0065] Similarly, the second interval time is obtained.
[0066] Based on this, the motion time is T = t + t1 + t2.
[0067] It is understandable that t1 and t2 can be considered as time compensation for t, with t1 being compensation for the entry time of t and t2 being compensation for the departure time of t.
[0068] The above scheme acquires multiple initial images of a preset area, then performs target detection on each initial image to obtain the motion trajectory of the target object within the preset area. Based on this motion trajectory, the entry and exit positions of the target object in the target area can be determined, thus obtaining the motion time of the target object between the two positions. This motion time is used as the dwell time of the target object in the target area. Compared to calculating the difference in the number of frames between the first and last frames in which the target object appears in the area and then dividing by the frame rate to obtain the time, the dwell time obtained by this scheme is more accurately represented as the time corresponding to the motion process of the target object in the target area.
[0069] Please see Figure 5 , Figure 5 This is a schematic diagram of an embodiment of the target object dwell time acquisition device of this application. The target object dwell time acquisition device 30 includes an image acquisition module 31, a motion trajectory acquisition module 32, an intersection point acquisition module 33, and a motion time acquisition module 34. The image acquisition module 31 is used to acquire multiple initial images captured in a preset area containing the target area to be tested; the motion trajectory acquisition module 32 is used to perform target detection on each initial image to obtain the motion trajectory of the target object in the preset area; the intersection point acquisition module 33 is used to determine the first intersection point and the second intersection point between the motion trajectory and the boundary of the target area to be tested, wherein the first intersection point is used to indicate the entry position of the target object into the target area to be tested, and the second intersection point is used to indicate the exit position of the target object from the target area to be tested; the motion time acquisition module 34 is used to acquire the motion time of the target object between the first intersection point and the second intersection point, and uses the motion time as the dwell time of the target object in the target area to be tested.
[0070] The above scheme acquires multiple initial images of a preset area, then performs target detection on each initial image to obtain the motion trajectory of the target object within the preset area. Based on this motion trajectory, the entry and exit positions of the target object in the target area can be determined, thus obtaining the motion time of the target object between the two positions. This motion time is used as the dwell time of the target object in the target area. Compared to calculating the difference in the number of frames between the first and last frames in which the target object appears in the area and then dividing by the frame rate to obtain the time, the dwell time obtained by this scheme is more accurately represented as the time corresponding to the motion process of the target object in the target area.
[0071] The functions of each module can be found in the embodiment of the method for obtaining the dwell time of the target object, and will not be repeated here.
[0072] Please see Figure 6 , Figure 6 This is a schematic diagram of the structure of an embodiment of the electronic device of this application. The electronic device 40 includes a memory 41 and a processor 42. The processor 42 is used to execute program instructions stored in the memory 41 to implement the steps in any of the above-described embodiments of the method for obtaining the dwell time of a target object. In a specific implementation scenario, the electronic device 40 may include, but is not limited to, monitoring equipment, microcomputers, and servers. In addition, the electronic device 40 may also include mobile devices such as laptops and tablets, which are not limited here.
[0073] Specifically, processor 42 controls itself and memory 41 to implement the steps in the above-described method embodiment for obtaining the dwell time of any target object. Processor 42 can also be referred to as a CPU (Central Processing Unit). Processor 42 may be an integrated circuit chip with signal processing capabilities. Processor 42 can also be a general-purpose processor, digital signal processor (DSP), application-specific integrated circuit (ASIC), field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. A general-purpose processor can be a microprocessor or any conventional processor. Furthermore, processor 42 can be implemented using integrated circuit chips.
[0074] The above scheme acquires multiple initial images of a preset area, then performs target detection on each initial image to obtain the motion trajectory of the target object within the preset area. Based on this motion trajectory, the entry and exit positions of the target object in the target area can be determined, thus obtaining the motion time of the target object between the two positions. This motion time is used as the dwell time of the target object in the target area. Compared to calculating the difference in the number of frames between the first and last frames in which the target object appears in the area and then dividing by the frame rate to obtain the time, the dwell time obtained by this scheme is more accurately represented as the time corresponding to the motion process of the target object in the target area.
[0075] Please see Figure 7 , Figure 7 This is a schematic diagram of a computer-readable storage medium according to an embodiment of the present application. The computer-readable storage medium 50 stores program instructions 51 that can be executed by a processor. The program instructions 51 are used to implement the steps in the embodiments of the method for obtaining the dwell time of any of the target objects described above.
[0076] The above scheme acquires multiple initial images of a preset area, then performs target detection on each initial image to obtain the motion trajectory of the target object within the preset area. Based on this motion trajectory, the entry and exit positions of the target object in the target area can be determined, thus obtaining the motion time of the target object between the two positions. This motion time is used as the dwell time of the target object in the target area. Compared to calculating the difference in the number of frames between the first and last frames in which the target object appears in the area and then dividing by the frame rate to obtain the time, the dwell time obtained by this scheme is more accurately represented as the time corresponding to the motion process of the target object in the target area.
[0077] In some embodiments, the functions or modules of the apparatus provided in this disclosure can be used to perform the methods described in the above method embodiments. The specific implementation can be referred to the description of the above method embodiments, and for the sake of brevity, it will not be repeated here.
[0078] The description of the various embodiments above tends to emphasize the differences between the various embodiments. The similarities or similarities between them can be referred to, and for the sake of brevity, they will not be repeated here.
[0079] In the several embodiments provided in this application, it should be understood that the disclosed methods and apparatus can be implemented in other ways. For example, the apparatus implementations described above are merely illustrative. For instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, units or components may be combined or integrated into another system, or some features may be ignored or not executed. In another image location, the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces, and the indirect coupling or communication connection of devices or units may be electrical, mechanical, or other forms.
[0080] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit. If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor to execute all or part of the steps of the methods in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
Claims
1. A method of acquiring a target object stay time, characterized by, The method comprises: acquiring a plurality of initial images captured for a preset region containing a target region to be detected; detecting a target object in each of the initial images to obtain a motion track of the target object in the preset region; determining a first intersection point and a second intersection point of the motion track and a region boundary of the target region to be detected, the first intersection point representing an entering position of the target object into the target region to be detected, and the second intersection point representing a leaving position of the target object from the target region to be detected; acquiring a motion time of the target object between the first intersection point and the second intersection point, and taking the motion time as a stay time of the target object in the target region to be detected; wherein the acquiring of the motion time of the target object between the first intersection point and the second intersection point comprises: dividing an interval time between a first initial image and a first target image based on a ratio between a first distance between the first intersection point and a first image position and a second distance between the first intersection point and a second image position, to obtain a first interval time, wherein the first interval time represents an interval time of the target object moving from the first intersection point to the second image position; the first image position is a position of the target object in the first initial image, the first initial image is an image adjacent to and earlier than a first target image in a plurality of target images, and the second image position is a position of the target object in the first target image; the plurality of target images are images captured when the target object is in the target region to be detected; and dividing an interval time between a second initial image and a last target image based on a ratio between a third distance between the second intersection point and a third image position and a fourth distance between the second intersection point and a fourth image position, to obtain a second interval time, wherein the second interval time represents an interval time of the target object moving from the fourth image position to the second intersection point; the third image position is a position of the target object in the second initial image, the second initial image is an image adjacent to and later than a last target image in the plurality of target images, and the fourth image position is a position of the target object in the last target image; taking a sum of the first interval time, the second interval time, and a third interval time between the first target image and the last target image as the motion time.
2. The method of claim 1, wherein, The detecting of the target object in each of the initial images to obtain a motion track of the target object in the preset region comprises: determining an image position of the target object in each of the initial images respectively; determining a plurality of target images captured when the target object is in the target region to be detected from the plurality of initial images based on the image positions; determining a motion track of the target object based on at least part of the target images and adjacent images of the target images.
3. The method of claim 2, wherein, The determining of the motion track of the target object based on at least part of the target images and adjacent images of the target images comprises: determine a first initial image adjacent to and earlier than a first frame of the target images; determine an entering trajectory of the target object into the target region based on the first frame of the target images and the first initial image; determine a second initial image adjacent to and later than a last frame of the target images; determine an exiting trajectory of the target object out of the target region based on the last frame of the target images and the second initial image; the determining the first intersection and the second intersection of the motion trajectory and the region boundary of the target region comprises: taking the intersection between the entering trajectory and the region boundary of the target region as the first intersection; taking the intersection between the exiting trajectory and the region boundary of the target region as the second intersection.
4. The method of claim 3, wherein, the determining the entering trajectory of the target object into the target region based on the first frame of the target images and the first initial image comprises: determining a first image position of the target object in the first initial image and a second image position of the target object in the first frame of the target images in the same coordinate system; taking the first image position as one end point of the entering trajectory, taking the second image position as another end point of the entering trajectory, and obtaining the entering trajectory by line segment fitting; the determining the exiting trajectory of the target object out of the target region based on the last frame of the target images and the second initial image comprises: determining a third image position of the target object in the second initial image and a fourth image position of the target object in the last frame of the target images in the same coordinate system; taking the third image position as one end point of the exiting trajectory, taking the fourth image position as another end point of the exiting trajectory, and obtaining the exiting trajectory by line segment fitting.
5. The method of claim 1, wherein, before the obtaining the motion time of the target object between the first intersection and the second intersection, the method further comprises: determining the number of image frames between the first frame of the target images and the last frame of the target images; determining the third interval time based on the ratio between the number of image frames and the frame rate.
6. The method according to any one of claims 2-4, characterized in that, the determining the target images based on the image positions comprises: forming a ray with the image positions of the target object in the initial images as end points; determining that the target object is in the target region in response to the intersection between the ray and the region boundary of the target region being singular or zero.
7. The method of claim 6, wherein, before the determining the target images based on the image positions, the method further comprises: in response to the original target region of the initial images being a concave region, dividing the original target region into at least two target regions; the method further comprises: The staying time of the target object in the at least two target regions to be detected is summed to obtain the staying time of the target object in the original target region.
8. An electronic device, comprising: A computer program product comprising a memory and a processor configured to execute program instructions stored in the memory to implement the method of any one of claims 1 to 7.
9. A computer-readable storage medium having stored thereon program instructions, wherein, The program instructions, when executed by a processor, implement the method of any one of claims 1 to 7.
Citation Information
Patent Citations
Area determination method and device, storage medium and processor
CN109919966A
Object behavior determination method and device, storage medium and electronic device
CN114255424A