Foreign matter height calculation method and device based on binocular vision and storage medium
Patent Information
- Application Number
- CN202410730790.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-06
- Publication Date
- 2026-09-25
- Estimated Expiration
- 2044-06-06
AI Technical Summary
[0004]本发明提供了一种基于双目视觉的异物高度计算方法、装置及存储介质,以解决目前产品中异物高度测量效率低的问题
[0022]本发明提供的技术方案,通过位于物流线上方同一高度处的第一相机和第二相机分别拍照得到第一图像和第二图像,获取第一图像中每个异物的第一特征向量,获取第二图像中每个异物的第二特征向量。根据所述第一特征向量和所述第二特征向量确定关联的第一异物和第二异物,所述第一异物为第一图像中的异物,所述第二异物为第二图像中的异物,所述第一异物和所述第二异物指向同一个异物实体;根据所述第一异物的坐标、所述第二异物的坐标以及预设光心距离参数确定异物距离;根据第一图像中待检测产品的第一底部中心点的坐标、第二图像中待检测产品的第二底部中心点的坐标以及所述预设光心距离参数确定底面距离;最后根据所述底面距离和所述异物距离确定异物高度。相对于目前人工手动检查异物高度或者3D激光扫描的方式,本发明提供的技术方案能够根据第一图像和第二图像确定两个图像中关联的第一异物和第二异物,然后根据第一异物的坐标、第二异物坐标以及预设光心距离参数计算出异物实体到第一相机和第二相机光心的距离,根据待检测产品的第一底部中心点的坐标、第二图像中待检测产品的第二底部中心点的坐标以及所述预设光心距离参数确定底面距离,最终根据底面距离和所述异物距离确定异物高度。上述过程无需人工参与,能够自动化的计算异物高度,提高异物高度计算效率。此外,通过对第一图像和第二图像中异物的比对,能够确定关联的第一异物和第二异物,进而准确计算出异物实体到第一相机和第二相机光心的距离,在此基础上得到的异物高度更加精准,提高异物高度计算的准确性。
Smart Images

Figure CN118608590B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image processing technology, and in particular to a method, apparatus and storage medium for calculating the height of foreign objects based on binocular vision. Background Technology
[0002] With the advent of the intelligent era, industrial machines are increasingly being used in product manufacturing. The production process includes automated stages such as welding, assembly, and grinding. These automated stages inevitably generate foreign matter such as welding slag and particles, which remain in the product. For products with high safety requirements, these foreign objects can affect their performance.
[0003] Traditional inspection methods include manual visual inspection and 3D laser scanning. Manual visual inspection is subject to the subjective nature of the human eye. If the product is picked up for inspection, the inspection speed is further reduced, leading to low efficiency in manual measurement. Laser scanning, on the other hand, suffers from inaccuracies because the area containing the foreign object is abruptly different from a flat surface, and the surface of the foreign object is generally uneven, making it prone to data loss. Therefore, 3D laser scanning cannot accurately calculate the height of foreign objects. How to automate and quickly calculate the height of foreign objects in products has become a pressing problem to be solved. Summary of the Invention
[0004] This invention provides a method, device, and storage medium for calculating the height of foreign objects based on binocular vision, in order to solve the problem of low efficiency in measuring the height of foreign objects in current products.
[0005] According to a first aspect of the present invention, a method for calculating the height of a foreign object based on binocular vision is provided. The product to be inspected is placed on a logistics line, and a first camera and a second camera are located at the same height above the logistics line to photograph the product to be inspected. The method includes:
[0006] Obtain the first feature vector of each foreign object in the first image, and obtain the second feature vector of each foreign object in the second image. The first image is an image of the product to be detected acquired by the first camera, and the second image is an image of the product to be detected acquired by the second camera.
[0007] Based on the first feature vector and the second feature vector, a first foreign object and a second foreign object are determined to be associated. The first foreign object is the foreign object in the first image, and the second foreign object is the foreign object in the second image. The first foreign object and the second foreign object point to the same foreign object entity.
[0008] The distance to the foreign object is determined based on the coordinates of the first foreign object, the coordinates of the second foreign object, and a preset optical center distance parameter. The distance to the foreign object represents the distance from the foreign object entity to the optical centers of the first and second cameras.
[0009] The bottom distance is determined based on the coordinates of the first bottom center point of the product to be detected in the first image, the coordinates of the second bottom center point of the product to be detected in the second image, and the preset optical center distance parameter.
[0010] The height of the foreign object is determined based on the distance to the bottom surface and the distance to the foreign object.
[0011] According to a second aspect of the present invention, a binocular vision-based foreign object height calculation device is provided, wherein the product to be inspected is placed on a logistics line, and a first camera and a second camera are located at the same height above the logistics line for photographing the product to be inspected, the device comprising:
[0012] The feature vector acquisition module is used to acquire the first feature vector of each foreign object in the first image and the second feature vector of each foreign object in the second image. The first image is an image of the product to be detected acquired by the first camera, and the second image is an image of the product to be detected acquired by the second camera.
[0013] The association determination module is used to determine the associated first foreign object and second foreign object based on the first feature vector and the second feature vector, wherein the first foreign object is a foreign object in the first image, the second foreign object is a foreign object in the second image, and the first foreign object and the second foreign object point to the same foreign object entity;
[0014] The foreign object distance determination module is used to determine the foreign object distance based on the coordinates of the first foreign object, the coordinates of the second foreign object, and a preset optical center distance parameter. The foreign object distance represents the distance from the foreign object entity to the optical center of the first camera and the second camera.
[0015] The bottom distance determination module is used to determine the bottom distance based on the coordinates of the first bottom center point of the product to be detected in the first image, the coordinates of the second bottom center point of the product to be detected in the second image, and the preset optical center distance parameter.
[0016] The height determination module is used to determine the height of the foreign object based on the distance to the bottom surface and the distance to the foreign object.
[0017] According to a third aspect of the present invention, an electronic device is provided, the electronic device comprising:
[0018] At least one processor; and
[0019] A memory communicatively connected to the at least one processor; wherein,
[0020] The memory stores a computer program that can be executed by the at least one processor, the computer program being executed by the at least one processor to enable the at least one processor to perform the binocular vision-based foreign object height calculation method described in any embodiment.
[0021] According to a fourth aspect of the present invention, a computer-readable storage medium is provided, the computer-readable storage medium storing computer instructions for causing a processor to execute and implement the binocular vision-based method for calculating the height of foreign objects as described in any embodiment of the present invention.
[0022] The technical solution provided by this invention involves taking photos with a first camera and a second camera located at the same height above the logistics line to obtain a first image and a second image, respectively. A first feature vector is obtained for each foreign object in the first image, and a second feature vector is obtained for each foreign object in the second image. Based on the first and second feature vectors, associated first and second foreign objects are determined. The first foreign object is the one in the first image, and the second foreign object is the one in the second image, both pointing to the same foreign object entity. The distance between the foreign objects is determined based on the coordinates of the first and second foreign objects and a preset optical center distance parameter. The bottom surface distance is determined based on the coordinates of the first bottom center point of the product to be inspected in the first image, the coordinates of the second bottom center point of the product to be inspected in the second image, and the preset optical center distance parameter. Finally, the height of the foreign object is determined based on the bottom surface distance and the foreign object distance. Compared to current methods of manually inspecting foreign object height or using 3D laser scanning, the technical solution provided by this invention can identify a first and a second foreign object in the first and second images respectively. Then, based on the coordinates of the first and second foreign objects and a preset optical center distance parameter, the distance from the foreign object to the optical centers of the first and second cameras is calculated. The bottom surface distance is determined based on the coordinates of the first bottom center point of the product under inspection, the coordinates of the second bottom center point of the product under inspection in the second image, and the preset optical center distance parameter. Finally, the height of the foreign object is determined based on the bottom surface distance and the distance of the foreign object. This process requires no manual intervention and can automatically calculate the foreign object height, improving the efficiency of foreign object height calculation. Furthermore, by comparing foreign objects in the first and second images, the associated first and second foreign objects can be identified, thereby accurately calculating the distance from the foreign object to the optical centers of the first and second cameras. The resulting foreign object height is more accurate, improving the overall accuracy of foreign object height calculation.
[0023] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of the present invention, nor is it intended to limit the scope of the invention. Other features of the invention will become readily apparent from the following description. Attached Figure Description
[0024] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0025] Figure 1 This is a flowchart illustrating a method for calculating the height of foreign objects based on binocular vision, provided in Embodiment 1 of the present invention.
[0026] Figure 2 This is a schematic diagram of the positional relationship between the camera and the logistics line provided in Embodiment 1 of the present invention;
[0027] Figure 3 This is a schematic diagram of the structure of the product to be tested provided in Embodiment 1 of the present invention;
[0028] Figure 4 This is a schematic diagram of the first image captured by the first camera according to Embodiment 1 of the present invention;
[0029] Figure 5 This is a schematic diagram of a second image captured by the second camera according to Embodiment 1 of the present invention;
[0030] Figure 6 This is a schematic diagram of perspective projection provided in Embodiment 1 of the present invention;
[0031] Figure 7 This is a schematic diagram of a planar image of perspective projection provided in Embodiment 1 of the present invention;
[0032] Figure 8 This is an imaging schematic diagram of the standard part provided in Embodiment 1 of the present invention;
[0033] Figure 9 This is a schematic diagram of the structure of a foreign object height calculation device based on binocular vision provided in Embodiment 2 of the present invention;
[0034] Figure 10 This is a schematic diagram of the structure of an electronic device provided in Embodiment 3 of the present invention. Detailed Implementation
[0035] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.
[0036] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0037] With the advent of the intelligent era, industrial machines are increasingly being used in product manufacturing. The production process includes automated stages such as welding, assembly, and grinding. These automated stages inevitably generate foreign matter such as welding slag and particles, which can remain in the product. For products with high safety requirements, such as explosion-proof valves for solar panels, these foreign objects can affect the product's performance. Solar panel explosion-proof valves can be cylindrical containers. During automated processing, foreign objects may remain inside the explosion-proof valve. The explosion-proof valve has a transparent membrane on its upper surface and may have a perforated area at the bottom.
[0038] By comparing the height of the foreign object with the standard distance between the top of the transparent film and the perforated area on the bottom, the distance from the top of the foreign object to the transparent film can be determined. If this distance is too small, when a certain pressure is applied to the transparent film, the film will dent downwards, potentially causing the film to be punctured by the foreign object. This is unacceptable for products with strict safety requirements.
[0039] This solution provides a binocular vision-based method for calculating the height of foreign objects. It uses two fixed 2D cameras (a first camera and a second camera) at the same height to simultaneously capture images (resulting in a first image and a second image, respectively). By illuminating the foreign object within the membrane, the feature vector of the foreign object captured by each camera is calculated and matched. Combined with relevant invariant parameters obtained from standard components (i.e., preset optical center distance parameters), the height of each foreign object is indirectly calculated. This method is cost-effective and adaptable to complex foreign object shapes. The technical solution provided by this invention is illustrated below through embodiments.
[0040] Example 1
[0041] Figure 1This is a flowchart illustrating the foreign object height calculation method based on binocular vision provided in Embodiment 1 of the present invention. This embodiment is applicable to the automated calculation of foreign object heights for products on a logistics line. The method can be executed by a binocular vision-based foreign object height calculation device, which can be implemented in hardware and / or software. The method includes:
[0042] S110. Obtain the first feature vector of each foreign object in the first image, and obtain the second feature vector of each foreign object in the second image.
[0043] Wherein, the first image is an image of the product to be inspected acquired by the first camera, and the second image is an image of the product to be inspected acquired by the second camera.
[0044] like Figure 2 As shown, the logistics line can be a conveyor belt used to transport objects. The object to be inspected, i.e., the product to be inspected, is placed on the logistics line. A first camera and a second camera are located at the same height above the logistics line to photograph the product. When the product moves into the shooting range of the first and second cameras, the logistics line is controlled to stop transporting the product. The first and second cameras can be 2D cameras. The first and second cameras are placed directly above the logistics line; optionally, the optical axes of the first and second cameras are perpendicular to the conveyor belt.
[0045] The product to be tested can be any geometric shape with internal grooves, such as a cylinder, cuboid, cube, or elliptical cylinder. The surface of the product can have a perforated design or remain a solid plane. A transparent film is applied to the upper surface of the product. This transparent film can have a fixed color, such as blue, green, or red.
[0046] For example, the product to be tested and the foreign object structure, such as Figure 3 As shown, taking an elliptical cylinder as an example, the bottom surface of the product to be tested is elliptical, and there are foreign objects inside the transparent membrane.
[0047] Optionally, obtaining the first feature vector of each foreign object in the first image can be implemented as follows:
[0048] Obtain the first bottom region of the product to be detected in the first image, and determine the first bottom center point based on the bottom region; obtain the area of the first connected region of each foreign object in the first image; calculate the first centroid distance from the centroid of each connected region to the first bottom center point; determine the first feature vector of each foreign object in the first image based on the area of the first connected region and the first centroid distance.
[0049] The first bottom region of the product to be inspected is identified from the first image. The geometric center of the first bottom region, i.e., the first bottom center point, is calculated based on its coordinates. The first image may include one or more foreign objects, each represented by a first connected region. The area of the first connected region for each foreign object is calculated. Based on the first connected region of each foreign object, the centroid of the first connected region is calculated, and the distance from this centroid to the first bottom center point is taken as the first centroid distance. The calculated area of the first connected region and the first centroid distance are used as the first feature vector for each foreign object.
[0050] For example, the first image is as follows Figure 4 As shown, Figure 4 It contains three foreign object connected regions, namely A1, A2, and A3. This application embodiment does not limit the number of foreign object connected regions. Figure 4 As an example only. Point E is the first bottom center point in the first image captured by the first camera, and the coordinates of point E are (E... x E y A1, A2, A3...A m Let A be the m connected components of foreign objects in the first image. i For A1, A2, A3...A m For any connected domain of a foreign object, A i Coordinates are (A) xi A yi The area of the connected region is A. Si A m The distance from the centroid to point E is A. Li Foreign object A i The first feature vector is shown below:
[0051]
[0052] The first feature vectors of the connected regions of all foreign objects in the first image are represented by Table 1.
[0053] Table 1
[0054]
[0055] Obtaining the second feature vector of each foreign object in the second image can be implemented as follows: obtaining the second bottom region of the product to be detected in the second image, and determining the second bottom center based on the bottom region; obtaining the second connected region area of each foreign object in the second image; calculating the second centroid distance from the centroid of each connected region to the second bottom center point; and determining the second feature vector of each foreign object in the second image based on the second connected region area and the second centroid distance.
[0056] The second bottom region of the product to be inspected is identified from the second image. The geometric center of the second bottom region, i.e., the second bottom center point, is calculated based on its coordinates. The second image may include one or more foreign objects, each represented by a second connected region. The area of the second connected region for each foreign object is calculated. Based on the second connected region of each foreign object, the centroid of the second connected region is calculated, and the distance from this centroid to the second bottom center point is taken as the second centroid distance. The calculated area of the second connected region and the second centroid distance are used as the second feature vector for each foreign object.
[0057] For example, the first image is as follows Figure 5 As shown, Figure 5 It contains three foreign object connected regions, namely B1, B2, and B3. This application embodiment does not limit the number of foreign object connected regions. Figure 5 As an example only. Point F is the second bottom center point in the second image captured by the second camera, and the coordinates of point F are (F... x F y B1, B2, B3...B n Let x be the connected component of n foreign objects in the second image. x can be equal to y. B j For B1, B2, B3...B n For any connected domain of a foreign object, B j Coordinates are (B) xj B yj The area of the connected region corresponding to this is B. Sj B j The distance from the centroid to point F is B. Lj Foreign object B j The feature vectors are shown below:
[0058]
[0059] The second feature vectors of the connected regions of all foreign objects in the second image are represented by Table 2.
[0060] Table 2
[0061]
[0062] Furthermore, if the centroid distance and the area of the connected domain cannot determine the first and second foreign objects associated with each other, the dimensions included in the feature vector can be increased. These dimensions include: the angle between the line connecting the centroid of the connected domain to the center point of the ground and the horizontal direction, the location region of the connected domain, or the outer matrix of the connected domain.
[0063] Specifically, the first feature vector also includes a combination of one or more of the following dimensions: the angle between the line connecting the centroid of a connected region in the first image to the center point of the ground and the horizontal direction, the location region of the connected region, or the outer matrix of the connected region; the second feature vector also includes a combination of one or more of the following dimensions: the angle between the line connecting the centroid of a connected region in the second image to the center point of the ground and the horizontal direction, the location region of the connected region, or the outer matrix of the connected region. When the first feature vector adds a certain dimension, the second feature vector adds the same dimension accordingly.
[0064] The bottom center point can also be replaced by other feature points at the bottom, such as the point with the largest horizontal and vertical coordinates at the bottom.
[0065] S120. Determine the associated first foreign object and second foreign object based on the first feature vector and the second feature vector.
[0066] Wherein, the first foreign object is the foreign object in the first image, the second foreign object is the foreign object in the second image, and the first foreign object and the second foreign object point to the same foreign object entity.
[0067] Optionally, determining the associated first and second foreign objects based on the first feature vector and the second feature vector includes:
[0068] Select any first feature vector as the feature vector of the first foreign object; calculate the variance between the feature vector of the first foreign object and all second feature vectors; identify the foreign object identified by the second feature vector with the smallest variance value as the second foreign object, and determine the association between the first foreign object and the second foreign object.
[0069] Table 1 records the first feature vectors of all foreign objects in the first image. Table 2 records the second feature vectors of all foreign objects in the second image. To find the correspondence between the first and second feature vectors, the feature vectors in Tables 1 and 2 can be iterated through, and the associated first and second feature vectors can be found using the minimum variance method, thereby determining the associated first and second foreign objects. The associated first and second foreign objects can be determined using the following formula.
[0070]
[0071] in,
[0072] According to the above formula, the i-th foreign object is selected from all foreign objects captured by the first camera. Then, foreign objects captured by the second camera are selected sequentially. The feature vector of each foreign object is extracted from the feature vector table, and the variance is calculated. If the variance of the j-th foreign object selected from the second camera is the smallest compared to the i-th foreign object in the first camera, then the i-th foreign object captured by the first camera and the j-th foreign object captured by the second camera are determined to be the same foreign object, and the associated first and second foreign objects are obtained. This process continues until every foreign object captured by the first camera can be found among the foreign objects captured by the second camera.
[0073] S130. Determine the distance of the foreign object based on the coordinates of the first foreign object, the coordinates of the second foreign object, and a preset optical center distance parameter. The distance of the foreign object represents the distance from the foreign object entity to the optical center of the first camera and the second camera.
[0074] Before determining the distance to the foreign object based on the coordinates of the first foreign object, the coordinates of the second foreign object, and a preset optical center distance parameter, the process also includes:
[0075] Obtain the distance between the test point on the logistics line and the line connecting the optical centers of the first camera and the second camera; obtain the x-coordinate of the first imaging point of the test point in the first camera image and the x-coordinate of the second imaging point of the second camera image, and calculate the difference in imaging point coordinates; multiply the distance between the test point and the line connecting the optical centers of the first camera and the second camera image by the difference in imaging point coordinates to obtain the preset optical center distance parameter.
[0076] The preset optical center distance parameter is calculated in the above manner, thereby calculating the preset optical center distance parameter that matches the first camera and the second camera.
[0077] The binocular vision imaging principle applicable to this application is as follows: Figure 6 As shown, assume the focal length of the two cameras is f, and the distance between the optical centers of the first camera OA and the second camera OB is d. A point P in the scene is located at a distance D from the line connecting the optical centers of the first and second cameras. The image coordinates of point P in the first image captured by the first camera are Qa, and the image coordinates of point P in the second image captured by the second camera are Qb. The width of both the first and second images is w. Assuming the distance between image point Qa in the first image and image point Qb in the second image is g, the planar schematic diagram of the imaging principle is as follows. Figure 7 As shown. ZA is the optical axis direction of the first camera, and ZB is the optical axis direction of the second camera. xa is the horizontal axis of the first image, and ya is the vertical axis of the first image. CA is the point on the first image corresponding to the optical axis of the first camera. xb is the horizontal axis of the second image, and yb is the vertical axis of the second image. CB is the point on the second image corresponding to the optical axis of the second camera. According to... Figure 7 From the planar schematic diagram of similar triangles presented in the image, we can obtain the following relationship:
[0078]
[0079] Assuming that the horizontal coordinates of imaging point Qa in the first image and imaging point Qb in the second image are Qax and Qbx respectively, the following formula can be derived from the above formula:
[0080] g=d-(Qax-w / 2)-(w / 2-Qbx) formula (2);
[0081] Combining the two formulas above, we can obtain the following formula (3):
[0082] fd=D*(Qax-Qbx) formula (3);
[0083] Therefore, the product of the camera focal length f and the distance d between the optical centers of the two cameras can be obtained by using the same point in space that can be imaged by the two cameras as the preset optical center distance parameter.
[0084] In actual production, the reliability of the machine is usually first tested using standard parts. Standard parts, i.e., products without foreign objects, are placed on the logistics line. A schematic diagram of the standard part under perspective projection is shown below. Figure 8 As shown, point C is the center of the transparent film on the upper surface, and point G is the center of the bottom surface.
[0085] Assume that the center of the transparent film in the first image captured by the first camera is Ca, and the center of the bottom surface is Ga. In the second image captured by the second camera, the center of the transparent film is Cb, and the center of the bottom surface is Gb. Then, according to formula (3), we can obtain:
[0086] fd = D C *(Cax-Cbx) Formula (4);
[0087] fd = D G *(Gax-Gbx) formula (5);
[0088] Where Cax is the x-coordinate of point Ca, Cbx is the x-coordinate of point Cb, Gax is the x-coordinate of point Ga, and Gbx is the x-coordinate of point Gb.
[0089] Since the height from the top surface to the bottom surface of the standard part is a known quantity, let it be H. std ,Right now:
[0090] H std =D C -D G Formula (6);
[0091] Combining formulas (4), (5), and (6), we can obtain:
[0092]
[0093] Where fd is the correlation invariant parameter between the two cameras, i.e., the preset optical center distance parameter.
[0094] Optionally, the distance to the foreign object can be determined based on the coordinates of the first foreign object, the coordinates of the second foreign object, and a preset optical center distance parameter. This can be implemented in the following way:
[0095] Subtract the x-coordinate of the first foreign object from the x-coordinate of the second foreign object to obtain the first difference value;
[0096] Divide the preset optical center distance parameter by the first difference to obtain the distance to the foreign object.
[0097] Based on the found foreign object and combined with formula (3), the distance Dk from the foreign object k to the optical center of the two cameras can be calculated using the following formula:
[0098]
[0099] S140. Determine the bottom surface distance based on the coordinates of the first bottom center point of the product to be detected in the first image, the coordinates of the second bottom center point of the product to be detected in the second image, and the preset optical center distance parameter.
[0100] Optionally, the bottom surface distance can be determined based on the coordinates of the first bottom center point of the product to be detected in the first image, the coordinates of the second bottom center point of the product to be detected in the second image, and the preset optical center distance parameter. This can be implemented in the following way:
[0101] The second difference is obtained by subtracting the x-coordinate of the first bottom center point of the product to be detected in the first image from the x-coordinate of the second bottom center point of the product to be detected in the second image.
[0102] Divide the preset optical center distance parameter by the second difference to obtain the bottom surface distance.
[0103] Based on the first bottom center point E and the second bottom center point F, and combined with formula (3), the distance D from the bottom center point to the optical center of the two cameras can be obtained. EF It can be calculated using the following formula:
[0104]
[0105] S150. Determine the height of the foreign object based on the bottom surface distance and the distance to the foreign object.
[0106] Optionally, the height of the foreign object can be determined based on the bottom surface distance and the distance to the foreign object, which can be achieved by subtracting the distance to the foreign object from the bottom surface distance to obtain the height of the foreign object.
[0107] The distance D from the obtained foreign object k to the optical center of the two cameras kThe distance D from the bottom center point to the optical center of the two cameras EF Subtracting the two values gives the height of the object.
[0108] The present invention provides a method for calculating the height of foreign objects based on binocular vision. This method involves taking photos with a first camera and a second camera located at the same height above the logistics line to obtain a first image and a second image, respectively. A first feature vector is obtained for each foreign object in the first image, and a second feature vector is obtained for each foreign object in the second image. Based on the first and second feature vectors, associated first and second foreign objects are determined. The first foreign object is the one in the first image, and the second foreign object is the one in the second image, both pointing to the same entity. The distance between the foreign objects is determined based on the coordinates of the first and second foreign objects and a preset optical center distance parameter. The bottom surface distance is determined based on the coordinates of the first bottom center point of the product to be detected in the first image, the coordinates of the second bottom center point of the product to be detected in the second image, and the preset optical center distance parameter. Finally, the height of the foreign object is determined based on the bottom surface distance and the distance between the foreign objects. Compared to current methods of manually inspecting foreign object height or using 3D laser scanning, the technical solution provided by this invention can identify a first and a second foreign object in the first and second images respectively. Then, based on the coordinates of the first and second foreign objects and a preset optical center distance parameter, the distance from the foreign object to the optical centers of the first and second cameras is calculated. The bottom surface distance is determined based on the coordinates of the first bottom center point of the product to be inspected, the coordinates of the second bottom center point of the product to be inspected in the second image, and the preset optical center distance parameter. Finally, the height of the foreign object is determined based on the bottom surface distance and the foreign object distance. This process requires no manual intervention and can automatically calculate the foreign object height, improving the efficiency of foreign object height calculation. Furthermore, by comparing foreign objects in the first and second images, the associated first and second foreign objects can be identified, thereby accurately calculating the distance from the foreign object to the optical centers of the first and second cameras. The resulting foreign object height is more accurate, improving the overall accuracy of foreign object height calculation.
[0109] Example 2
[0110] Figure 9 This is a schematic diagram of a foreign object height calculation device based on binocular vision provided in Embodiment 2 of the present invention. The product to be inspected is placed on a logistics line, and a first camera and a second camera are located at the same height above the logistics line for photographing the product. The device includes:
[0111] The feature vector acquisition module 21 is used to acquire the first feature vector of each foreign object in the first image and the second feature vector of each foreign object in the second image. The first image is an image of the product to be detected acquired by the first camera, and the second image is an image of the product to be detected acquired by the second camera.
[0112] The association determination module 22 is used to determine the associated first foreign object and second foreign object based on the first feature vector and the second feature vector. The first foreign object is a foreign object in the first image, and the second foreign object is a foreign object in the second image. The first foreign object and the second foreign object point to the same foreign object entity.
[0113] The foreign object distance determination module 23 is used to determine the foreign object distance based on the coordinates of the first foreign object, the coordinates of the second foreign object, and a preset optical center distance parameter. The foreign object distance represents the distance from the foreign object entity to the optical center of the first camera and the second camera.
[0114] Bottom surface distance determination module 24 is used to determine the bottom surface distance based on the coordinates of the first bottom center point of the product to be detected in the first image, the coordinates of the second bottom center point of the product to be detected in the second image, and the preset optical center distance parameter.
[0115] The height determination module 25 is used to determine the height of the foreign object based on the bottom surface distance and the distance to the foreign object.
[0116] Optionally, based on the above implementation method, the feature vector acquisition module 21 is used for:
[0117] Obtain the first bottom region of the product to be detected in the first image, and determine the first bottom center point based on the bottom region; obtain the area of the first connected region of each foreign object in the first image; calculate the first centroid distance from the centroid of each connected region to the first bottom center point; determine the first feature vector of each foreign object in the first image based on the area of the first connected region and the first centroid distance.
[0118] The feature vector acquisition module 21 is used to: acquire the second bottom region of the product to be detected in the second image, and determine the second bottom center based on the bottom region; acquire the second connected region area of each foreign object in the second image; calculate the second centroid distance from the centroid of each connected region to the second bottom center point; and determine the second feature vector of each foreign object in the second image based on the second connected region area and the second centroid distance.
[0119] Optionally, based on the above implementation, the first feature vector further includes a combination of one or more of the following dimensions: the angle between the line connecting the centroid of the connected domain to the center point of the ground in the first image and the horizontal direction, the location region where the connected domain is located, or the outer matrix of the connected domain.
[0120] The second feature vector also includes a combination of one or more of the following dimensions: the angle between the line connecting the centroid of the connected domain to the center point of the ground in the second image and the horizontal direction, the location region of the connected domain, or the outer matrix of the connected domain.
[0121] Optionally, based on the above implementation method, the association determination module 22 is used for:
[0122] Select any first feature vector as the feature vector of the first foreign object;
[0123] Calculate the variance between the eigenvector of the first foreign object and all the second eigenvectors;
[0124] The foreign object identified by the second eigenvector with the smallest variance value is designated as the second foreign object, thus determining the association between the first and second foreign objects.
[0125] Optionally, based on the above implementation method, the foreign object distance determination module 23 is used for:
[0126] Determining the distance to the foreign object based on the coordinates of the first foreign object, the coordinates of the second foreign object, and a preset optical center distance parameter includes:
[0127] Subtract the x-coordinate of the first foreign object from the x-coordinate of the second foreign object to obtain the first difference value;
[0128] Divide the preset optical center distance parameter by the first difference to obtain the distance to the foreign object.
[0129] Optionally, based on the above implementation method, the bottom surface distance determination module 24 is used for:
[0130] The second difference is obtained by subtracting the x-coordinate of the first bottom center point of the product to be detected in the first image from the x-coordinate of the second bottom center point of the product to be detected in the second image.
[0131] Divide the preset optical center distance parameter by the second difference to obtain the bottom surface distance.
[0132] Optionally, based on the above embodiments, the height determination module 25 is used for:
[0133] The height of the foreign object is obtained by subtracting the distance of the foreign object from the distance of the bottom surface.
[0134] Optionally, based on the above embodiments, a parameter determination module is further included, used for:
[0135] Obtain the distance between the test point on the logistics line and the line connecting the optical centers of the first and second cameras;
[0136] Obtain the x-coordinate of the first image point of the test point in the first camera image and the x-coordinate of the second image point in the second camera, and calculate the difference in image point coordinates.
[0137] Multiply the distance from the test point to the line connecting the optical centers of the first and second cameras by the difference in the coordinates of the imaging point to obtain the preset optical center distance parameter.
[0138] The present invention provides a foreign object height calculation device based on binocular vision, comprising: a feature vector acquisition module 21, used to acquire a first feature vector of each foreign object in a first image and a second feature vector of each foreign object in a second image, wherein the first image is an image of the product to be detected acquired by a first camera and the second image is an image of the product to be detected acquired by a second camera; an association determination module 22, used to determine an associated first foreign object and a second foreign object based on the first feature vector and the second feature vector, wherein the first foreign object is a foreign object in the first image and the second foreign object is a foreign object in the second image, and the first foreign object and the second foreign object point to the same foreign object entity; a foreign object distance determination module 23, used to determine the foreign object distance based on the coordinates of the first foreign object, the coordinates of the second foreign object, and a preset optical center distance parameter, wherein the foreign object distance represents the distance from the foreign object entity to the optical center of the first camera and the second camera; a bottom surface distance determination module 24, used to determine the bottom surface distance based on the coordinates of the first bottom center point of the product to be detected in the first image, the coordinates of the second bottom center point of the product to be detected in the second image, and the preset optical center distance parameter; and a height determination module 25, used to determine the foreign object height based on the bottom surface distance and the foreign object distance.
[0139] Compared to current methods of manually inspecting foreign object height or using 3D laser scanning, the technical solution provided by this invention can identify the first and second foreign objects associated with each other in the first and second images. Then, based on the coordinates of the first and second foreign objects and a preset optical center distance parameter, the distance from the foreign object to the optical centers of the first and second cameras is calculated. The bottom surface distance is determined based on the coordinates of the first bottom center point of the product under inspection, the coordinates of the second bottom center point of the product under inspection in the second image, and the preset optical center distance parameter. Finally, the height of the foreign object is determined based on the bottom surface distance and the distance of the foreign object. This process requires no manual intervention, enabling automated calculation of foreign object height and improving calculation efficiency. Furthermore, by comparing the foreign objects in the first and second images, the associated first and second foreign objects can be accurately identified, leading to accurate calculation of the distance from the foreign object to the optical centers of the first and second cameras. The resulting foreign object height is more accurate, further improving the accuracy of foreign object height calculation.
[0140] The object height calculation device based on binocular vision provided in this embodiment of the invention can execute the object height calculation method based on binocular vision provided in any embodiment of the invention, and has the corresponding functional modules and beneficial effects of the method.
[0141] Example 3
[0142] Figure 10This is a schematic diagram of the structure of an electronic device provided in Embodiment 3 of the present invention. The electronic device 10 is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices (such as helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the invention described and / or claimed herein.
[0143] like Figure 10 As shown, the electronic device 10 includes at least one processor 11 and a memory, such as a read-only memory (ROM) 12 or a random access memory (RAM) 13, communicatively connected to the at least one processor 11. The memory stores computer programs executable by the at least one processor. The processor 11 can perform various appropriate actions and processes based on the computer program stored in the ROM 12 or loaded from storage unit 18 into the RAM 13. The RAM 13 may also store various programs and data required for the operation of the electronic device 10. The processor 11, ROM 12, and RAM 13 are interconnected via a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0144] Multiple components in electronic device 10 are connected to I / O interface 15, including: input unit 16, such as keyboard, mouse, etc.; output unit 17, such as various types of displays, speakers, etc.; storage unit 18, such as disk, optical disk, etc.; and communication unit 19, such as network card, modem, wireless transceiver, etc. Communication unit 19 allows electronic device 10 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.
[0145] Processor 11 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. Processor 11 performs the various methods and processes described above, such as a binocular vision-based method for calculating the height of foreign objects.
[0146] In some embodiments, the binocular vision-based object height calculation method can be implemented as a computer program tangibly contained in a computer-readable storage medium, such as storage unit 18. In some embodiments, part or all of the computer program can be loaded and / or installed on electronic device 10 via ROM 12 and / or communication unit 19. When the computer program is loaded into RAM 13 and executed by processor 11, one or more steps of the binocular vision-based object height calculation method described above can be performed. Alternatively, in other embodiments, processor 11 can be configured to perform the binocular vision-based object height calculation method by any other suitable means (e.g., by means of firmware).
[0147] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), payload-programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.
[0148] Computer programs for implementing the binocular vision-based object height calculation method of the present invention can be written in any combination of one or more programming languages. These computer programs can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when executed by the processor, the functions / operations specified in the flowcharts and / or block diagrams are implemented. The computer programs can be executed entirely on the machine, partially on the machine, as a standalone software package partially on the machine and partially on a remote machine, or entirely on a remote machine or server.
[0149] Example 4
[0150] Embodiment 4 of the present invention also provides a computer-readable storage medium storing computer instructions. These instructions can be used to cause a processor to execute a method for calculating the height of a foreign object based on binocular vision. The product to be inspected is placed on a logistics line, and a first camera and a second camera are located at the same height above the logistics line to photograph the product. The method includes:
[0151] Obtain the first feature vector of each foreign object in the first image, and obtain the second feature vector of each foreign object in the second image. The first image is an image of the product to be detected acquired by the first camera, and the second image is an image of the product to be detected acquired by the second camera.
[0152] Based on the first feature vector and the second feature vector, a first foreign object and a second foreign object are determined to be associated. The first foreign object is the foreign object in the first image, and the second foreign object is the foreign object in the second image. The first foreign object and the second foreign object point to the same foreign object entity.
[0153] The distance to the foreign object is determined based on the coordinates of the first foreign object, the coordinates of the second foreign object, and a preset optical center distance parameter. The distance to the foreign object represents the distance from the foreign object entity to the optical centers of the first and second cameras.
[0154] The bottom distance is determined based on the coordinates of the first bottom center point of the product to be detected in the first image, the coordinates of the second bottom center point of the product to be detected in the second image, and the preset optical center distance parameter.
[0155] The height of the foreign object is determined based on the distance to the bottom surface and the distance to the foreign object.
[0156] Optionally, based on the above implementation method, obtaining the first feature vector of each foreign object in the first image includes:
[0157] Obtain the first bottom region of the product to be detected in the first image, and determine the first bottom center point based on the bottom region;
[0158] Obtain the area of the first connected region for each foreign object in the first image;
[0159] Calculate the distance from the centroid of each connected component to the first centroid of the first bottom center point;
[0160] Based on the area of the first connected region and the distance to the first centroid, determine the first feature vector of each foreign object in the first image;
[0161] Accordingly, the second feature vector of each foreign object in the second image is obtained, including:
[0162] Obtain the second bottom region of the product to be detected in the second image, and determine the center of the second bottom region based on the bottom region;
[0163] Obtain the area of the second connected region for each foreign object in the second image;
[0164] Calculate the distance from the centroid of each connected component to the second centroid of the second bottom center point;
[0165] The second feature vector of each foreign object in the second image is determined based on the area of the second connected region and the distance between the second centroid and the second centroid.
[0166] Optionally, based on the above implementation, the first feature vector further includes a combination of one or more of the following dimensions: the angle between the line connecting the centroid of the connected domain to the center point of the ground in the first image and the horizontal direction, the location region where the connected domain is located, or the outer matrix of the connected domain.
[0167] The second feature vector also includes a combination of one or more of the following dimensions: the angle between the line connecting the centroid of the connected domain to the center point of the ground in the second image and the horizontal direction, the location region of the connected domain, or the outer matrix of the connected domain.
[0168] Optionally, based on the above implementation method, determining the associated first and second foreign objects according to the first feature vector and the second feature vector includes:
[0169] Select any first feature vector as the feature vector of the first foreign object;
[0170] Calculate the variance between the eigenvector of the first foreign object and all the second eigenvectors;
[0171] The foreign object identified by the second eigenvector with the smallest variance value is designated as the second foreign object, thus determining the association between the first and second foreign objects.
[0172] Optionally, based on the above embodiments, determining the distance to the foreign object according to the coordinates of the first foreign object, the coordinates of the second foreign object, and a preset optical center distance parameter includes:
[0173] Subtract the x-coordinate of the first foreign object from the x-coordinate of the second foreign object to obtain the first difference value;
[0174] Divide the preset optical center distance parameter by the first difference to obtain the distance to the foreign object.
[0175] Optionally, based on the above embodiments, determining the bottom surface distance according to the coordinates of the first bottom center point of the product to be detected in the first image, the coordinates of the second bottom center point of the product to be detected in the second image, and the preset optical center distance parameter includes:
[0176] The second difference is obtained by subtracting the x-coordinate of the first bottom center point of the product to be detected in the first image from the x-coordinate of the second bottom center point of the product to be detected in the second image.
[0177] Divide the preset optical center distance parameter by the second difference to obtain the bottom surface distance.
[0178] Optionally, based on the above embodiments, determining the height of the foreign object according to the bottom surface distance and the distance to the foreign object includes:
[0179] The height of the foreign object is obtained by subtracting the distance of the foreign object from the distance of the bottom surface.
[0180] Optionally, based on the above embodiments, before determining the distance to the foreign object according to the coordinates of the first foreign object, the coordinates of the second foreign object, and the preset optical center distance parameter, the method further includes:
[0181] Obtain the distance between the test point on the logistics line and the line connecting the optical centers of the first and second cameras;
[0182] Obtain the x-coordinate of the first image point of the test point in the first camera image and the x-coordinate of the second image point in the second camera, and calculate the difference in image point coordinates.
[0183] Multiply the distance from the test point to the line connecting the optical centers of the first and second cameras by the difference in the coordinates of the imaging point to obtain the preset optical center distance parameter.
[0184] In the context of this invention, a computer-readable storage medium can be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, apparatus, or device. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination thereof. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.
[0185] To provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the electronic device. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).
[0186] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as data servers), or computing systems that include middleware components (e.g., application servers), or computing systems that include frontend components (e.g., user computers with graphical user interfaces or web browsers through which users can interact with implementations of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., communication networks). Examples of communication networks include local area networks (LANs), wide area networks (WANs), blockchain networks, and the Internet.
[0187] A computing system can include clients and servers. Clients and servers are generally located far apart and typically interact through communication networks. The client-server relationship is created by computer programs running on the respective computers and having a client-server relationship with each other. The server can be a cloud server, also known as a cloud computing server or cloud host, which is a hosting product within the cloud computing service system to address the shortcomings of traditional physical hosts and VPS services, such as high management difficulty and weak business scalability.
[0188] It should be understood that the various forms of processes shown above can be used, with steps reordered, added, or deleted. For example, the steps described in this invention can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution of this invention can be achieved, and this is not limited herein.
[0189] The specific embodiments described above do not constitute a limitation on the scope of protection of this invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this invention should be included within the scope of protection of this invention.
Claims
1. A method for calculating the height of a foreign object based on binocular vision, characterized in that, The product to be inspected is placed on a logistics line, and a first camera and a second camera are positioned at the same height above the logistics line to photograph the product to be inspected. The method includes: Obtaining the first feature vector of each foreign object in the first image includes: obtaining the first bottom region of the product to be detected in the first image, and determining the first bottom center point based on the bottom region; obtaining the area of the first connected region of each foreign object in the first image; calculating the first centroid distance from the centroid of each connected region to the first bottom center point; and determining the first feature vector of each foreign object in the first image based on the area of the first connected region and the first centroid distance; the first image is an image of the product to be detected acquired by the first camera. Obtaining the second feature vector of each foreign object in the second image includes: obtaining the second bottom region of the product to be detected in the second image, and determining the second bottom center based on the bottom region; obtaining the area of the second connected region of each foreign object in the second image; calculating the second centroid distance from the centroid of each connected region to the second bottom center point; and determining the second feature vector of each foreign object in the second image based on the area of the second connected region and the second centroid distance; the second image is an image of the product to be detected acquired by the second camera. Based on the first feature vector and the second feature vector, a first foreign object and a second foreign object are determined to be associated. The first foreign object is the foreign object in the first image, and the second foreign object is the foreign object in the second image. The first foreign object and the second foreign object point to the same foreign object entity. The distance to the foreign object is determined based on the coordinates of the first foreign object, the coordinates of the second foreign object, and a preset optical center distance parameter. The distance to the foreign object represents the distance from the foreign object entity to the optical centers of the first and second cameras. The bottom distance is determined based on the coordinates of the first bottom center point of the product to be detected in the first image, the coordinates of the second bottom center point of the product to be detected in the second image, and the preset optical center distance parameter. The height of the foreign object is determined based on the distance to the bottom surface and the distance to the foreign object.
2. The method according to claim 1, characterized in that, Determining the associated first and second foreign objects based on the first feature vector and the second feature vector includes: Select any first feature vector as the feature vector of the first foreign object; Calculate the variance between the eigenvector of the first foreign object and all the second eigenvectors; The foreign object identified by the second eigenvector with the smallest variance value is designated as the second foreign object, thus determining the association between the first and second foreign objects.
3. The method according to claim 1, characterized in that, The first feature vector also includes a combination of one or more of the following dimensions: the angle between the line connecting the centroid of the connected domain to the center point of the ground in the first image and the horizontal direction, the location region where the connected domain is located, or the outer matrix of the connected domain. The second feature vector also includes a combination of one or more of the following dimensions: the angle between the line connecting the centroid of the connected domain to the center point of the ground in the second image and the horizontal direction, the location region of the connected domain, or the outer matrix of the connected domain.
4. The method according to claim 1, characterized in that, Determining the distance to the foreign object based on the coordinates of the first foreign object, the coordinates of the second foreign object, and a preset optical center distance parameter includes: Subtract the x-coordinate of the first foreign object from the x-coordinate of the second foreign object to obtain the first difference value; Divide the preset optical center distance parameter by the first difference to obtain the distance to the foreign object.
5. The method according to claim 1, characterized in that, Determining the bottom surface distance based on the coordinates of the first bottom center point of the product to be detected in the first image, the coordinates of the second bottom center point of the product to be detected in the second image, and the preset optical center distance parameter includes: The second difference is obtained by subtracting the x-coordinate of the first bottom center point of the product to be detected in the first image from the x-coordinate of the second bottom center point of the product to be detected in the second image. Divide the preset optical center distance parameter by the second difference to obtain the bottom surface distance.
6. The method according to claim 1, characterized in that, Before determining the distance to the foreign object based on the coordinates of the first foreign object, the coordinates of the second foreign object, and a preset optical center distance parameter, the process also includes: Obtain the distance between the test point on the logistics line and the line connecting the optical centers of the first and second cameras; Obtain the x-coordinate of the first image point of the test point in the first camera image and the x-coordinate of the second image point in the second camera, and calculate the difference in image point coordinates. Multiply the distance from the test point to the line connecting the optical centers of the first and second cameras by the difference in the coordinates of the imaging point to obtain the preset optical center distance parameter.
7. A device for calculating the height of foreign objects based on binocular vision, characterized in that, The product to be inspected is placed on a logistics line. A first camera and a second camera are positioned at the same height above the logistics line to photograph the product. The device includes: The feature vector acquisition module is used to acquire the first feature vector of each foreign object in the first image, including: acquiring the first bottom region of the product to be detected in the first image, and determining the first bottom center point based on the bottom region; acquiring the area of the first connected region of each foreign object in the first image; calculating the first centroid distance from the centroid of each connected region to the first bottom center point; and determining the first feature vector of each foreign object in the first image based on the area of the first connected region and the first centroid distance; the first image is an image of the product to be detected acquired by the first camera; Obtaining the second feature vector of each foreign object in the second image includes: obtaining the second bottom region of the product to be detected in the second image, and determining the second bottom center based on the bottom region; obtaining the area of the second connected region of each foreign object in the second image; calculating the second centroid distance from the centroid of each connected region to the second bottom center point; and determining the second feature vector of each foreign object in the second image based on the area of the second connected region and the second centroid distance; the second image is an image of the product to be detected acquired by the second camera. The association determination module is used to determine the associated first foreign object and second foreign object based on the first feature vector and the second feature vector, wherein the first foreign object is a foreign object in the first image, the second foreign object is a foreign object in the second image, and the first foreign object and the second foreign object point to the same foreign object entity; The foreign object distance determination module is used to determine the foreign object distance based on the coordinates of the first foreign object, the coordinates of the second foreign object, and a preset optical center distance parameter. The foreign object distance represents the distance from the foreign object entity to the optical center of the first camera and the second camera. The bottom distance determination module is used to determine the bottom distance based on the coordinates of the first bottom center point of the product to be detected in the first image, the coordinates of the second bottom center point of the product to be detected in the second image, and the preset optical center distance parameter. The height determination module is used to determine the height of the foreign object based on the distance to the bottom surface and the distance to the foreign object.
8. An electronic device, characterized in that, The electronic device includes: At least one processor; and A memory communicatively connected to the at least one processor; wherein, The memory stores a computer program that can be executed by the at least one processor, the computer program being executed by the at least one processor to enable the at least one processor to perform the binocular vision-based method for calculating the height of foreign objects according to any one of claims 1-6.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions that cause a processor to execute the binocular vision-based method for calculating the height of foreign objects as described in any one of claims 1-6.
Citation Information
Patent Citations
Electric welding spot binocular vision positioning method and device based on shape descriptor
CN111862193A
Monocular distance measurement method for longitudinal positioning of structural defects of drainage pipeline and storage medium
CN115841449A