Automatic measurement system for flatness and size of automobile battery
By combining a line laser industrial camera with a point cloud processing algorithm and OpenCV, efficient and accurate automated measurement of the flatness and size of automotive batteries is achieved. This solves the problems of low manual measurement accuracy and high automation system resources in existing technologies, and improves production efficiency and measurement accuracy.
Patent Information
- Application Number
- CN202511120853.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-12
- Publication Date
- 2025-09-12
- Estimated Expiration
- 2045-08-12
AI Technical Summary
In existing technologies, the flatness and size measurement of automotive batteries relies on manual operation, resulting in poor repeatability and consistency of measurement results. In addition, automated measurement systems are difficult to meet the requirements of high efficiency and high precision on production lines with limited computing resources.
A line laser industrial camera is used to scan and photograph the battery, and point cloud processing algorithms and OpenCV algorithms are combined for automated measurement. The Qt dual-thread architecture is used to improve real-time performance and response speed, and the PLC communication module is used to achieve automated operation.
It achieves high-precision, automated battery flatness and size measurement, reduces human errors, improves measurement efficiency and accuracy, adapts to different production environments, and meets the needs of real-time and high efficiency.
Smart Images

Figure CN120627897A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image processing, and in particular to an automatic measurement system for the flatness and size of automobile batteries. Background Art
[0002] Existing technologies primarily rely on traditional manual measurement or simple optical inspection equipment to measure the flatness and dimensions of automotive batteries. These methods manually or semi-automatically measure the battery surface to assess whether its flatness and geometric dimensions meet standards. The main advantages of these methods are simplicity, low cost, and suitability for small-scale production environments.
[0003] However, in practical applications, these methods face significant technical challenges and limitations. First, traditional measurement tools rely on manual operation and are easily affected by the operator's technical level, resulting in poor repeatability and consistency of measurement results; second, optical inspection equipment has difficulty accurately capturing the details of the battery surface in complex environments (such as uneven light or surface reflections), affecting measurement accuracy. In addition, since there may be slight variations in the flatness and size of the battery surface, it is difficult for existing methods to achieve high-precision automated measurement, especially in large-scale production environments, where efficiency and accuracy are difficult to strike a balance. Automated measurement systems in existing technologies often require high computing resources, and in practical applications, these systems are often deployed on production lines with limited computing resources, such as industrial robots or automated equipment. This environment places higher demands on the real-time performance and computing efficiency of the algorithm, making it difficult for existing systems to meet the needs of efficient and accurate measurement, seriously affecting production efficiency and product quality consistency. Summary of the Invention
[0004] The present invention provides an automated measurement system for the flatness and dimensions of automotive batteries to address the problems in the prior art of low manual measurement accuracy and efficiency, the need to adjust the algorithm when replacing the battery, the ability to only detect deviations at fixed positions, and the high computing resource requirements of the existing automated measurement system, which makes it difficult to meet real-time and high efficiency requirements.
[0005] According to one aspect of the present invention, an automated flatness and size measurement system for automotive batteries is provided, comprising: a data acquisition module for scanning and photographing a battery using a line laser industrial camera to obtain a battery laser image; a point cloud processing module, connected to the data acquisition module, for converting the obtained laser image into point cloud data, processing the point cloud data based on a point cloud processing algorithm, calculating the flatness of the battery surface, and converting the point cloud data into a two-dimensional image using an algorithm within the line laser industrial camera. The point cloud data is then converted into an OpenCV algorithm to detect battery circular holes on the two-dimensional image and calculate the hole spacing and battery length; a programmable logic controller (PLC) communication module, connected to the point cloud processing module, for determining whether the battery is qualified based on the flatness, hole spacing, and length calculated by the point cloud processing module, and sending the determination result to a programmable logic controller (PLC); an automated control module, for reading data from the PLC and, based on the determination result, executing automated operations of a robotic arm and the line laser industrial camera under PLC control; and a front-end display module, connected to the data acquisition module, the point cloud processing module, and the PLC communication module, for displaying the data acquisition status, point cloud image, calculation results, and determination results, and enabling user interaction through a Qt interface.
[0006] Optionally, the automation control module is also used to control the robotic arm to grab the battery from the conveyor belt and place it on the upper layer of the battery scanning frame. The battery scanning frame adopts a two-layer structure, the upper layer places the battery to be tested, and the lower layer integrates a stepper motor and a line laser industrial camera. The line laser industrial camera is installed on the stepper motor, and the acquisition frequency, installation height and constant moving speed of the line laser industrial camera are set according to the length and width of the battery. The stepper motor drives the line laser industrial camera to move along the surface of the battery and completely photograph the battery to obtain a laser image.
[0007] Optionally, the point cloud processing module uses the Qt dual-thread architecture to separate point cloud data processing from two-dimensional image processing, and each is executed by an independent thread to improve real-time performance and response speed. The dual-thread architecture includes a main thread and a sub-thread, wherein the main thread is responsible for processing point cloud data, including point cloud acquisition, plane fitting, and flatness calculation. The point cloud data is processed through the PCL point cloud library, and the flatness of the battery surface is calculated in real time. After the processing is completed, the main thread sends the flatness result to the front-end interface through the Qt signal slot mechanism for display; the sub-thread is responsible for processing two-dimensional images. After the point cloud data is converted into a two-dimensional image through an independent program, it is passed to the sub-thread for processing. The sub-thread uses the OpenCV algorithm to perform circular hole detection, hole spacing calculation and battery length measurement on the two-dimensional image. After the processing is completed, the sub-thread sends the measurement result to the front-end interface through the signal slot mechanism for display.
[0008] Optionally, converting the obtained laser image into point cloud data includes: extracting resolution and offset from image calibration information of the laser image, wherein the resolution includes 、 、 , the offset includes 、 、 ,in, Indicates the actual distance represented by each pixel in the x-axis direction. Indicates the actual distance represented by each pixel in the y-axis direction, Indicates the actual distance represented by each unit of the depth value; Indicates the zero point offset in the x-axis direction, Indicates the zero point offset in the y-axis direction, Indicates the zero point offset in the z-axis direction; determines the valid row range and shielded area of the laser image based on predefined upper and lower filtering limits; downsamples the acquired laser data by taking a point every two rows and every two columns within the valid row range, and skipping the shielded area to reduce the point cloud density; retains points with depth values within a preset fixed range and performs z-direction filtering; Based on the downsampled and filtered data, the point cloud coordinates of each valid point are calculated using the extracted resolution and offset. The calculation formula is as follows: ; ; ; in 、 、 Represents the point cloud coordinates of valid points after downsampling and filtering; Represents the column index of the point cloud data, corresponding to the x-coordinate calculation in the formula; Indicates the row index of the point cloud data, corresponding to the y coordinate calculation in the formula; Represents the processed 16-bit depth data.
[0009] Optionally, the calculation of the flatness of the battery surface includes: performing plane fitting on the acquired point cloud data to obtain a plane equation; calculating the distance from each point in the point cloud data to the fitting plane; , and sorting the obtained distances in descending order; taking the difference between the 0.001% quantile and the 99.999% quantile after sorting to obtain a flatness index, which is used to characterize the flatness of the battery surface.
[0010] Optionally, performing plane fitting on the acquired point cloud data to obtain a plane equation includes: Calculate the geometric center of the point cloud data, that is, the centroid: ; Where, , is the coordinate of the center of mass; is the number of points in the point cloud data; is the index of the point; , indicating the The coordinates of the points; Subtract the coordinates of each point from the coordinates of the center of mass, and translate the point cloud to a coordinate system with the center of mass as the origin to obtain a centralized point cloud: ; Where, Indicates the A centralized point cloud; The covariance matrix is obtained based on the obtained centralized point cloud computing: ; Where, is the covariance matrix of the centralized point cloud; Extract eigenvalues of the covariance matrix: ; Where, is the eigenvector matrix, It is a diagonal matrix, and the elements on the diagonal are eigenvalues; The eigenvector corresponding to the minimum eigenvalue is the normal vector of the fitted plane, and the fitted plane equation is expressed as: ; Where, They represent the x, y, and z coordinates of any point in plane space.
[0011] Optionally, the distance between each point in the point cloud data and the fitting plane is calculated include: Target point , its distance to the fitting plane for: ; Where, represents the constant term of the plane equation, .
[0012] Optionally, converting the point cloud data into a two-dimensional image through an internal algorithm function of the line laser industrial camera includes: Use the API in the line laser industrial camera to process the point cloud data, perform pre-processing through statistical filtering, and remove discrete points; Use the camera intrinsic matrix and the external parameter matrix Project the processed point cloud onto the image plane: ; in, is the processed three-dimensional point cloud coordinate; is the two-dimensional coordinate after projection; For each pixel, find the nearest projection point and assign the pixel grayscale value of the nearest projection point to the pixel, thereby initially obtaining a two-dimensional image; The initial two-dimensional image is then normalized and Gaussian filtered to obtain the final two-dimensional image. The Gaussian filtering formula can be expressed as: ; ; in, represents the filtered image; represents the original two-dimensional image; represents a Gaussian filter; Indicates the standard deviation, which determines the filtering strength; Indicates the horizontal offset relative to the center pixel; Indicates the vertical offset relative to the center pixel.
[0013] Optionally, preprocessing is performed by statistical filtering to remove discrete points including: Target point , calculate the average distance to its neighboring points: ; in, Indicates a point The average distance to neighboring points; Indicates the number of adjacent points; Indicates the index of the adjacent point; is the current point; Yes No. a nearby point; Calculate all points The mean and standard deviation , set the threshold : ; in, is a multiplier defined according to the circumstances; Remove point.
[0014] Optionally, the use of the OpenCV algorithm to detect battery circular holes on a two-dimensional image and calculate the hole spacing and battery length includes: checking whether the converted two-dimensional image is empty and whether the size meets the requirements, and converting the grayscale image into a color image for visualization; defining and blocking specific areas in the image, and preprocessing the image using mean filtering, binarization, and opening operations; identifying circular marks in the image using the Hough circle detection method, and calculating the average grayscale value of pixels in the circular marks, wherein the calculation formula for the average grayscale value of pixels is: ; Where, represents the average grayscale value of pixels, is the sum of the pixel values in the circular area, is the area of the circular region; Valid circular markers are screened based on the average pixel grayscale value and the y-coordinate. Valid circular markers are those whose average pixel grayscale value within the circular marker area is lower than the preset threshold and whose y-coordinates are within the predefined three y-coordinate areas. Sort and mark the detected valid circular marks in ascending order of the vertical coordinates, and record their coordinates; Calculate the horizontal and vertical distances between the circular center marks of each area and deduce the width and length of the battery and the hole spacing.
[0015] The beneficial effects of the present invention are: 1. This invention uses a line laser industrial camera to scan and photograph batteries, processes the point cloud data based on a point cloud processing algorithm, calculates the flatness of the battery surface, and uses the OpenCV algorithm to detect battery circular holes and calculate the hole spacing and battery length. The fully automated operation achieves real-time detection, avoids the subjective errors of manual detection, and improves detection efficiency and accuracy. 2. Using Qt dual-thread technology, point cloud processing and 2D image processing are separated. This multi-threaded design significantly improves the system's display efficiency, ensuring a smooth user interface and real-time display effects when processing large amounts of data; 3. The present invention uses a line laser industrial camera to obtain laser image data of the battery surface with high precision. The camera's high resolution and laser scanning technology ensure the clarity of the image data and the ability to capture details. Especially in complex lighting or reflective environments, it can still maintain high measurement accuracy, accurately obtain the geometric characteristics of the battery, eliminate human errors, ensure the accurate detection of key dimensions, and improve the stability of the battery's feature positioning during dynamic shooting.
[0016] 4. The present invention solves the problem of combining manual debugging with automated operation, ensures efficient and accurate identification in automated detection scenarios, and improves the flexibility and adaptability of the system. The present invention uses point cloud real-time fitting planes that are dynamically adapted, and statistical indicators support dynamic adjustment of thresholds, which improves the measurement capabilities of batteries of different shapes and sizes, significantly enhancing the system's adaptability in various production scenarios. It can measure at different point cloud resolutions to ensure that battery features at different locations can be correctly identified, greatly improving the system's real-time performance and response speed, and can still quickly and accurately complete measurement tasks on production lines with limited resources. This solves the problems in the existing technology of low manual measurement accuracy, poor efficiency, the need to adjust the algorithm when replacing batteries, the ability to only check deviations at fixed positions, and the high computing resource requirements of existing automated measurement systems, which make it difficult to meet real-time and high efficiency requirements. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings: Figure 1 This is a schematic diagram of the architecture of an automated measurement system for flatness and size of automotive batteries according to an embodiment of the present invention; Figure 2 This is a schematic diagram of battery loading and unloading implemented by the automated control module according to an embodiment of the present invention; Figure 3 This is a schematic diagram of the front-end display module interface of the present invention. DETAILED DESCRIPTION
[0018] In order to enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only embodiments of a part of the present application, not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work should fall within the scope of protection of this application. It should be noted that, in the absence of conflict, the embodiments in the present application and the features in the embodiments can be combined with each other.
[0019] The terms "comprises" and "having" and any variations thereof in the specification and claims of this application are intended to cover non-exclusive inclusions. For example, a process, method, product or apparatus that includes a series of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, product or apparatus.
[0020] The embodiment of the present invention provides a schematic diagram of an automatic measurement system for flatness and size of automobile batteries, such as Figure 1 As shown, the system includes: Data acquisition module: used to scan and photograph the battery through a line laser industrial camera to obtain the battery laser image; Point cloud processing module: This module is connected to the data acquisition module and is used to convert the acquired laser image into point cloud data. This module processes the point cloud data based on the point cloud processing algorithm, calculates the flatness of the battery surface, and converts the point cloud data into a two-dimensional image using the internal algorithm function of the line laser industrial camera. The OpenCV algorithm is then used to detect the battery circular holes on the two-dimensional image and calculate the hole spacing and battery length. PLC communication module: connected to the point cloud processing module, used to judge whether the battery is qualified according to the flatness, hole spacing and length calculated by the point cloud processing module, and send the judgment result to the PLC; Automation control module: used to read data from PLC and execute automation operations of robotic arms and line laser industrial cameras under the control of PLC according to the judgment results, such as Figure 2 The automation control module controls the robotic claw (also known as the robotic arm) to grab the battery from the conveyor belt and place it on the upper layer of the battery scanning rack. After completing the battery inspection, the robotic claw is controlled to further process the battery according to its eligibility. Front-end display module: connected with data acquisition module, point cloud processing module and PLC communication module, such as Figure 3 As shown, it is used to display data acquisition status, point cloud images, calculation results and judgment results, and realize user interaction through the Qt interface.
[0021] During the specific implementation of the data acquisition module, the line laser industrial camera is pre-installed on the stepper motor on the battery scanning frame (the battery scanning frame is divided into two layers, the upper layer is used to place the battery to be inspected, and the lower layer integrates the stepper motor and the line laser industrial camera). The acquisition frequency, installation height and constant speed of the line laser industrial camera are set according to the approximate length and width of the battery. The stepper motor drives the line laser industrial camera to move under the battery and completely capture the battery to obtain laser image data.
[0022] When automatic data acquisition is started, the automation control module sends instructions to the data acquisition module and the battery scanning frame stepper motor. The line laser industrial camera starts to collect laser images, and the stepper motor moves the camera at a constant speed to obtain complete laser image data.
[0023] A line laser industrial camera can capture high-precision laser image data of the battery surface. The camera's high resolution and laser scanning technology ensure image clarity and detail capture, especially in complex lighting or reflective environments, maintaining high measurement accuracy and eliminating human error. Similarly, the data acquisition module reduces the computational burden of subsequent processing by optimizing the data acquisition process and implementing automated control, ensuring efficient system operation even in resource-constrained environments. The captured laser image data is transmitted via a wired network to the point cloud processing module, which converts the laser image into point cloud data. This module processes the point cloud data using a point cloud processing algorithm to calculate dimensions such as battery surface flatness, hole spacing, and length. The PLC communication module then determines and transmits this data to the automation control module, which controls the robotic arm loading and unloading HEV batteries and the automated operation of the line laser industrial camera based on the results. During this process, the data acquisition module, point cloud processing module, and PLC communication module display the acquisition status, point cloud image, measurement data, and judgment results to the front-end display module, which uses a Qt interface for data visualization and user interaction.
[0024] In this invention, Qt dual-thread technology is used to separate point cloud processing and two-dimensional image processing. This multi-threaded design significantly improves the display efficiency of the system, ensuring a smooth user interface and real-time display effects when processing large amounts of data. The Qt interface implements a user-friendly interactive design that can intuitively display the acquisition status, point cloud image, measurement data, and judgment results. Users can view the measurement results of key dimensions such as battery flatness, hole spacing, and length in real time through the interface, facilitating quick decision-making and greatly improving the debuggability and maintainability of the system. At the same time, users can choose automatic or manual mode according to actual needs, flexibly responding to different production environments and measurement requirements.
[0025] In a dual-threaded architecture: Main thread: Responsible for point cloud data processing, including point cloud acquisition, plane fitting, and flatness calculation. The main thread processes the point cloud data using the PCL point cloud library and calculates the battery surface flatness in real time. Once processed, the main thread sends the flatness results to the front-end interface for display via Qt's signal slot mechanism.
[0026] Sub-thread: Responsible for 2D image processing. Point cloud data is converted into 2D images by a separate program and then passed to the sub-thread for processing. The sub-thread uses OpenCV algorithms to detect circular holes, calculate hole spacing, and measure dimensions such as battery length. Once processing is complete, the sub-thread sends the measurement results to the front-end interface via a signal slot mechanism for display.
[0027] Qt's dual-thread design separates point cloud data processing from two-dimensional image processing, which are executed by independent threads respectively. This allows point cloud data processing and interface rendering to be executed in parallel, avoiding the interface freeze problem caused by the mutual blocking of data processing and interface rendering in single-threaded mode, significantly improving the real-time performance and response speed of the system, and improving the system's operating efficiency and user experience; the dual-thread design fully utilizes the computing power of multi-core CPUs, improving the overall operating efficiency of the system, especially when processing large-scale point cloud data; the main thread focuses on interface rendering and user interaction, ensuring that users can view measurement results and perform operations in real time, improving the system's user experience; the dual-thread architecture separates data processing from interface display, facilitating subsequent function expansion and maintenance; Qt's dual-thread design also supports joint debugging with the PLC communication module. Users can manually control the data acquisition and measurement process through the front-end interface, observe the system status in real time, and quickly locate and solve potential problems through the dual-thread mechanism, further enhancing the system's operability and debugging efficiency.
[0028] In the present invention, PLC communication is specifically implemented as follows: the program uses the snap7 library to realize communication with the PLC, and is able to modify the db block data in the PLC to perform specific operations; and uses Siemens S7-PLCSIM Advanced V6.0 technology to realize connection with the PLC communication module.
[0029] The point cloud processing module of the present invention is based on the acquired laser image and algorithm to accurately and effectively calculate flatness, detect battery round holes, and calculate hole spacing and battery length. The processing process mainly includes converting the laser image into a point cloud, plane fitting of the point cloud data, calculating flatness, converting the point cloud into two dimensions, detecting battery round holes, and calculating hole spacing and battery length. Specifically: S1, laser image converted into point cloud: When processing the acquired battery laser image, it is necessary to convert it into a point cloud. The point cloud conversion process includes: S11, extracting the resolution from the image calibration information of the laser image ( 、 、 ) and offset ( 、 、 ),in, Indicates the actual distance represented by each pixel in the x-axis direction, Indicates the actual distance represented by each pixel in the y-axis direction, Indicates the actual distance represented by each unit of the depth value (conversion coefficient); Indicates the zero point offset in the x-axis direction, Indicates the zero point offset in the y-axis direction, Indicates the zero point offset in the z-axis direction; In the embodiment of the present invention, a line laser camera is used to obtain depth information. By measuring the laser reflection time or phase difference, the depth value (Z value) of each point is directly obtained instead of being generated through a pixel grid. The resulting point cloud data is unstructured. The Z value may come from a non-uniformly sampled depth sensor, which is different from the regular pixel grid (X / Y value) of the image. Therefore, the depth value in this step is not generated by the pixel grid. The concept of "pixel" is not involved. That is to say, in the depth map, the Z value is indeed stored in the form of pixels, but the physical meaning is still the depth value output by the sensor, not the pixel spacing. The concept of "pixel" is only used after it is subsequently converted into a two-dimensional image.
[0030] S12, according to the predefined upper and lower limits of filtering ( )and Calculate the effective range of rows that need to be processed in the laser map ( ), From the camera image calibration data, we obtain the regions of interest, where Used to define the valid row range ( ), Used to define the shielded area ( ); It should be noted that the reason only the valid row range is defined in this step is that the line laser camera used in the embodiments of the present invention typically scans the surface of an object by emitting a laser line (in a single column or narrow band). The generated point cloud data is naturally continuous in the column direction (X-axis), while the depth information in the row direction (Y-axis) varies more significantly (such as the position of a circular hole). Therefore, the x-area (column area) covered by the laser line is generally valid (unless there is occlusion) and no additional restrictions are required.
[0031] in, The calculation formula is as follows: , subscript ; S13, downsampling the depth data according to the defined valid line range and shielded area, reducing the point cloud density by interval sampling. Specifically, according to Starting from the starting point, take a point every two rows and a point every two columns. For example, in a 6X6 matrix, take the points at (1,1), (4,1), (1,4), (4,4). At the same time, during the sampling process, skip the defined Shielding areas to further reduce the processing of invalid data; S14, defining a preset fixed range based on the actual battery height range, retaining only points whose depth values (in the z direction) are within this preset fixed range, removing interference points from background or irrelevant areas, and performing z-direction filtering; S15, based on the downsampled and filtered data, uses the extracted resolution and offset to calculate the three-dimensional spatial coordinates of each valid point: ; ; ; in 、 、 Represent the point cloud coordinates of the valid points after downsampling and filtering respectively; Indicates the column index of the point cloud data (X-axis direction), corresponding to the x-coordinate calculation in the formula; Indicates the row index (Y-axis direction) of the point cloud data, corresponding to the y-coordinate calculation in the formula; Represents the processed 16-bit depth data.
[0032] Through the above steps, the input laser image is converted into a downsampled and depth-filtered 3D point cloud dataset.
[0033] S2, point cloud data plane fitting: The plane fitting method includes a RANSAC (RANdom Sampling Consensus) algorithm or a least squares method. In an embodiment of the present invention, the plane fitting includes the following steps: S21, calculating the centroid (i.e., the geometric center of the point cloud data) of the point cloud data obtained after processing in S1; S22, using the difference between the coordinates of each point and the coordinates of the center of mass, the point cloud is translated to a coordinate system with the center of mass as the origin to obtain a centralized point cloud; S23, then calculate and obtain the covariance matrix, extract the eigenvalue of the matrix, and the eigenvector corresponding to the minimum eigenvalue is the normal vector of the fitted plane; The formula of the above plane fitting process is as follows: ; ; ; ; Where, , is the coordinate of the center of mass; is the number of points in the point cloud data; is the index of the point; , indicating the The coordinates of the points; Indicates the A centralized point cloud; is the covariance matrix of the centralized point cloud; is the eigenvector matrix, It is a diagonal matrix, and the elements on the diagonal are eigenvalues; The eigenvector corresponding to the minimum eigenvalue is the normal vector of the fitted plane, and the fitted plane equation is expressed as: ; Where, They represent the x, y, and z coordinates of any point in plane space.
[0034] S3, calculate flatness: Based on the fitted plane, the distances from all points to the plane are calculated, and the flatness of the battery surface is evaluated using statistics (such as maximum value, standard deviation, and peak-to-valley value). In this embodiment of the present invention, the difference between the maximum distance and the minimum distance is used to evaluate the flatness of the battery surface. Specifically, S3 includes: S31, calculate the distance between each point in the point cloud data and the fitting plane , and sort the obtained distances in descending order; S32, taking the difference between the 0.001% quantile (the extreme value of the maximum distance, reflecting the surface convexity) and the 99.999% quantile (the extreme value of the minimum distance, reflecting the surface concavity) after sorting to obtain a flatness index. The flatness index is used to characterize the flatness of the battery surface. The smaller the value, the flatter the surface; the larger the value, the more significant the difference in surface concavity. The calculation formula is as follows: ; Where, Represents the constant term of the plane equation, which is equal to the inverse of the inner product of the normal vector and a point on the plane, that is: .
[0035] S4, point cloud two-dimensionalization: Projecting the 3D point cloud into a 2D coordinate system relative to the fitted plane simplifies subsequent hole detection and size measurement.
[0036] In the embodiment of the present invention, the API in the line laser industrial camera is used to process the obtained point cloud data, which is first pre-processed by statistical filtering to remove discrete points; The filtering process includes: Calculation Point To its neighboring point (referring to The average distance to all other points within a certain range of the center: ; in, Indicates a point The average distance to neighboring points; Indicates the number of adjacent points; Indicates the index of the adjacent point; is the current point; yes No. a nearby point; Among them, the neighborhood point refers to the target point in the three-dimensional space All other points within a certain range of the center are calculated using the K-nearest neighbor method in the present invention, that is, the distance point is selected Recent points as neighborhood points.
[0037] Then calculate all points of The mean and standard deviation , set the threshold , remove all Points (discrete points), threshold The calculation is as follows: ; in, is a multiplier defined according to the situation.
[0038] After discrete point filtering, use the camera intrinsic parameter matrix and the external parameter matrix Project the point cloud onto the image plane: ; in, is the three-dimensional point cloud coordinate after filtering; is the two-dimensional coordinate after projection; For each pixel, find the nearest projection point and assign the pixel grayscale value of the nearest projection point to the pixel, thereby initially obtaining a two-dimensional image; The initial two-dimensional image is then normalized and Gaussian filtered to obtain the final two-dimensional image. The Gaussian filtering formula can be expressed as: ; ; in, represents the filtered image; represents the original two-dimensional image; represents a Gaussian filter; represents the standard deviation (determines the filtering strength); Indicates the horizontal (column) offset relative to the center pixel (negative for left and positive for right); Indicates the vertical (row) offset relative to the center pixel (negative for up and positive for down).
[0039] S5, detect the battery holes and calculate the hole spacing and battery length: The two-dimensional image is processed using OpenCV to detect circular battery holes and calculate dimensions such as hole spacing and battery length. The algorithm code checks whether the input image is empty and that the dimensions meet the requirements, and converts the grayscale image to a color image for visualization. Specific areas in the image are defined and masked, and the image is preprocessed using mean filtering, binarization, and opening operations. Circular markers in the image are identified using the Hough circle detection method, and valid circular markers are selected based on the pixel grayscale average and vertical coordinate. The pixel average value is calculated as follows: ; Where, represents the average grayscale value of pixels, is the sum of the pixel values in the circular area, is the area of the circular region (i.e., the number of pixels).
[0040] The average grayscale value of pixels in the circular mark area is lower than the preset threshold (to exclude the influence of highlights) and is located in the predefined three y-coordinate areas. The circular mark is valid, where the predefined three y-coordinate areas include the top, middle, and bottom intervals. Only circles that meet the regional positions are retained. The detected valid circular marks are sorted and marked in ascending order of the vertical coordinates, and their coordinates are recorded. The horizontal and vertical distances between the circular center marks in each area are calculated, and the width, length, and hole spacing of the battery are calculated based on these distances. The processed image is scaled to the specified size and the result is output. Afterwards, the output result is compared with the standard size to determine whether the battery size is qualified. If it is within the preset standard range, it is judged to be qualified, otherwise, it is unqualified.
[0041] In actual production, ambient lighting may affect the quality of camera scanning. Therefore, for undetected circular marks, Hough circle detection is performed again in a predefined local area and its coordinates are corrected to solve possible problems. For images with multiple circular marks detected, Hough circle detection is performed again in a predefined local area and the average circle center position coordinates are obtained using the following code: circles_part[0][0]=circles_part[0][0]+circle_local[i].x−100; circles_part[0][1]=circles_part[0][1]+circle_local[i].y−100; circles_part[0][0] / = circle_local.size(); circles_part[0][1] / = circle_local.size(); Among them, circles_part[0][0] and circles_part[0][1] represent the created circle containers, with an initial value of 0; circle_local[i].x and circle_local[i].y represent the xy coordinates of the centers of multiple circles extracted; the last two equations represent the calculation of the average center coordinates.
[0042] By combining advanced point cloud imaging technology with automated measurement algorithms, this invention provides an efficient and accurate automated measurement system for the flatness and dimensions of automotive batteries. The system utilizes a multi-module architecture, including data acquisition, point cloud processing, automated control, PLC communication, and front-end display modules. Each module plays a key role in the battery measurement process. In particular, the PCL point cloud library, least squares method, OpenCV algorithm, and Qt dual-threading technology ensure that the system can perform efficient and accurate battery measurements in diverse production environments. By combining parallel computing with real-time data processing, the system meets the high-precision and efficiency requirements of large-scale production. The final measurement results are not only visually displayed on the front-end interface but can also automatically trigger subsequent automated operations through the PLC communication module, further enhancing the system's applicability and flexibility. Through these technological innovations, the battery measurement system of this invention can significantly improve production efficiency and measurement accuracy, reduce labor costs and false positives, and has broad application prospects, particularly in the large-scale production of HEV batteries.
[0043] The above is only a preferred embodiment 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 within the scope of protection of the present invention.
Claims
1. An automatic measurement system for flatness and size of automobile batteries, characterized in that: include: A data acquisition module is used to scan and photograph the battery using a line laser industrial camera to obtain a battery laser image; The point cloud processing module is connected to the data acquisition module and is used to convert the acquired laser image into point cloud data. The point cloud data is processed based on the point cloud processing algorithm to calculate the flatness of the battery surface. The point cloud data is converted into a two-dimensional image using the internal algorithm of the line laser industrial camera. The OpenCV algorithm is then used to detect the battery circular holes on the two-dimensional image and calculate the hole spacing and battery length. The PLC communication module is connected to the point cloud processing module and is used to judge whether the battery is qualified according to the flatness, hole spacing and length calculated by the point cloud processing module, and send the judgment result to the PLC; The automation control module is used to read the data in the PLC and, based on the judgment results, execute the automation operation of the robotic arm and the line laser industrial camera under the control of the PLC; The front-end display module is connected to the data acquisition module, point cloud processing module and PLC communication module. It is used to display the data acquisition status, point cloud image, calculation results and judgment results, and realize user interaction through the Qt interface.
2. The automatic measurement system for flatness and size of automobile batteries according to claim 1, characterized in that: The automation control module is also used to control the robotic arm to grab the battery from the conveyor belt and place it on the upper layer of the battery scanning frame. The battery scanning frame adopts a two-layer structure, the upper layer is used to place the battery to be tested, and the lower layer integrates the stepper motor and the line laser industrial camera. The line laser industrial camera is installed on the stepper motor, and the acquisition frequency, installation height and constant moving speed of the line laser industrial camera are set according to the length and width of the battery. The stepper motor drives the line laser industrial camera to move along the surface of the battery and completely photograph the battery to obtain a laser image.
3. The automated flatness and size measurement system for automobile batteries according to claim 1, characterized in that: The point cloud processing module uses Qt dual-thread architecture to separate point cloud data processing from two-dimensional image processing, and each is executed by an independent thread to improve real-time performance and response speed. The dual-thread architecture includes a main thread and a sub-thread. in, Main thread: Responsible for point cloud data processing, including point cloud acquisition, plane fitting, and flatness calculation. It processes point cloud data through the PCL point cloud library and calculates the flatness of the battery surface in real time. After processing is completed, the main thread sends the flatness result to the front-end interface through the Qt signal slot mechanism for display; Sub-thread: Responsible for the processing of two-dimensional images. After the point cloud data is converted into a two-dimensional image through an independent program, it is passed to the sub-thread for processing. The sub-thread uses the OpenCV algorithm to detect circular holes, calculate hole distances, and measure battery length on the two-dimensional image. After processing is completed, the sub-thread sends the measurement results to the front-end interface through the signal slot mechanism for display.
4. The automatic measurement system for flatness and size of automobile batteries according to claim 1, characterized in that: The converting of the obtained laser image into point cloud data comprises: The resolution and offset are extracted from the image calibration information of the laser image, where the resolution includes 、 、 , the offset includes 、 、 ,in, Indicates the actual distance represented by each pixel in the x-axis direction. Indicates the actual distance represented by each pixel in the y-axis direction, Indicates the actual distance represented by each unit of the depth value; Indicates the zero point offset in the x-axis direction, Indicates the zero point offset in the y-axis direction, Indicates the zero point offset in the z-axis direction; Determine the effective line range and shielding area of the laser image according to the predefined upper and lower filtering limits; Within the valid row range, a point is taken every two rows, a point is taken every two columns, and the shielded area is skipped to downsample the acquired laser data to reduce the point cloud density; Keep the points whose depth values are within the preset fixed range and perform z-direction filtering; Based on the downsampled and filtered data, the point cloud coordinates of each valid point are calculated using the extracted resolution and offset. The calculation formula is as follows: ; ; ; in 、 、 Represents the point cloud coordinates of valid points after downsampling and filtering; Represents the column index of the point cloud data, corresponding to the x-coordinate calculation in the formula; Indicates the row index of the point cloud data, corresponding to the y coordinate calculation in the formula; Represents the processed 16-bit depth data.
5. The automatic measurement system for flatness and size of automobile batteries according to claim 1, characterized in that: The calculation of the flatness of the battery surface includes: Perform plane fitting on the acquired point cloud data to obtain the plane equation; Calculate the distance from each point in the point cloud data to the fitted plane , and sort the obtained distances in descending order; The difference between the 0.001% quantile and the 99.999% quantile after sorting is taken to obtain a flatness index, which is used to characterize the flatness of the battery surface.
6. The automatic measurement system for flatness and size of automobile batteries according to claim 5, characterized in that: The plane equation obtained by performing plane fitting on the acquired point cloud data includes: Calculate the geometric center of the point cloud data, that is, the centroid: ; Where, , is the coordinate of the center of mass; is the number of points in the point cloud data; is the index of the point; , indicating the The coordinates of the points; Subtract the coordinates of each point from the coordinates of the center of mass, and translate the point cloud to a coordinate system with the center of mass as the origin to obtain a centralized point cloud: ; Where, Indicates the A centralized point cloud; The covariance matrix is obtained based on the obtained centralized point cloud computing: ; Where, is the covariance matrix of the centralized point cloud; Extract eigenvalues of the covariance matrix: ; Where, is the eigenvector matrix, It is a diagonal matrix, and the elements on the diagonal are eigenvalues; The eigenvector corresponding to the minimum eigenvalue is the normal vector of the fitted plane, and the fitted plane equation is expressed as: ; Where, They represent the x, y, and z coordinates of any point in plane space.
7. The automated flatness and size measurement system for automobile batteries according to claim 6, characterized in that: The distance between each point in the calculated point cloud data and the fitting plane include: Target point , its distance to the fitting plane for: ; Where, represents the constant term of the plane equation, .
8. The automatic measurement system for flatness and size of automobile batteries according to claim 1, characterized in that: The method of converting point cloud data into a two-dimensional image by using the internal algorithm function of the line laser industrial camera includes: Use the API in the line laser industrial camera to process the point cloud data, perform pre-processing through statistical filtering, and remove discrete points; Use the camera intrinsic matrix and the external parameter matrix Project the processed point cloud onto the image plane: ; in, is the processed three-dimensional point cloud coordinate; is the two-dimensional coordinate after projection; For each pixel, find the nearest projection point and assign the pixel grayscale value of the nearest projection point to the pixel, thereby initially obtaining a two-dimensional image; The initial two-dimensional image is then normalized and Gaussian filtered to obtain the final two-dimensional image. The Gaussian filtering formula can be expressed as: ; ; in, represents the filtered image; represents the original two-dimensional image; represents a Gaussian filter; Indicates the standard deviation, which determines the filtering strength; Indicates the horizontal offset relative to the center pixel; Indicates the vertical offset relative to the center pixel.
9. The automatic measurement system for flatness and size of automobile batteries according to claim 8, characterized in that: Preprocessing is performed through statistical filtering to remove discrete points including: Target point , calculate the average distance to its neighboring points: ; in, Indicates a point The average distance to neighboring points; Indicates the number of adjacent points; Indicates the index of the adjacent point; is the current point; Yes No. a nearby point; Calculate all points The mean and standard deviation , set the threshold : ; in, is a multiplier defined according to the circumstances; Remove point.
10. The automatic measurement system for flatness and size of automobile batteries according to claim 1, characterized in that: The method of detecting battery circular holes on a two-dimensional image and calculating the hole spacing and battery length using the OpenCV algorithm includes: Check whether the converted 2D image is empty and whether the size meets the requirements, and convert the grayscale image to a color image for visualization; Define and block specific areas in the image, and preprocess the image using mean filtering, binarization, and opening operations; The circular marks in the image are identified by the Hough circle detection method, and the average grayscale value of the pixels in the circular marks is calculated. The calculation formula of the average grayscale value of the pixels is: ; Where, represents the average grayscale value of pixels, is the sum of the pixel values in the circular area, is the area of the circular region; Valid circular markers are screened based on the average pixel grayscale value and the y-coordinate. Valid circular markers are those whose average pixel grayscale value within the circular marker area is lower than the preset threshold and whose y-coordinates are within the predefined three y-coordinate areas. Sort and mark the detected valid circular marks in ascending order of the vertical coordinates, and record their coordinates; Calculate the horizontal and vertical distances between the circular center marks of each area and deduce the width and length of the battery and the hole spacing.
Citation Information
Patent Citations
Planeness measurement system and method
CN104422406A
Roadway roof support steel belt drilling positioning method based on radar and vision fusion
CN115877400A
Point cloud data processing method and device, equipment and medium
CN117372483A
Ship three-dimensional point cloud model height measurement method based on machine learning algorithm
CN117630958A
Transmission tower cross arm height identification method, system and device and medium
CN117689708A