A method, device, electronic device and storage medium for detecting target distance
By calculating the homography matrix and the deep learning detection model, we can achieve accurate measurement of the physical distance between objects and real-time elimination of dynamic objects, solve the problem of inaccurate cargo distance detection in the existing technology, and ensure the safe distance between cargoes and Monitoring system efficiency.
Patent Information
- Application Number
- CN202410800867.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-20
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2044-06-20
AI Technical Summary
Existing technology cannot accurately measure the actual physical distance between objects, and cannot exclude dynamic objects in real time, resulting in inaccurate cargo distance detection, which may lead to potential risks.
By obtaining the monitoring screen of the target scene, calibrating the detection area, calculating the homography matrix to perspectively transform the detection area into a rectangular area in the real scene, inputting the deep learning detection model to obtain the rectangle, using the intersection and union ratio algorithm to filter the target, and calculating the actual coordinates of the target. and size, to determine the relative physical distance between objects.
It achieves precise interval measurement and classification of static goods, ensures a safe distance between goods, prevents potential risks, and improves the accuracy and efficiency of the monitoring system.
Smart Images

Figure CN118365869B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of detection and tracking technology, and in particular to a target distance detection method, device, electronic equipment and storage medium. Background Art
[0002] In modern logistics warehouse management, it is crucial to ensure the safety of the space where goods are stored. Especially for large goods, proper spacing is not only to optimize storage space, but also to prevent potential chain reaction risks - commonly known as the "domino effect". In this scenario, it is necessary to ensure that each piece of goods is kept at a safe distance at least equal to its own size. In addition, during the placement and movement of goods, the constantly changing physical layout puts higher demands on the real-time monitoring system. Ideally, the monitoring system should not only accurately identify and track stationary goods, but also exclude those objects that are still being placed, and avoid making interval judgments before they are stable, which can greatly reduce the false alarm rate and improve the accuracy and efficiency of the overall monitoring system.
[0003] Although traditional deep learning detection and tracking technology can provide a certain degree of monitoring capabilities, it still has limitations in accurately measuring the actual physical distance between objects and eliminating dynamic objects in real time.
[0004] Therefore, there is an urgent need for a target spacing detection method that can accurately measure and classify the intervals between static targets, ensure that targets maintain a safe distance, and prevent potential risks. Summary of the invention
[0005] Each embodiment of the present invention provides a method for detecting target distance to solve the problem that the prior art cannot accurately measure the actual physical distance between objects and cannot eliminate dynamic objects in real time. The technical solution is as follows:
[0006] According to one aspect of the present invention, a method for detecting target spacing includes: obtaining a monitoring screen of a target scene, and calibrating a detection area in the monitoring screen; calculating a corresponding homography matrix based on the detection area; the homography matrix is used to perspective transform the detection area into a rectangular area in a real scene; obtaining data to be detected and inputting it into a deep learning detection model to obtain multiple rectangles, and filtering the multiple rectangles according to the divided areas through an intersection-over-union algorithm to obtain multiple targets; obtaining the actual coordinates of each of the targets based on the homography matrix and calculating the actual size of each of the targets and the relative physical distance between the targets.
[0007] In one of the embodiments, the corresponding homography matrix is calculated according to the detection area by the following steps: four detection corner points are selected in the detection area, and the actual coordinates of the four detection corner points in the real scene are determined; a linear equation group is constructed according to the coordinates of the four detection corner points in the detection area and the actual coordinates; the linear equation group is solved by a numerical algorithm to obtain the corresponding homography matrix; the numerical algorithm includes least squares method, linear transformation and singular value decomposition.
[0008] In one of the embodiments, obtaining the data to be detected and inputting it into a deep learning detection model to obtain multiple rectangles is achieved by the following steps: obtaining multiple consecutive frames of images of the target scene as the data to be detected, inputting the data to be detected into the deep learning detection model to obtain multiple rectangles and numbering them; obtaining the displacement of each rectangle through the continuous position change of each rectangle in the data to be detected; setting a time threshold and a distance threshold, and comparing the displacement of each rectangle within the time threshold with the distance threshold to obtain the motion state of each rectangle; the time threshold is used to define the duration of the static state; and the distance threshold is used to define the maximum displacement.
[0009] In one of the embodiments, the plurality of rectangles are screened according to the divided areas by the intersection-and-union algorithm to obtain the plurality of targets by the following steps: if the displacement of the rectangle within the time threshold is less than the distance threshold, the rectangle is determined to be in a stationary state; the minimum circumscribed matrix of each rectangle is calculated according to the position of each stationary rectangle in the corresponding image and the divided areas are set; the intersection-and-union algorithm is used to determine whether each rectangle is within the divided area according to the minimum circumscribed matrix of each rectangle, and the rectangle within the divided area is taken as a target.
[0010] In one of the embodiments, obtaining the actual coordinates of each of the targets according to the homography matrix and calculating the actual size of each of the targets and the relative physical distance between each of the targets are achieved by the following steps: converting the position of each of the targets into bird's-eye view coordinates in a real scene according to the homography matrix; calculating the actual size of each of the targets according to the bird's-eye view coordinates of each of the targets; and obtaining the relative physical distance between each of the targets according to the bird's-eye view coordinates and the actual size of each of the targets.
[0011] In one of the embodiments, the actual size of each target is calculated based on the bird's-eye view coordinates of each target by the following steps: a size calculation method for each target is selected based on the geometric relationship between the camera and the detection area in the scene where the target is located; the size calculation method includes from the upper left corner to the lower right corner or from the upper right corner to the lower left corner; the actual size of each target is calculated based on the bird's-eye view coordinates and the size calculation method.
[0012] In one of the embodiments, obtaining the relative physical distance between each of the targets based on the bird's-eye view coordinates and actual size of each of the targets is achieved by the following steps: selecting the corner points of each of the targets based on the viewing angle and physical layout of the camera in the scene where each of the targets is located; obtaining the corner point coordinates of each of the targets based on the corner points and bird's-eye view coordinates of each of the targets, and obtaining the center of mass coordinates of each of the targets based on the bird's-eye view coordinates and actual size of each of the targets; and calculating the corner point coordinates or center of mass coordinates of each of the targets to obtain the relative physical distance between the targets.
[0013] According to one aspect of the present invention, a target distance detection device includes: a detection area calibration module, which is used to obtain a monitoring screen of a target scene and calibrate a detection area in the monitoring screen; a homography matrix calculation module, which is used to calculate a corresponding homography matrix based on the detection area; a target detection module, which is used to obtain data to be detected and input it into a deep learning detection model to obtain multiple rectangles, and obtain multiple targets by screening the multiple rectangles according to the divided areas through an intersection-and-union algorithm; and a target distance detection module, which is used to obtain the actual coordinates of each of the targets based on the homography matrix and calculate the actual size of each of the targets and the relative physical distance between each of the targets.
[0014] According to one aspect of the present invention, an electronic device includes at least one processor and at least one memory, wherein the memory stores computer-readable instructions; the computer-readable instructions are executed by one or more of the processors, so that the electronic device implements the target distance detection method as described above.
[0015] According to one aspect of the present invention, a storage medium stores computer-readable instructions, and the computer-readable instructions are executed by one or more processors to implement the target distance detection method as described above.
[0016] The beneficial effects brought by the technical solution provided by the present invention are:
[0017] In the above technical scheme, the present invention first obtains a monitoring screen of the target scene, calibrates the detection area in the monitoring screen, calculates the corresponding homography matrix according to the detection area, and the homography matrix is used to perspectively transform the detection area into a rectangular area in the real scene, obtains the data to be detected and inputs it into the deep learning detection model to obtain multiple rectangles, and screens the multiple rectangles according to the divided areas through the intersection and union algorithm to obtain multiple targets, obtains the actual coordinates of each target according to the homography matrix, and calculates the actual size of each target and the relative physical distance between each target. By introducing the homography matrix, the matrix transformation is used in combination with the detection model to realize the mapping of the picture pixels and the physical position, so as to judge the relationship between the actual physical distance between objects and the multiple of the size of the object itself, and judges the moving state of the object through continuous frame images to ensure the detection of the relationship between objects in a relatively static state, and can realize accurate interval measurement and classification of static goods, ensure that a safe distance is maintained between goods, and prevent potential risks, thereby effectively solving the problem that the prior art cannot accurately measure the actual physical distance between objects and cannot eliminate dynamic objects in real time. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in describing the embodiments of the present invention. Obviously, the drawings described below are only some embodiments of the present invention, and those skilled in the art can obtain other drawings based on these drawings without creative work.
[0019] Figure 1 is a flow chart of a method for detecting target distance according to an exemplary embodiment;
[0020] Figure 2 yes Figure 1 Flow chart corresponding to step 130 in the embodiment;
[0021] Figure 3 yes Figure 1 Flow chart of target detection in step 150 of the corresponding embodiment;
[0022] Figure 4 yes Figure 1 Flow chart of target screening in step 150 of the corresponding embodiment;
[0023] Figure 5 It is a schematic diagram of a target distance detection method in an application scenario;
[0024] Figure 6 yes Figure 5 Schematic diagram of region overlap judgment in corresponding application scenarios;
[0025] Figure 7 yes Figure 5Schematic diagram of the coordinate transformation of the homography matrix in the corresponding application scenario;
[0026] Figure 8 yes Figure 5 Schematic diagram of target size measurement method in corresponding application scenarios;
[0027] Fig. 9 is a schematic diagram of a target distance detection method in another application scenario;
[0028] Fig.10 is a block diagram of a target distance detection device according to an exemplary embodiment;
[0029] Fig.11 is a hardware structure diagram of an electronic device according to an exemplary embodiment;
[0030] Fig.12 It is a block diagram of an electronic device according to an exemplary embodiment. DETAILED DESCRIPTION
[0031] Embodiments of the present invention are described in detail below, examples of which are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and cannot be interpreted as limiting the present invention.
[0032] It will be understood by those skilled in the art that, unless expressly stated, the singular forms "one", "said", and "the" used herein may also include plural forms. It should be further understood that the term "comprising" used in the specification of the present disclosure refers to the presence of the features, integers, steps, operations, elements, and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and / or groups thereof. It should be understood that when we refer to an element as being "connected" or "coupled" to another element, it may be directly connected or coupled to the other element, or there may be intermediate elements. In addition, the "connection" or "coupling" used herein may include wireless connection or wireless coupling. The term "and / or" used herein includes all or any unit and all combinations of one or more associated listed items.
[0033] Homography: It is a transformation matrix used to achieve perspective transformation between images. It can map points on one plane to another plane. In monitoring systems and image processing, homography is often used to correct perspective distortion in images. This is because straight lines and planes in the real world may be deformed in images due to perspective projection. By calculating the homography matrix under the perspective of the surveillance camera, the distorted area in the real scene captured by the camera can be transformed into a normal rectangular view. We call this process "bird's eye view" transformation.
[0034] Bird's-eye view: A perspective from above that provides a plan view of an area, which is very useful in spatial analysis and distance measurement. For example, in road monitoring, by converting the oblique view captured by the camera into a bird's-eye view, the distance between vehicles can be accurately measured for traffic flow analysis or security monitoring. In the scene of object size and spacing calculation, the homography matrix can be applied to convert the image captured by the camera into a bird's-eye view, so as to calculate the actual size of the objects and the distance between them, ensuring the accuracy of the measurement results.
[0035] The present invention provides a target distance detection method, which realizes the mapping between picture pixels and physical positions by introducing a homography matrix and using matrix transformation combined with a detection model, thereby judging the multiple relationship between the actual physical distance between objects and the size of the objects themselves, solving the problem that the prior art cannot accurately measure the actual physical distance between objects and cannot eliminate dynamic objects in real time. The target distance detection method is suitable for a target distance detection device, which can be an electronic device. The target distance detection method in the embodiment of the present invention can be applied to a variety of scenarios, such as cargo distance detection, etc.
[0036] See also Figure 1 , an embodiment of the present invention provides a target distance detection method, which is applicable to electronic equipment.
[0037] In the following method embodiments, for ease of description, the execution subject of each step of the method is taken as an electronic device as an example for illustration, but this does not constitute a specific limitation.
[0038] like Figure 1 As shown, the method may include the following steps:
[0039] Step 110, obtaining a monitoring picture of the target scene, and calibrating the detection area in the monitoring picture.
[0040] Step 130, calculating and obtaining a corresponding homography matrix according to the detection area.
[0041] Among them, the homography matrix is used to transform the detection area into a rectangular area in the real scene.
[0042] In one possible implementation, such as Figure 2 As shown, step 130 may include the following steps:
[0043] Step 210: Select four detection corner points in the detection area and determine the actual coordinates of the four detection corner points in the real scene.
[0044] Step 230: construct a linear equation group according to the coordinates of the four detected corner points in the detection area and the actual coordinates.
[0045] Step 250, solving the linear equations by numerical algorithm to obtain the corresponding homography matrix.
[0046] Step 150, obtaining the data to be detected and inputting it into the deep learning detection model to obtain multiple rectangles, and screening the multiple rectangles according to the divided areas through the intersection-over-union algorithm to obtain multiple targets.
[0047] In one possible implementation, such as Figure 3 As shown, obtaining the data to be detected and inputting it into the deep learning detection model to obtain multiple rectangles in step 150 may include the following steps:
[0048] Step 310: obtain multiple consecutive frames of images of the target scene as data to be detected, input the data to be detected into a deep learning detection model to obtain multiple rectangles and number them.
[0049] Step 330 , obtaining the displacement of each rectangle through the continuous position change of each rectangle in the data to be detected.
[0050] Step 350 , setting a time threshold and a distance threshold, and comparing the displacement of each rectangle within the time threshold with the distance threshold to obtain the motion state of each rectangle.
[0051] The time threshold is used to define the duration of the stationary state, and the distance threshold is used to define the maximum displacement.
[0052] In one possible implementation, such as Figure 4 As shown, the step 150 of screening multiple rectangles according to the divided areas by using the intersection-over-union algorithm to obtain multiple targets may include the following steps:
[0053] Step 410: If the displacement of the rectangle within the time threshold is less than the distance threshold, it is determined that the rectangle is in a stationary state.
[0054] Step 430 , calculating the minimum circumscribed matrix of each rectangle according to the position of each rectangle in a stationary state in the corresponding image and setting the division area.
[0055] Step 450, using the intersection-over-union algorithm to determine whether each rectangle is within the divided area according to the minimum circumscribed matrix of each rectangle, and the rectangle within the divided area is taken as the target.
[0056] Step 170, obtaining the actual coordinates of each target according to the homography matrix and calculating the actual size of each target and the relative physical distance between the targets.
[0057] In one possible implementation, the position of each target is converted into a bird's-eye view coordinate in a real scene according to a homography matrix, the actual size of each target is calculated according to the bird's-eye view coordinate of each target, and the relative physical distance between the targets is obtained according to the bird's-eye view coordinate and the actual size of each target.
[0058] In one possible implementation, a size calculation method for each target is selected based on a geometric relationship between a camera and a detection area in a scene where the target is located, and the actual size of each target is calculated based on the bird's-eye view coordinates and size calculation method of each target.
[0059] The size calculation method includes from the upper left corner to the lower right corner or from the upper right corner to the lower left corner.
[0060] In one possible implementation, the corner points of each target are selected according to the viewing angle and physical layout of the camera in the scene where each target is located, the corner point coordinates of each target are obtained according to the corner points of each target and the bird's-eye view coordinates, the center of mass coordinates of each target are obtained according to the bird's-eye view coordinates and actual size of each target, and the corner point coordinates or center of mass coordinates of each target are calculated to obtain the relative physical distance between the targets.
[0061] Through the above process, the present invention first obtains the monitoring screen of the target scene, calibrates the detection area in the monitoring screen, calculates the corresponding homography matrix according to the detection area, the homography matrix is used to transform the detection area into a rectangular area in the real scene, obtains the data to be detected and inputs it into the deep learning detection model to obtain multiple rectangles, screens the multiple rectangles according to the divided areas through the intersection and union algorithm to obtain multiple targets, obtains the actual coordinates of each target according to the homography matrix, and calculates the actual size of each target and the relative physical distance between each target. By introducing the homography matrix, the matrix transformation is used in combination with the detection model to realize the mapping of the picture pixels and the physical position, so as to judge the relationship between the actual physical distance between objects and the multiple of the size of the object itself, and judges the moving state of the object through continuous frame images to ensure the detection of the relationship between objects in a relatively static state, and can realize accurate interval measurement and classification of static goods, ensure that a safe distance is maintained between goods, and prevent potential risks, thereby effectively solving the problem that the prior art cannot accurately measure the actual physical distance between objects and cannot eliminate dynamic objects in real time.
[0062] In one application scenario, Figure 5 A flowchart of a target spacing detection method is shown. Figure 6 A schematic diagram showing the region overlap judgment is shown. Figure 7A schematic diagram showing the coordinate transformation of the homography matrix is shown. Figure 8 A schematic diagram showing how the target size is measured.
[0063] like Figure 5 As shown, firstly, a physical rectangular area, i.e., a convex quadrilateral in the picture where the target is located, is selected, and the homography matrix is calculated based on the convex quadrilateral to obtain the matrix parameters. After the data to be predicted is input into the detection model, it is determined whether the target in the data to be predicted is in the convex quadrilateral. If the target is in the convex quadrilateral, the target is transformed from the convex quadrilateral to a rectangle in the bird's-eye view according to the matrix parameters, and the size of the target and the distance between the targets are calculated according to the position of the target in the rectangle in the bird's-eye view.
[0064] Specifically, the following steps may be included:
[0065] Step S1, initializing monitoring area selection.
[0066] Specifically, the user manually calibrates a specific area in the real-time monitoring screen of the camera. The area is a rectangle in the physical world and is displayed as a distorted convex quadrilateral in the monitoring screen. The calibration is completed by selecting the pixel positions of the four corner points of the quadrilateral.
[0067] Step S2, calculation and transformation of the homography matrix.
[0068] Specifically, computational geometry technology is used to calculate the homography matrix based on the four points calibrated by the user. The distorted convex quadrilateral in the monitoring image is transformed into a rectangle through the homography matrix to facilitate subsequent processing.
[0069] The homography matrix H is a 3×3 matrix that can be solved from a set of corresponding points by the least squares method or other optimization techniques. Calculating the homography matrix may include the following steps:
[0070] The first step is to select the corresponding points.
[0071] Specifically, four points Pimg={(xi, yi)} are selected on the image. These points are the four corner points of the convex quadrilateral manually drawn on the image. At the same time, the positions of these points in the real-world rectangular area Preal={(Xi, Yi)} are determined. Since the present invention only needs to calculate the ratio of the size and distance instead of the specific numerical value, the length and width of the rectangle to be converted can be manually set to facilitate the determination of Xi and Yi.
[0072] The second step is to construct a system of linear equations.
[0073] Specifically, a linear equation system is constructed using the corresponding points, with each pair of points (xi, yi) and (Xi, Yi) providing two equations, and four pairs of points providing eight equations.
[0074] The third step is to solve the homography matrix.
[0075] Specifically, the linear equation can be expressed as a matrix multiplication form A·h=b.
[0076] Among them, A is the coefficient matrix consisting of the coordinates of the corresponding points, h is the column vector containing the elements of the H matrix, and b is the column vector consisting of the coordinates of the corresponding points in real-world coordinates.
[0077] Furthermore, by solving h through the least squares method or direct linear transform (DLT) algorithm, H can be obtained. Usually, numerical methods such as singular value decomposition (SVD) are used to solve h to obtain the homography matrix H that minimizes the error.
[0078] It is worth noting that, since the present invention only needs to calculate the ratio of size and distance and the scaling of the homography matrix is uncertain, and a fixed value can determine the scaling, the last element of H is fixed to 1.
[0079] Step S3: data preparation and detection model application.
[0080] Specifically, the user inputs the data to be predicted into the deep learning detection model. The model analyzes the data and detects the target object in the image. The data to be predicted can be data such as screenshots of surveillance images.
[0081] Step S4, confirming the relationship between the detection target and the selected area.
[0082] Specifically, the Intersection over Union (IoU) algorithm is used to determine whether each detected target is within the quadrilateral area previously calibrated by the user, and only targets within this area are subsequently processed.
[0083] like Figure 6 As shown in the figure, the detection model will detect each cargo. The cargo may be contained in the manually demarcated area or outside the area. IoU can determine whether two areas overlap. As long as this value is not 0, it can be considered that the two areas have overlapping parts. The specific tolerance level needs to be fine-tuned according to the on-site environment or project requirements.
[0084] The specific judgment formula is: IoU = (A∩B) / (A∪B).
[0085] Among them, I is Figure 6 In the Intersection, U stands for Union, and A and B are two areas.
[0086] It is worth noting that since the detection model detects the minimum circumscribed matrix of the goods, only a part of the matrix is within the manually demarcated area. Therefore, by calculating the IoU value, the extent to which the goods are included in the demarcated area can be controlled, which increases the flexibility of practical applications.
[0087] Step S5, applying the homography matrix to perform target transformation.
[0088] like Figure 7 As shown, a homography matrix transformation is applied to the target located in the calibration area. During the transformation process, the target is transformed from a convex quadrilateral in the picture to a rectangle in the bird's-eye view.
[0089] Among them, the calculation of the homography matrix H is based on the correspondence between the points in the manually delineated convex quadrilateral area and the actual rectangular area. Therefore, the homography matrix can realize the conversion from the pixel coordinates of the screen to the actual physical coordinates of the warehouse. After obtaining the homography matrix H, for each cargo identified by the detection model, if the IoU value between its minimum circumscribed rectangle and the manually delineated area meets the preset tolerance level, the cargo is considered to be in the delineated area. Then, the pixel coordinates of these cargoes are transformed using the homography matrix H to obtain their bird's-eye view coordinates in the rectangular area, and then the precise position of the cargo in the actual physical space of the warehouse can be obtained, which provides a basis for subsequent size measurement and distance analysis. This process not only optimizes the arrangement of cargo storage, but also greatly improves the practicality and accuracy of the monitoring system.
[0090] It is worth noting that in the homography matrix transformation and the homogeneous coordinate system, w represents a scaling factor used to convert the homogeneous coordinates back to ordinary two-dimensional coordinates. When a point (x, y) is transformed using the homography matrix H, the point will be converted to homogeneous coordinates (x′, y′, w′). In order to obtain ordinary two-dimensional coordinates, x′ and y′ need to be divided by w′. Since only the multiple relationship of size and distance is calculated in the present invention, the value of w′ can be directly set to 1 to reduce the amount of calculation.
[0091] Step S6, distance calculation and analysis in the bird's-eye view.
[0092] Specifically, the size of each target object and the relative physical distance between each target object are calculated in the bird's-eye view representation, and the real physical distance between the objects is accurately analyzed.
[0093] The size of each target object can be calculated by measuring the distance between the diagonals of the bounding box to estimate the size of the object.
[0094] like Figure 8As shown, the distance from the upper left corner to the lower right corner or from the upper right corner to the lower left corner depends on the specific geometric relationship between the camera and the target area. If the specific geometric relationship between the camera and the target area is as follows Figure 8 As shown in (a), it is obvious that the distance from the upper right corner to the lower left corner is more consistent with the actual size of the goods, so the distance from the upper right corner to the lower left corner is selected to estimate the size of the object; if the specific geometric relationship between the camera and the target area is as follows Figure 8 As shown in (b), it is obvious that the distance from the upper left corner to the lower right corner is more consistent with the actual size of the goods. Therefore, the distance from the upper left corner to the lower right corner is selected to estimate the size of the object. This method reduces the computational complexity while maintaining a small error.
[0095] Among them, the relative physical distance between each target object can be determined by measuring between the center of mass or specific corner points of the bounding box. The appropriate measurement method can be selected according to the actual application scenario. The key to measuring through the specific corner points of the bounding box is to select the corner points that best suit the camera viewing angle and physical layout for calculation, which can provide sufficiently accurate distance measurement in most cases.
[0096] Through the above process, the embodiment of the present invention introduces a homography matrix and uses matrix transformation in combination with a detection model to achieve mapping between picture pixels and physical positions, thereby judging the relationship between the actual physical distance between objects and the multiples of the size of the objects themselves, and judging the movement state of the objects through continuous frame images to ensure the relationship between objects in a relatively static state is detected, and can achieve accurate interval measurement and classification of static goods, ensure that a safe distance is maintained between goods, and prevent potential risks, thereby effectively solving the problem that the prior art cannot accurately measure the actual physical distance between objects and cannot eliminate dynamic objects in real time.
[0097] In another application scenario, Fig. 9 As shown, the target distance detection method of the present invention may include the following steps in the application scenario of a surveillance camera and a tracking model:
[0098] Step 610, tracking model initialization and continuous frame input.
[0099] Specifically, the frames continuously captured by the surveillance camera are first input into the tracking model. The tracking model receives the objects detected in each frame and assigns them unique identification numbers, such as "item1", "item2", "item3", etc.
[0100] Step 620: number marking and object displacement monitoring.
[0101] Specifically, for each target object, the model tracks its movement trajectory in consecutive frames and calculates the displacement distance of each object by comparing the position changes in consecutive frames.
[0102] Step 630, setting time and distance thresholds.
[0103] Specifically, during the tracking process, the user sets a time threshold to define the time range of the stationary state, and sets a distance threshold to define the maximum allowed displacement range.
[0104] Step 640, static state determination.
[0105] Specifically, if the displacement distance of an object within a set time threshold is less than a distance threshold, it is judged to be in a stationary state. The system screens out all stationary objects and records their positions in the corresponding frames.
[0106] Step 650: Bird's-eye view coordinate transformation and size distance calculation.
[0107] Specifically, for the screened stationary objects, the previously calculated homography matrix is applied to convert their positions into bird's-eye view coordinates, and the size of each stationary object and the distance between the stationary objects are calculated in the bird's-eye view.
[0108] Step 660: Analyze the relationship between size and distance multiples.
[0109] Through the above steps, the embodiment of the present invention not only calculates the size of the stationary object, but also obtains the distance between the objects, and finally analyzes the multiple relationship between the size and distance between the objects to evaluate the actual physical interval between the objects, which can effectively solve the problem that the prior art cannot accurately measure the actual physical distance between objects and cannot eliminate dynamic objects in real time.
[0110] The following is an embodiment of the device of the present invention, which can be used to perform the target distance detection method involved in the present invention. For details not disclosed in the embodiment of the device of the present invention, please refer to the method embodiment of the target distance detection method involved in the present invention.
[0111] See also Fig.10 , an embodiment of the present invention provides a target distance detection device 800.
[0112] The device 800 includes but is not limited to: a detection area calibration module 810 , a homography matrix calculation module 830 , a target detection module 850 and a target distance detection module 870 .
[0113] The detection area calibration module 810 is used to obtain a monitoring screen of a target scene and calibrate a detection area in the monitoring screen.
[0114] The homography matrix calculation module 830 is used to calculate the corresponding homography matrix according to the detection area.
[0115] The target detection module 850 is used to obtain the data to be detected and input it into the deep learning detection model to obtain multiple rectangles, and to obtain multiple targets by screening the multiple rectangles according to the divided areas through the intersection-and-union algorithm.
[0116] The target distance detection module 870 is used to obtain the actual coordinates of each target according to the homography matrix and calculate the actual size of each target and the relative physical distance between the targets.
[0117] It should be noted that, in the target distance detection provided in the above embodiment, only the division of the above functional modules is used as an example. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the target distance detection device will be divided into different functional modules to complete all or part of the functions described above.
[0118] In addition, the target distance detection device and the target distance detection method provided in the above embodiments belong to the same concept, and the specific manner in which each module performs the operation has been described in detail in the method embodiment, which will not be repeated here.
[0119] Fig.11 The present invention schematically illustrates the structure of an electronic device according to an exemplary embodiment.
[0120] It should be noted that the electronic device is only an example adapted to the present invention and cannot be considered to provide any limitation on the scope of use of the present invention. The electronic device cannot be interpreted as requiring dependence on or having Fig.11 One or more components of exemplary electronic device 2000 are shown.
[0121] The hardware structure of the electronic device 2000 may vary greatly due to differences in configuration or performance, such as Fig.11 As shown, the electronic device 2000 includes: a power supply 210 , an interface 230 , at least one memory 250 , and at least one central processing unit (CPU) 270 .
[0122] Specifically, the power supply 210 is used to provide operating voltage for each hardware device on the electronic device 2000 .
[0123] The interface 230 includes at least one wired or wireless network interface 231 for interacting with external devices. Of course, in other examples adapted by the present invention, the interface 230 may further include at least one serial-to-parallel conversion interface 233, at least one input-output interface 235, and at least one USB interface 237, etc. Fig.11 As shown, this is not intended to be a specific limitation.
[0124] The memory 250 is a carrier for storing resources, which may be a read-only memory, a random access memory, a disk or an optical disk, etc. The resources stored thereon include an operating system 251, an application 253 and data 255, etc. The storage method may be temporary storage or permanent storage.
[0125] Among them, the operating system 251 is used to manage and control various hardware devices and application programs 253 on the electronic device 2000 to enable the central processor 270 to calculate and process the massive data 255 in the memory 250. It can be WindowsServerTM, Mac OS XTM, UnixTM, LinuxTM, FreeBSDTM, etc.
[0126] The application program 253 is a computer-readable instruction that performs at least one specific task based on the operating system 251, and may include at least one module ( Fig.11 (not shown), each module may respectively include computer-readable instructions for the electronic device 2000. For example, the target distance detection device may be regarded as an application 253 deployed in the electronic device 2000.
[0127] The data 255 may be signal information, etc., stored in the memory 250 .
[0128] The central processor 270 may include one or more processors, and is configured to communicate with the memory 250 through at least one communication bus to read the computer-readable instructions stored in the memory 250, thereby realizing the operation and processing of the mass data 255 in the memory 250. For example, the target spacing detection method is completed by the central processor 270 reading a series of computer-readable instructions stored in the memory 250.
[0129] In addition, the present invention can also be implemented by hardware circuits or hardware circuits combined with software. Therefore, the implementation of the present invention is not limited to any specific hardware circuits, software, or a combination of the two.
[0130] See also Fig.12 In an embodiment of the present invention, an electronic device 4000 is provided. The electronic device 4000 may include: a desktop computer, a laptop computer, a server, etc. with sensor recognition capability.
[0131] exist Fig.12 In the embodiment, the electronic device 4000 includes at least one processor 4001 and at least one memory 4003.
[0132] The data interaction between the processor 4001 and the memory 4003 can be realized through at least one communication bus 4002. The communication bus 4002 may include a path for transmitting data between the processor 4001 and the memory 4003. The communication bus 4002 may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus. The communication bus 4002 can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Fig.12 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0133] Optionally, the electronic device 4000 may further include a transceiver 4004, which may be used for data interaction between the electronic device and other electronic devices, such as data transmission and / or data reception, etc. It should be noted that in actual applications, the transceiver 4004 is not limited to one, and the structure of the electronic device 4000 does not constitute a limitation on the embodiments of the present invention.
[0134] Processor 4001 may be a CPU (Central Processing Unit), a general-purpose processor, a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field Programmable Gate Array) or other programmable logic devices, transistor logic devices, hardware components or any combination thereof. It may implement or execute various exemplary logic blocks, modules and circuits described in conjunction with the disclosure of the present invention. Processor 4001 may also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, etc.
[0135] The memory 4003 can be a ROM (Read Only Memory) or other types of static storage devices that can store static information and instructions, a RAM (Random Access Memory) or other types of dynamic storage devices that can store information and instructions, or an EEPROM (Electrically Erasable Programmable Read Only Memory), a CD-ROM (Compact Disc Read Only Memory) or other optical disk storage, optical disk storage (including compressed optical disk, laser disk, optical disk, digital versatile disk, Blu-ray disk, etc.), a magnetic disk storage medium or other magnetic storage device, or any other medium that can be used to carry or store the desired program instructions or codes in the form of instructions or data structures and can be accessed by the electronic device 4000, but is not limited to this.
[0136] Computer-readable instructions are stored in the memory 4003 , and the processor 4001 can read the computer-readable instructions stored in the memory 4003 through the communication bus 4002 .
[0137] The computer-readable instructions are executed by one or more processors 4001 to implement the target distance detection method in the above-mentioned embodiments.
[0138] In addition, an embodiment of the present invention provides a storage medium on which computer-readable instructions are stored. The computer-readable instructions are executed by one or more processors to implement the target distance detection method as described above.
[0139] A computer program product is provided in an embodiment of the present invention. The computer program product includes computer-readable instructions. The computer-readable instructions are stored in a storage medium. One or more processors of an electronic device read the computer-readable instructions from the storage medium, load and execute the computer-readable instructions, so that the electronic device implements the target spacing detection method as described above.
[0140] Compared with the related art, the present invention has the following beneficial effects:
[0141] 1. The present invention first obtains a monitoring screen of the target scene, demarcates the detection area in the monitoring screen, calculates a corresponding homography matrix according to the detection area, the homography matrix is used to perspectively transform the detection area into a rectangular area in the real scene, obtains the data to be detected and inputs it into a deep learning detection model to obtain multiple rectangles, screens the multiple rectangles according to the divided areas through an intersection-and-union algorithm to obtain multiple targets, obtains the actual coordinates of each target according to the homography matrix, and calculates the actual size of each target and the relative physical distance between each target, introduces the homography matrix and uses matrix transformation in combination with the detection model to achieve mapping between screen pixels and physical positions, thereby judging the relationship between the actual physical distance between objects and the multiple of the size of the objects themselves, and judging the moving state of the objects through continuous frame images to ensure the detection of the relationship between objects in a relatively static state, and can achieve accurate interval measurement and classification of static goods, ensure that a safe distance is maintained between goods, and prevent potential risks, thereby effectively solving the problem that the prior art cannot accurately measure the actual physical distance between objects and cannot eliminate dynamic objects in real time.
[0142] 2. The present invention uses matrix transformation combined with a detection model to achieve the mapping of picture pixels and physical positions, thereby determining the relationship between the actual physical distance between objects and the multiples of the size of the objects themselves, and determines the movement state of the objects by introducing a tracking model to ensure the detection of the relationship between objects in a relatively static state.
[0143] 3. The present invention has precise space utilization and safety interval assurance: by adopting homography matrix and bird's-eye view transformation to realize the precise measurement of the size of the goods in the physical space, the storage space utilization is optimized, the safety distance around each piece of goods is ensured, and the potential risks caused by the domino effect are effectively prevented.
[0144] 4. The present invention can reduce the false alarm rate and improve monitoring efficiency: the advanced tracking model can effectively distinguish between stationary and moving objects, avoid false alarms during the placement of objects, and improve the real-time response capability and accuracy of the monitoring system.
[0145] 5. The present invention can enhance system adaptability: it is not dependent on a specific monitoring environment layout, has high adaptability and flexibility, and can be easily deployed in different logistics warehouses to adapt to different cargo types and storage configurations.
[0146] 6. The present invention is easy to operate and can reduce maintenance costs: it takes into account the convenience of user operation and reduces the threshold required for professional knowledge, so that logistics management personnel with non-technical backgrounds can also easily operate and maintain, reducing long-term maintenance costs.
[0147] It should be understood that, although the steps in the flowchart of the accompanying drawings are displayed in sequence as indicated by the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least a part of the steps in the flowchart of the accompanying drawings may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be executed in turn or alternately with other steps or at least a part of the sub-steps or stages of other steps.
[0148] The above descriptions are only some embodiments of the present invention. It should be pointed out that, for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. A target distance detection method, characterized in that: The method comprises: Acquire a monitoring picture of the target scene, and calibrate the detection area in the monitoring picture; A corresponding homography matrix is calculated according to the detection area; the homography matrix is used to perspective transform the detection area into a rectangular area in a real scene; Acquire multiple consecutive frames of images of the target scene as data to be detected, input the data to be detected into a deep learning detection model to obtain multiple rectangles and number them, and obtain the displacement of each rectangle through the continuous position change of each rectangle in the data to be detected; A time threshold and a distance threshold are set, and the displacement of each rectangle within the time threshold is compared with the distance threshold to obtain the motion state of each rectangle; the time threshold is used to define the duration of the static state; and the distance threshold is used to define the maximum displacement; If the displacement of the rectangle within the time threshold is less than the distance threshold, the rectangle is determined to be in a stationary state, and the minimum circumscribed matrix of each rectangle is calculated according to the position of each rectangle in the corresponding image and a division area is set, and whether each rectangle is in the division area is determined according to the minimum circumscribed matrix of each rectangle by an intersection-and-union algorithm, and the rectangle in the division area is taken as a target, and a plurality of targets are obtained; The position of each target is converted into a bird's-eye view coordinate in a real scene according to the homography matrix, and a size calculation method of each target is selected according to a geometric relationship between a camera and the detection area in the scene where the target is located; the size calculation method includes from the upper left corner to the lower right corner or from the upper right corner to the lower left corner; The actual size of each target is calculated based on the bird's-eye view coordinates of each target and the size calculation method, and the relative physical distance between each target is obtained based on the bird's-eye view coordinates and the actual size of each target.
2. The target distance detection method according to claim 1, characterized in that: The step of calculating a corresponding homography matrix according to the detection area includes: Selecting four detection corner points in the detection area, and determining actual coordinates of the four detection corner points in the real scene; Construct a linear equation group according to the coordinates of the four detected corner points in the detection area and the actual coordinates; The linear equations are solved by a numerical algorithm to obtain a corresponding homography matrix; the numerical algorithm includes a least squares method, a linear transformation and a singular value decomposition.
3. The target distance detection method according to claim 1, characterized in that: The obtaining of the relative physical distance between the targets according to the bird's-eye view coordinates and the actual size of the targets includes: Selecting corner points of each target according to the viewing angle and physical layout of the camera in the scene where each target is located; Obtaining the coordinates of the corner points of each target according to the corner points and the bird's-eye view coordinates of each target, and obtaining the coordinates of the center of mass of each target according to the bird's-eye view coordinates and the actual size of each target; The relative physical distance between the targets is obtained by calculating the coordinates of the corner points or the center of mass of the targets.
4. A target distance detection device, characterized in that: The device is applied to the target distance detection method according to any one of claims 1 to 3, and the device comprises: A detection area calibration module is used to obtain a monitoring picture of a target scene and calibrate a detection area in the monitoring picture; A homography matrix calculation module, used to calculate the corresponding homography matrix according to the detection area; A target detection module is used to obtain the data to be detected and input it into the deep learning detection model to obtain multiple rectangles, and to screen the multiple rectangles according to the divided areas through the intersection-over-union algorithm to obtain multiple targets; The target spacing detection module is used to obtain the actual coordinates of each of the targets according to the homography matrix and calculate the actual size of each of the targets and the relative physical distance between the targets.
5. An electronic device, characterized in that: include: at least one processor and at least one memory, wherein: The memory has computer-readable instructions stored thereon; The computer-readable instructions are executed by one or more of the processors so that the electronic device implements the target distance detection method according to any one of claims 1 to 3.
6. A storage medium having computer-readable instructions stored thereon, characterized in that: The computer-readable instructions are executed by one or more processors to implement the target distance detection method according to any one of claims 1 to 3.
