Machine vision-based method for detecting oil leakage from a speed reducer
By using a machine vision-based method to monitor changes in oil spots on the test paper at the bottom of the reducer in real time, and using the YOLOv8 model for image segmentation and area calculation, the problem of unstable accuracy in reducer oil leakage detection under complex environments is solved, and efficient and economical oil leakage detection is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CHINA YANGTZE POWER
- Filing Date
- 2024-09-25
- Publication Date
- 2026-04-17
AI Technical Summary
Existing methods for detecting oil leaks in reducers are not accurate enough in complex environments and are prone to misjudgment or missed detection. Furthermore, deep learning methods require a large amount of computing resources and are difficult to apply effectively in specific industrial scenarios.
A machine vision-based system is used, consisting of a light source, lens, camera, image acquisition device, and interactive software. It combines grayscale processing, Gaussian filtering, image averaging, and the YOLOv8 model to monitor the changes in oil spots on the test paper at the bottom of the reducer in real time. YOLOv8 is used for image segmentation and oil spot area calculation, and the alarm is controlled by a PLC to issue a warning.
It enables real-time monitoring and early warning of reducer oil leakage, reduces the time and cost of equipment disassembly and inspection, provides high-precision segmentation results and fast reasoning speed, is suitable for complex industrial environments, and does not require expensive testing equipment.
Smart Images

Figure CN120063593B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of oil leakage detection technology, and relates to a machine vision-based method for detecting oil leakage in reducers. Background Technology
[0002] Maintenance and upkeep of mechanical equipment are of paramount importance, especially for critical components such as speed reducers. During operation, speed reducers may leak oil due to various reasons, which not only wastes lubricating oil but can also lead to equipment malfunctions and even safety accidents. Therefore, researching effective methods for detecting speed reducer oil leaks has become an important research topic.
[0003] Traditional methods for detecting gearbox oil leaks mainly include periodic inspections and experience-based judgment. These methods typically rely on the operator's skill and experience, visually inspecting the gearbox to determine if a leak is present. However, this method has many limitations, such as high subjectivity, low efficiency, and the tendency to miss early, subtle signs of leakage. In recent years, with advancements in sensor and machine vision technologies, various automated detection methods have emerged to improve the efficiency and accuracy of gearbox oil leak detection.
[0004] Traditional image processing techniques still hold a place in oil leak detection. For example, in the petrochemical industry, machine vision and digital image processing technologies can effectively detect oil leaks in cooling water. This method typically involves converting the original image of the water body at the site into a 256-color grayscale image to highlight the edges of the oil droplets and performing necessary image enhancement. Subsequently, edge detection operators are used to delineate the edges of the oil droplets, segmenting the object and background to form a high-contrast binary image. The segmented binary image has obvious features such as area and perimeter, which can be identified through simple intra-class discrimination. In addition, template matching methods can be used to scan the entire image to determine similarity, and multi-recognizer integration methods can be employed to improve the reliability of the identification.
[0005] With the development of deep learning technology, neural network-based oil leak detection methods have become a research hotspot. These methods typically involve improving existing models to enhance detection accuracy and efficiency. For example, the improved YOLOv5 model adds a 4x sampling layer to the Feature Pyramid Network (FPN) structure, enabling cross-layer fusion of feature information and improving the model's detection accuracy. Furthermore, a Wise-IoU bounding box loss function with a dynamic non-monotonic focusing mechanism is introduced to accelerate network training and inference, and the overall performance of the model is further improved by balancing the learning of low-quality and high-quality samples. Finally, by using the EfficientViT model as the backbone network, although a small portion of detection performance is sacrificed, it still maintains performance superior to the original model while significantly reducing the number of model parameters, which is beneficial for engineering deployment.
[0006] Besides image processing and deep learning methods, sensor monitoring technology is also widely used in oil leak detection. For example, for oil leak detection in scraper conveyor reducers, oil reservoirs can be designed on the outer seals of the reducer's input and output ends. Leaking oil is introduced into an oil storage hole at a certain height from the bottom of the reservoir, and a pressure sensor is installed at the bottom of the storage hole to monitor changes in the internal oil pressure. This technology uses wireless transmission to achieve data exchange between the detection results and the PLC controller, enabling real-time monitoring of the reducer's oil leak status, timely detection of leaks, and prevention of equipment damage caused by leaks.
[0007] Currently, research on oil leak detection in speed reducers is relatively limited. Among the three detection methods mentioned above, traditional image processing-based methods are often highly sensitive to changes in lighting conditions and background, making them susceptible to environmental interference and resulting in unstable detection accuracy. Furthermore, they have a high false detection rate, easily misidentifying non-oil-contaminated objects as oil stains or missing actual oil contamination in complex environments. Sensor-based detection methods are easily affected by environmental changes, such as temperature and humidity, which can impact detection accuracy. They also suffer from low reliability, as sensors may experience false alarms or missed alarms due to aging or other reasons. Additionally, some sensors are only suitable for specific environmental conditions and have poor adaptability to complex and changing environments. Traditional deep learning methods often have high data requirements and computational resource consumption, which may be difficult to obtain for certain application scenarios. Moreover, the instability of the training set image quality for deep learning also significantly affects the model's prediction accuracy, posing a significant challenge to recognition accuracy in complex industrial environments such as speed reducer oil leaks. Summary of the Invention
[0008] The technical problem to be solved by the present invention is to provide a machine vision-based method for detecting oil leakage in reducers, which monitors the changes in oil spots on the test paper at the bottom of the reducer in real time, detects abnormal oil spots caused by oil leakage in the reducer in a timely manner and issues an early warning signal to prevent potential environmental or safety risks.
[0009] To solve the above-mentioned technical problems, the technical solution adopted by the present invention is: a machine vision-based method for detecting oil leakage in a reducer, comprising the following steps:
[0010] S1, Hardware Selection: A machine vision system consisting of a light source, lens, camera, image acquisition device, image analysis device, and interactive software is selected.
[0011] S2, Image Acquisition: Two cameras are mounted above the reducer. The cameras do not interfere with other moving mechanisms in the application environment and have a clear and unobstructed field of view. Images are acquired from the front to check whether there is oil dripping or oil spots on the bottom test paper. Images are also acquired from the rear to detect whether there are any abnormal changes in the area of the oil spots.
[0012] S3, grayscale processing, uses color feature-based grayscale processing to improve the quality of the acquired image;
[0013] S4, Image Filtering: Gaussian filtering is used for image preprocessing to remove noise while preserving the image's edges and other important features.
[0014] S5, Image Meansing, employs preprocessing techniques to reduce the mean of image data, making image features have zero mean and unit variance, thereby accelerating the training process and improving the model's convergence speed;
[0015] S6, Image Segmentation, uses YOLOv8 to classify each pixel in the image in order to identify specific object instances;
[0016] S7, Oil spot extraction: After extracting the mask of the oil spot region from the output of YOLOv8, the OpenCV findContours function is used to detect the contour of the oil spot region, and the contourArea function is used to calculate the area of the contour.
[0017] S8, Image Preprocessing, performs a series of preprocessing steps to reduce interference from various influencing factors; including grayscale processing based on color features, image filtering, and image averaging.
[0018] S9, Feature Recognition and Post-processing, uses YOLOv8 for object detection and instance segmentation, providing fast and accurate prediction, identifying the category and location of objects in the image, and generating a segmentation mask for each object, i.e., a pixel-level label; including loading the YOLOv8 model, image detection, extracting the image mask, contour detection, and oil spot area extraction.
[0019] S10, oil leak alarm. The image is segmented using the YOLOv8 model, and then the area change information of the image is obtained through OpenCV. The detected visual information is transmitted to the industrial control computer and the alarm is triggered by the Siemens PLC.
[0020] In S1, the lens selection factor is focal length, assuming the field of view is... The horizontal and vertical directions are respectively and The horizontal and vertical dimensions of the camera chip target surface are respectively and The detection distance is then focal length The calculation formula is:
[0021] ;
[0022] .
[0023] In S3, grayscale processing includes the following steps:
[0024] S3-1, Color Space Conversion, converts the original image from the RGB color space to another color space, including HSV hue, saturation, lightness or Lab brightness, a channel, b channel;
[0025] S3-2, Color Feature Extraction: Extracting channels related to specific color features from the transformed color space;
[0026] S3-3, Color thresholding: Based on the extracted color features, a threshold is set to divide the pixels in the image into foreground and background.
[0027] S3-4, Binarization processing: The image after color thresholding is binarized to obtain a binary image, in which the oil spot area is the foreground and the rest of the area is the background;
[0028] S3-5, Post-processing: Perform morphological operations on the binary image to remove noise or refine contours; perform connected component analysis on the binary image to extract oil spot regions.
[0029] In S4, image filtering includes the following steps:
[0030] S4-1, Select Gaussian kernel size. Choose an appropriate Gaussian kernel size based on the type of noise you need to remove.
[0031] S4-2, Construct a Gaussian kernel. Construct a two-dimensional Gaussian kernel, which is a discrete approximation of a two-dimensional Gaussian function;
[0032] S4-3, Normalized Gaussian kernel: To ensure that the sum of the filters is 1, the Gaussian kernel is normalized; calculate the sum of all elements, and then divide each element by this sum;
[0033] S4-4, Image Convolution: A normalized Gaussian kernel is used to perform a convolution operation with the image. For each pixel in the image, the Gaussian kernel is multiplied by the value of that pixel and its surrounding pixels, and the sum is obtained to get a new pixel value.
[0034] In S5, image averaging includes the following steps:
[0035] S5-1, Calculate the mean file, use all images in the training set to calculate the average image, that is, calculate the average pixel value of all training images for each pixel position;
[0036] S5-2, Subtract the mean: For each input image, subtract the corresponding mean value from each pixel position;
[0037] S5-3, Standardization: To further improve the convergence speed of the model, we choose to standardize the image after subtracting the mean, that is, divide it by the standard deviation or a fixed value, so that the features have unit variance.
[0038] In S6, image segmentation includes the following steps:
[0039] S6-1, Input image, feed the input image into the YOLOv8 network;
[0040] S6-2, Feature Extraction: Multi-scale feature maps of the image are extracted through the backbone network and the neck network.
[0041] S6-3, Segmentation prediction, performs prediction on the feature map. Each prediction unit corresponds to a location in the image. For instance segmentation, each prediction unit outputs a class prediction and a segmentation mask.
[0042] S6-4, Post-processing: Perform NMS (Non-maximum Suppression) on the prediction results to remove duplicate detection results, and filter out the final detection results based on the confidence threshold.
[0043] In S7, the contourArea function is used to calculate the area of a given contour. This function returns the area of the region enclosed by the contour, and specifically includes the following steps:
[0044] S7-1, YOLOv8 instance segmentation output. First, the YOLOv8 model segments the input image and generates a segmentation mask for each detected oil spot.
[0045] S7-2, Extract Mask: Extract the segmentation mask for each oil spot from the output of YOLOv8;
[0046] S7-3, Contour Detection: Use OpenCV's findContours function to detect contours in each oil spot mask;
[0047] S7-4, Calculate the area using the contourArea function to calculate the area of each contour.
[0048] In S8, image mean normalization adjusts the image data by subtracting a mean vector, making the input data have zero mean. This is performed during the input data preprocessing stage of the deep learning model. By normalizing, redundancy in the training data is reduced, making the model more likely to converge. Its core calculation process includes the following steps:
[0049] S8-1, calculate the mean vector. Define a two-dimensional array M to represent the pixel value matrix of all images in the training set. M is a four-dimensional tensor with dimensions N, H, W, and C, where N is the number of images, H is the height of the image, W is the width of the image, and C is the number of channels of the image. For grayscale images, C=1; for RGB images, C=3. Then calculate the mean vector μ.
[0050] S8-2, Subtract the mean: For a new input image I, convert it into a three-dimensional array, and for each pixel position (i,j,c), subtract the corresponding mean.
[0051] S8-3, to further improve the convergence speed of the model, we choose to standardize the image after subtracting the mean, that is, divide it by the standard deviation or a fixed value, so that the features have unit variance.
[0052] In S9, contour detection, based on segmentation masks, uses OpenCV's findContours function to detect contours within each mask. Contour detection helps understand the specific shape and distribution of oil spots. A contour is a series of continuous boundary points that form a closed shape. For segmentation masks, the contour refers to the boundary line of the oil spot. The specific steps include:
[0053] S9-1, Convert the mask to a binary image. If the segmentation mask is not given in the form of a binary image, first convert it to a black and white binary image.
[0054] S9-2, Find Contours: Use the findContours function to find the boundary formed by all non-zero pixels in the image;
[0055] S9-3, Contour sorting: If there are multiple contours, sort them according to area size or other criteria so that the largest contour can be selected as the primary target.
[0056] S9-4, Contour Drawing: The detected contours are drawn on the original image to visually display the segmentation results.
[0057] In S10, the oil leak alarm specifically includes the following steps:
[0058] S10-1, Image Acquisition and Processing: First, OpenCV is used to acquire real-time images from the camera, and image processing and target detection are performed. The images are preprocessed, including grayscale conversion, filtering, and contrast enhancement, to improve detection accuracy. Finally, the YOLOv8 image segmentation model is applied to analyze the images, identify and segment the oil stain regions.
[0059] S10-2, Data transmission: A TCP / IP connection is established through Python's socket library to send the detection results, including the location coordinates and area of oil spots, from the industrial computer to the PLC.
[0060] S10-3, PLC Programming: Configure the PLC in TIAPortal to ensure that the PLC's Ethernet communication module can receive data from the industrial computer. Use the TCP / IP communication library in TIAPortal to write a PLC program to receive and parse the coordinate and area data sent by the industrial computer. Write logic in the PLC to parse the received data and determine whether to trigger alarm conditions based on the detection results, including if the oil stain area exceeds the set threshold.
[0061] S10-4, Alarm system control: When the PLC detects that the oil stain area exceeds a predetermined threshold, an alarm signal is triggered; the PLC controls an external alarm device through a relay or output module.
[0062] The main beneficial effects of this invention are as follows:
[0063] By analyzing changes in the area of oil spots in continuous images, the system determines whether a preset warning threshold has been reached. Once the oil spot area exceeds the threshold, the system triggers a warning signal and executes corresponding emergency measures through the control system, thereby achieving real-time monitoring and early warning of oil spot changes.
[0064] A complete end-to-end system has been established, which can automate the entire detection process; the advantages of YOLOv8 in segmentation tasks make it one of the ideal choices for handling image segmentation problems.
[0065] It not only provides high-precision segmentation results but also features fast inference speed, simple model structure, and wide applicability. Using oil stains on leaked test strips as visual inspection objects is non-invasive. By inspecting the oil stains left on the test strips, disassembly and inspection of the reducer can be avoided, saving time and costs and reducing potential additional damage to the equipment. Furthermore, this method only requires placing the test strips and checking them periodically, without the need for complex tools or techniques.
[0066] The method of using test strips to detect oil leaks and then visually identifying them, as designed in this invention, is a relatively economical approach. The test strips are inexpensive and do not require expensive detection equipment. Furthermore, by regularly checking the test strips, information on whether there is an oil leak can be quickly obtained, allowing for timely intervention. Compared to directly visually inspecting the reducer itself, detecting oil leaks using test strips has advantages such as easier model training and higher detection accuracy. Attached Figure Description
[0067] The present invention will be further described below with reference to the accompanying drawings and embodiments.
[0068] Figure 1 This is a hardware block diagram of the present invention.
[0069] Figure 2 This is a camera layout diagram of the present invention.
[0070] Figure 3 This is a flowchart of the present invention. Detailed Implementation
[0071] like Figures 1-3 A machine vision-based method for detecting oil leaks in speed reducers includes the following steps:
[0072] S1, Hardware Selection: A machine vision system consisting of a light source, lens, camera, image acquisition device, image analysis device, and interactive software is selected.
[0073] S2, Image Acquisition: Two cameras are mounted above the reducer. The cameras do not interfere with other moving mechanisms in the application environment and have a clear and unobstructed field of view. Images are acquired from the front to check whether there is oil dripping or oil spots on the bottom test paper. Images are also acquired from the rear to detect whether there are any abnormal changes in the area of the oil spots.
[0074] S3, grayscale processing, uses color feature-based grayscale processing to improve the quality of the acquired image;
[0075] S4, Image Filtering: Gaussian filtering is used for image preprocessing to remove noise while preserving the image's edges and other important features.
[0076] S5, Image Meansing, employs preprocessing techniques to reduce the mean of image data, making image features have zero mean and unit variance, thereby accelerating the training process and improving the model's convergence speed;
[0077] S6, Image Segmentation, uses YOLOv8 to classify each pixel in the image in order to identify specific object instances;
[0078] S7, Oil spot extraction: After extracting the mask of the oil spot region from the output of YOLOv8, the OpenCV findContours function is used to detect the contour of the oil spot region, and the contourArea function is used to calculate the area of the contour.
[0079] S8, Image Preprocessing, performs a series of preprocessing steps to reduce interference from various influencing factors; including grayscale processing based on color features, image filtering, and image averaging.
[0080] S9, Feature Recognition and Post-processing, uses YOLOv8 for object detection and instance segmentation, providing fast and accurate prediction, identifying the category and location of objects in the image, and generating a segmentation mask for each object, i.e., a pixel-level label; including loading the YOLOv8 model, image detection, extracting the image mask, contour detection, and oil spot area extraction.
[0081] S10, oil leak alarm. Image segmentation is performed using the YOLOv8 model, and then OpenCV is used to obtain the area change information of the image. The detected visual information is transmitted to the industrial control computer, and the alarm is triggered via a Siemens PLC.
[0082] The above method is used for real-time monitoring of oil spot changes on the test paper at the bottom of the reducer. Its purpose is to promptly detect oil spot abnormalities caused by reducer oil leakage and issue early warning signals to prevent potential environmental or safety risks. This invention mainly consists of four parts: first, an oil spot display device, primarily composed of an oil test paper and a base; second, an image acquisition unit, mainly an industrial-grade camera for capturing images of the reducer and the test paper beneath it; third, an image processing unit integrating an image preprocessing module and a YOLOv8 model; and finally, an early warning determination unit, which compares the changes in oil spots in continuously acquired images. When the oil spot area changes beyond a preset threshold, it is determined to be abnormal and an early warning is triggered via an audible and visual alarm device.
[0083] Oil leak detection test strips are laid at the bottom of the reducer. An industrial-grade camera then captures real-time images of the area where the test strips are placed. These images are transmitted to an image processing unit for preprocessing. A YOLOv8 deep learning model is then used to segment the oil spots, followed by post-processing to obtain the location and area information of the oil spots. By observing changes in the oil spot area across consecutive images, a preset warning threshold is determined. If the oil spot area exceeds the threshold, the system triggers a warning signal and implements corresponding emergency measures through the control system, thus achieving real-time monitoring and early warning of oil spot changes.
[0084] Example 1,
[0085] like Figure 1 In computer vision, the visual system mimics the human visual system through optical systems and image processing devices. It acquires and processes signals from captured target images to obtain the necessary information about the target, then classifies and evaluates the detected target, transmitting the final conclusions to the hardware to guide its next steps. Therefore, a complete machine vision system consists of multiple devices, generally categorized as follows: optical (including light sources, lenses and cameras), image acquisition devices, image analysis devices, and interactive software.
[0086] (1) Light source and lighting method
[0087] In the entire machine vision system, the light source is the decisive factor in camera image quality. First, the light source can not only illuminate the target object, but also increase the contrast between the target object and the interference objects, further highlighting the features of the object being measured to achieve the best results; if the object being measured can be clearly separated from the background, the complexity of image algorithms and development can be reduced, and the overall detection speed can be shortened.
[0088] Regarding lighting methods, the most commonly used ones are direct illumination, low-angle oblique illumination, diffuse illumination, back illumination, and illumination based on coaxial light sources. Direct illumination works by detecting the surface of the object being measured through reflected light; it is generally used to detect objects with non-reflective surfaces. Low-angle oblique illumination is generally used to detect objects with uneven surfaces, bumps, or significant texture variations. Diffuse illumination uses a spherical integral light source to illuminate the object's surface at different angles, and is used to detect curved objects. Back illumination separates the object's edges from the background, and is suitable for detecting object contours and transparency.
[0089] Coaxial light sources detect objects by shining uniform, direct light, making them suitable for detecting highly reflective objects.
[0090] This project will conduct tests and studies based on the on-site usage environment, and ultimately select the light source with the best environmental suitability as the light source for this project.
[0091] (2) Camera and lens selection
[0092] Industrial cameras are primarily used to acquire image information. They can be categorized into various types based on their image sensors, with CMOS cameras offering advantages such as high integration, low power consumption, clearer image output, and lower cost. Therefore, CMOS cameras are chosen considering speed, image quality, and cost. Furthermore, the following key factors are mainly considered when selecting parameters for industrial cameras:
[0093] 1) Camera resolution
[0094] Resolution is calculated using the following formula:
[0095] Unidirectional resolution = unidirectional field of view / detection accuracy;
[0096] In the detection scenario of this project, a minimum resolution of 2 to 3 times the width and height is required to ensure that the acquired features are clearly visible and facilitate subsequent detection. Therefore, a 20-megapixel CMOS industrial camera was selected. For the camera's transmission method, a USB 3.0 interface was chosen. The final camera parameters are shown in the table below:
[0097]
[0098] 2) Lens selection
[0099] When selecting a lens, the primary factor to consider is focal length. Assume the field of view for the shot is... The horizontal and vertical directions are respectively and The horizontal and vertical dimensions of the camera chip target surface are respectively and The detection distance is then focal length The calculation formulas are as follows.
[0100]
[0101]
[0102] After comparison, Hikvision's industrial zoom lens was ultimately selected for image acquisition. Its specific parameters are shown in the table below:
[0103]
[0104] 3) Image processing platform
[0105] Based on the requirements of the detection system and the actual situation on site, an industrial computer was selected as the image processing platform. The performance parameters of the industrial computer are shown in the table below.
[0106]
[0107] Example 2,
[0108] like Figure 2 Two cameras are mounted above the reducer. They must not interfere with other moving parts in the application environment and must provide a clear, unobstructed view. The equipment mainly consists of two industrial cameras, an image processing unit, an early warning device, and oil leak detection test strips.
[0109] Camera 1 captures images from the front to check for oil droplets and oil spots on the bottom of the test strip; Camera 2 captures images from the rear to avoid blind spots and detects whether the oil spot area changes abnormally.
[0110] The decision to install artificial light sources, and the type of light source, depends on the site environment.
[0111] The specific working principle and workflow are as follows:
[0112] (1) An industrial camera collects images of the reducer oil seal area at regular intervals or according to trigger signals.
[0113] (2) Use OpenCV to preprocess the acquired images, including grayscale conversion and filtering, to improve image quality.
[0114] (3) Use target detection algorithms such as YOLOv8 to identify oil spot features in the image.
[0115] (4) Compare the changes in the area of oil spots in continuously acquired images to determine whether they exceed a preset threshold.
[0116] (5) When the oil spot area changes beyond the threshold, the system triggers an early warning signal.
[0117] (6) The control system executes emergency measures based on the early warning signal, such as stopping the production line or starting the oil suction equipment.
[0118] The following specifications must be followed for this visual recognition and early warning system for oil leaks:
[0119] (1) Operator training: All operators must undergo professional training to understand the system's operating procedures and safety regulations.
[0120] (2) Regular maintenance: Regularly maintain the system, including cleaning the camera lens, checking the cable connection, and updating the software.
[0121] (3) Emergency stop button: An emergency stop button is set near the system so that the system can be stopped quickly in an emergency.
[0122] (4) Data backup: Back up system data regularly to prevent data loss or damage.
[0123] (5) Access control: Strict access control is implemented for the system, and only authorized personnel can access and modify system settings.
[0124] (6) Security audit: Conduct security audits regularly to check for potential security risks in the system and take corresponding measures to eliminate them.
[0125] (7) Emergency plan: Develop an emergency plan, including emergency evacuation routes, emergency contact list, etc., to ensure a rapid response in the event of an accident.
[0126] (8) Software upgrade: Update the software version regularly to ensure that the system uses the latest security patches and feature improvements.
[0127] (9) Hardware inspection: Regularly check the operating status of hardware equipment, such as industrial cameras, PLCs, etc., to ensure that they are working properly.
[0128] (10) System calibration: Perform system calibration regularly, including camera calibration, sensor calibration, etc., to maintain the accuracy and reliability of the system.
[0129] Example 3,
[0130] Algorithm selection and basic principles;
[0131] (a) Grayscale processing based on color features
[0132] The invention employs color feature-based grayscale processing to improve the quality of acquired images. Color feature-based grayscale processing is an image preprocessing technique primarily used to highlight specific color features in an image. This method is particularly suitable for applications requiring the highlighting of a specific color region, such as the oil stain detection application scenario of this invention.
[0133] The basic idea behind color feature-based grayscale processing is to extract specific color regions through color space transformation and color thresholding, and then convert them into grayscale images. The purpose of this is to highlight specific color features to facilitate subsequent image processing tasks such as segmentation and detection.
[0134] The specific operating steps are as follows:
[0135] (1) Color space conversion: Convert the original image from the RGB color space to another color space, such as HSV hue, saturation, lightness or Lab luminance, a channel, b channel. HSV and Lab color spaces are generally more suitable for processing color-related information.
[0136] (2) Color Feature Extraction: In the converted color space, extract the channels related to specific color features. For example, in the HSV color space, the V lightness channel can be used to process grayscale images, or the H hue and S saturation channels can be used to extract information within a specific color range. In the Lab color space, the L lightness channel can be used for grayscale processing, or the a and b channels can be used to extract specific color information.
[0137] (3) Color thresholding: Set a threshold based on the extracted color features to divide the pixels in the image into foreground and background. For example, for oil spot detection, a threshold can be set based on the color features of the oil spot, such as dark color, to mark the oil spot area.
[0138] (4) Binarization: Binarize the image after color thresholding to obtain a binary image, where the oil spot area is the foreground, usually white, and the rest of the area is the background, usually black.
[0139] (5) Post-processing: Morphological operations such as dilation and erosion can be performed on the binary image to remove noise or refine the contours. Connectivity component analysis can be performed on the binary image, for example, the oil spot region can be extracted in this invention.
[0140] (ii) Gaussian image filtering,
[0141] This invention employs Gaussian filtering for image preprocessing. Gaussian filtering is a linear smoothing filter commonly used in image processing to remove noise while preserving image edges and other important features as much as possible. The Gaussian filter is implemented by convolving the image with a Gaussian kernel. This kernel has the characteristic of being largest at the center and gradually decreasing at the edges, effectively smoothing the image and reducing high-frequency noise. The basic steps of its implementation are as follows:
[0142] (1) Select Gaussian kernel size: Select an appropriate Gaussian kernel size according to the type of noise to be removed. Smaller kernels can remove fine noise, while larger kernels can remove larger noise, but may also lead to more loss of detail.
[0143] (2) Constructing a Gaussian kernel: Construct a two-dimensional Gaussian kernel, which is a discrete approximation of a two-dimensional Gaussian function. The size of the kernel is usually an odd number, such as 3x3, 5x5, etc.
[0144] (3) Normalized Gaussian kernel: In order to ensure that the sum of the filters is 1, the Gaussian kernel needs to be normalized. Calculate the sum of all elements, and then divide each element by this sum.
[0145] (4) Image convolution: A normalized Gaussian kernel is used to perform a convolution operation with the image. For each pixel in the image, the Gaussian kernel is multiplied by the value of that pixel and its surrounding pixels, and the results are summed to obtain a new pixel value. The final result of the convolution is a smooth image with noise removed.
[0146] (iii) Image mean normalization,
[0147] Image mean normalization is a preprocessing technique used to reduce the mean of image data, resulting in image features with zero mean and unit variance. This accelerates the training process and improves the model's convergence speed. Mean normalization is commonly used in the input data preprocessing stage of deep learning models.
[0148] The specific implementation steps are as follows:
[0149] (1) Calculate the mean file: Calculate the average image using all images in the training set, that is, calculate the average pixel value of all training images for each pixel position.
[0150] (2) Subtract the mean: For each input image, subtract the mean value from each pixel position. This can be achieved by pixel-by-pixel subtraction.
[0151] (3) Standardization (optional): In order to further improve the convergence speed of the model, you can choose to standardize the image after subtracting the mean, that is, divide it by the standard deviation or a fixed value, so that the features have unit variance.
[0152] (iv) YOLOv8 image segmentation,
[0153] YOLOv8, or YouOnlyLookOnceversion8, is one of the latest versions of the YOLO object detection algorithm series. It not only supports object detection but also extends functionality to include instance segmentation and semantic segmentation. In YOLOv8, image segmentation refers to classifying each pixel in an image to identify specific object instances. Developed based on YOLOv7, YOLOv8 improves detection accuracy and efficiency through improvements and technological updates. YOLOv8's design focuses on simplifying the architecture and increasing flexibility, making it a very powerful and versatile object detection framework. YOLOv8 supports various tasks, including object detection, instance segmentation, semantic segmentation, and pose estimation. The instance segmentation used in this invention aims to identify and segment each individual object instance in an image. The YOLOv8 instance segmentation model generates a bounding box and a segmentation mask for each detected object to represent its precise contour.
[0154] The specific implementation steps are as follows:
[0155] (1) Input image: The input image is fed into the YOLOv8 network.
[0156] (2) Feature extraction: Multi-scale feature maps of the image are extracted through the backbone network and the neck network.
[0157] (3) Segmentation prediction: Prediction is performed on the feature map. Each prediction unit corresponds to a location in the image. For instance segmentation, each prediction unit outputs a class prediction and a segmentation mask.
[0158] (4) Post-processing: The prediction results are processed by NMS (non-maximum suppression) to remove duplicate detection results, and the final detection results are selected according to the confidence threshold.
[0159] (v) Extraction of oil spot area,
[0160] After extracting the mask of the oil stain region from the output of YOLOv8, the OpenCV findContours function is used to detect the contour of the oil stain region, and the contourArea function is used to calculate the area of the contour.
[0161] The `findContours` function is used to find contours in a binary image. It identifies all contours formed by boundary pixels and returns a list of these contours.
[0162] The `contourArea` function is used to calculate the area of a given contour. This function returns the area of the region enclosed by the contour.
[0163] The specific steps are as follows:
[0164] (1) YOLOv8 instance segmentation output: First, the YOLOv8 model will segment the input image and generate a segmentation mask for each detected oil spot.
[0165] (2) Extract the mask: Extract the segmentation mask for each oil spot from the output of YOLOv8.
[0166] (3) Contour detection: Use OpenCV's findContours function to detect the contours in each oil spot mask.
[0167] (4) Calculate the area: Use the contourArea function to calculate the area of each contour.
[0168] Example 4,
[0169] Image preprocessing:
[0170] In the process of image processing, the extraction of image feature information is greatly affected by image quality. In actual image acquisition, due to a series of factors such as illumination, vibration, and noise, the acquired image data cannot be directly detected and needs to undergo a series of preprocessing steps to minimize the interference of various influencing factors.
[0171] Grayscale processing based on color features:
[0172] Color image data acquired by a camera is typically based on the RGB color space, which expresses color through three components: R: Red, G: Green, and B: Blue. Each component channel is generally composed of 8 bits, with a value range of 0 to 255. In traditional digital image processing, various feature detection algorithms are basically designed based on grayscale images. To improve the accuracy of subsequent feature recognition, it is necessary to select a suitable grayscale transformation method to transform the three-channel color RGB image into a single-channel grayscale image with the same value range. Let the pixel P(…) after grayscale transformation be set… x,y The grayscale value at position ) is Gray( x,y Common grayscale transformation methods are shown below:
[0173] (1) Maximum value grayscale processing method: The component with the largest value in the RGB three channels is taken as the grayscale value of the corresponding pixel after grayscale change. Usually, the grayscale image obtained by the maximum value method has high brightness. The calculation principle is shown in the following formula.
[0174]
[0175] (2) Average grayscale processing method: The average value of the RGB three-channel components is used as the grayscale value of the corresponding pixel after grayscale transformation. The calculation principle is shown in the formula.
[0176]
[0177] (3) Weighted average grayscale processing method: This method is equivalent to a generalization of the average grayscale processing method. The RGB three-channel component values are assigned appropriate weights (the sum of each weight is 1) and then the grayscale value of the corresponding pixel is calculated. The calculation principle is as follows.
[0178]
[0179] Image filtering:
[0180] Image filtering removes invalid information from input data. For image data, the filtering process typically refers to image smoothing, which smooths the grayscale changes between pixels and preserves as much of the original information in the image data as possible. Image smoothing is often implemented in the spatial or frequency domains, and its most obvious manifestation is that the image becomes blurred. During image data acquisition and transmission, due to the influence of various factors such as the image acquisition system hardware, working environment, and data transmission medium, noise of various shapes and sizes will randomly appear in the image. From the frequency domain analysis of image data, noise usually manifests as high-frequency components. Therefore, low-pass filters are often used in image filtering to minimize the impact of noise on feature extraction.
[0181] Compared with spatial domain filtering, frequency domain filtering has an absolute advantage in processing speed. To ensure real-time image processing, Gaussian filtering algorithm is used for image preprocessing in this project.
[0182] Gaussian filtering can effectively reduce the impact of Gaussian noise on feature extraction. During image smoothing, it utilizes the convolution operation between a Gaussian kernel and the image to remove image noise. The Gaussian kernel is calculated based on the Gaussian distribution function. The Gaussian distribution functions in one-dimensional and two-dimensional spaces are shown in the following two equations.
[0183]
[0184] Image mean normalization:
[0185] Image averaging is a common image preprocessing technique used to reduce the mean of image data, resulting in image features with zero mean and unit variance. This accelerates the training process and improves model convergence speed. The main purpose of image averaging is to adjust image data by subtracting a mean vector, ensuring the input data has zero mean. This step is typically performed during the input data preprocessing stage of deep learning models. By averaging, redundancy in the training data is reduced, making the model more likely to converge.
[0186] The core calculation process is as follows:
[0187] (1) Calculate the mean vector:
[0188] Define a two-dimensional array M to represent the pixel value matrix of all images in the training set, where M is a four-dimensional tensor with dimensions N, H, W, and C, where N is the number of images, H is the height of the image, W is the width of the image, and C is the number of channels of the image (C=1 for grayscale images; C=3 for RGB images). Then calculate the mean vector μ.
[0189] (2) Subtract the mean: For a new input image I, convert it into a three-dimensional array, and for each pixel position (i,j,c), subtract the corresponding mean.
[0190] To further improve the convergence speed of the model, you can choose to standardize the image after subtracting the mean, that is, divide it by the standard deviation or a fixed value, so that the features have unit variance.
[0191] Example 5,
[0192] Feature recognition, segmentation, and area extraction post-processing:
[0193] (1) Load the YOLOv8 model,
[0194] YOLOv8 (You Only Look Once Version 8) is an advanced object detection and instance segmentation model designed to provide fast and accurate predictions. YOLOv8 can not only identify the category and location of objects in an image, but also generate a segmentation mask for each object—a pixel-level label—which is crucial for subsequent analysis.
[0195] The specific steps are as follows:
[0196] 1) Install the Ultralytics library:
[0197] First, ensure that the ultralytics library is installed, which is the main implementation library for YOLOv8. This can be done by running `pip install ultralytics`.
[0198] 2) Pre-trained model:
[0199] We took photos of the leaked oil stains on-site, labeled them using labelling, and then input them into the YOLO model for pre-training.
[0200] 3) Load the model:
[0201] Load this pre-trained model file using the YOLO class.
[0202] (2) Image detection,
[0203] YOLOv8 can directly accept raw images and output detection results. To improve detection accuracy, image preprocessing is usually performed, such as resizing the image to fit the model's input size requirements. The specific steps are as follows:
[0204] 1) Loading images: Read the image file to be detected, for example, using OpenCV's imread function.
[0205] 2) Image preprocessing: Scaling, cropping, and other operations may be required to fit the model's requirements. YOLOv8 typically requires fixed-size input images, so image resizing may be necessary.
[0206] 3) Input image: Input the preprocessed image into the YOLOv8 model.
[0207] 4) Obtain detection results: YOLOv8 will return a list of results, which includes the location, category and segmentation mask information of each detected object.
[0208] (3) Extract the image mask.
[0209] The output of YOLOv8 includes segmentation mask information for each detected object. A segmentation mask is a pixel-level label representing the object's outline, typically composed of a set of polygon vertices. Extracting the mask is a necessary step for subsequent oil spot area acquisition, and its specific implementation steps are as follows:
[0210] 1) Accessing mask data: The result of YOLOv8 includes a mask attribute, which provides information about the segmentation mask.
[0211] 2) Extracting the mask: For each detected target, you can use masks.data to get the mask data, which is a two-dimensional array representing the pixel values of the mask.
[0212] 3) Visualized mask: The mask data can be visualized on the original image to better understand the detection results.
[0213] (4) Contour detection,
[0214] First, contour detection is performed. Based on the segmentation mask, OpenCV's `findContours` function can be used to detect contours within each mask. Contour detection helps us better understand the specific shape and distribution of oil spots. A contour is a series of continuous boundary points that form a closed shape. For a segmentation mask, the contour refers to the boundary line of the oil spot.
[0215] The implementation steps are as follows:
[0216] 1) Convert the mask to a binary image: If the segmentation mask is not given in the form of a binary image, then it needs to be converted into a black and white binary image first.
[0217] 2) Finding contours: Use the findContours function to find the boundaries formed by all non-zero pixels in an image.
[0218] 3) Contour sorting: If there are multiple contours, they can be sorted according to area size or other criteria in order to select the largest contour as the primary target.
[0219] 4) Contour drawing: The detected contours can be drawn on the original image to visually display the segmentation results.
[0220] (5) Extraction of oil spot area,
[0221] Following the contour detection step, the next step is to calculate the area of each contour. This can be done using the `contourArea` function. Area calculation is performed by counting the pixels within the contour. For irregular shapes, OpenCV uses the polygon area formula.
[0222] The steps for calculating the area are as follows:
[0223] 1) Calculate the area of a single contour: For each contour, use the contourArea function to calculate the area.
[0224] Calculate the area of all contours: If there are multiple contours, calculate their areas separately and summarize the results as needed.
[0225] Example 6,
[0226] Oil leak alarm:
[0227] In terms of program control, this invention utilizes the YOLOv8 model for image segmentation and then obtains the area change information of the image through OpenCV. The detected visual information is transmitted to an industrial control computer and controlled by a Siemens PLC to trigger an alarm. The specific technical solution is as follows: Figure 3 As shown:
[0228] (1) Environmental preparation,
[0229] Hardware preparation:
[0230] Camera: Used to capture real-time images; high-resolution industrial cameras are recommended for clear images.
[0231] Industrial control computers, or industrial PCs, run image processing and target detection algorithms, such as YOLOv8, and are responsible for communication with PLCs.
[0232] Siemens PLCs, such as the S7-1200 or S7-1500 series, are used to receive detection results and control the alarm system.
[0233] Communication interface: Used for data transmission between PLC and industrial computer, such as Ethernet interface.
[0234] Software preparation:
[0235] OpenCV library: used for image acquisition and preprocessing.
[0236] YOLOv8 image segmentation model: used to detect and segment oil stain regions.
[0237] Siemens TIAPortal: Used for PLC programming and configuration.
[0238] Communication protocols, such as ModbusTCP or Profinet, are used for data exchange between industrial PCs and PLCs.
[0239] (2) Image acquisition and processing,
[0240] First, OpenCV is used to acquire real-time images from a camera, and image processing and object detection are performed. Image preprocessing, such as grayscale conversion, filtering, and contrast enhancement, is applied to improve detection accuracy. Finally, the YOLOv8 image segmentation model is applied to analyze the image, identifying and segmenting the oil stain regions.
[0241] (3) Data transmission,
[0242] A TCP / IP connection is established using Python's socket library to send the detection results (such as the location coordinates and area of oil spots) from the industrial control computer to the PLC. ModbusTCP or Profinet protocols can be used to ensure the stability and reliability of data transmission.
[0243] (4) PLC programming,
[0244] Configure the PLC in TIAPortal, ensuring its Ethernet communication module can receive data from the industrial computer. Use the TCP / IP communication library in TIAPortal to write a PLC program that receives and parses the coordinate and area data sent by the industrial computer. Write logic in the PLC to parse the received data and determine whether to trigger an alarm condition based on the detection results, such as if the oil stain area exceeds a set threshold.
[0245] (5) Alarm system control,
[0246] When the PLC detects that the oil stain area exceeds a predetermined threshold, it triggers an alarm signal. The PLC can control external alarms, such as audible and visual alarms, via relays or other output modules. If the system has a recording function, it can also record the time of the alarm event and other relevant information.
[0247] The above method establishes a complete end-to-end system, enabling automation of the entire detection process. The advantages of YOLOv8 in segmentation tasks make it an ideal choice for handling image segmentation problems. It not only provides high-precision segmentation results but also features fast inference speed, a simple model structure, and wide applicability. Using oil stains on leaked test strips as visual inspection objects is non-invasive. By inspecting the oil stains left on the test strip, disassembly and inspection of the reducer can be avoided, saving time and costs and reducing potential additional damage to the equipment. Furthermore, this method only requires simple placement of the test strip and periodic checks, without the need for complex tools or techniques.
[0248] The method of using test strips to detect oil leaks and then visually identifying them, as designed in this invention, is a relatively economical approach. The test strips are inexpensive and do not require expensive detection equipment. Furthermore, by regularly checking the test strips, information on whether there is an oil leak can be quickly obtained, allowing for timely intervention. Compared to directly visually inspecting the reducer itself, detecting oil leaks using test strips has advantages such as easier model training and higher detection accuracy.
[0249] The above embodiments are merely preferred technical solutions of the present invention and should not be considered as limitations on the present invention. The embodiments and features described in these embodiments can be arbitrarily combined without conflict. The scope of protection of the present invention should be limited to the technical solutions described in the claims, including equivalent substitutions of the technical features described in the claims. That is, equivalent substitutions and improvements within this scope are also within the scope of protection of the present invention.
Claims
1. A machine vision-based method of detecting oil leaks in a speed reducer, characterized by, Includes the following steps: S1, Hardware Selection: A machine vision system consisting of a light source, lens, camera, image acquisition device, image analysis device, and interactive software is selected. S2, Image Acquisition: Two cameras are mounted above the reducer. The cameras do not interfere with other moving mechanisms in the application environment, and the field of view is clear and unobstructed. The test strip is captured from the front to check for oil droplets and oil spots, while images are captured from the rear to detect whether there are any abnormal changes in the area of the oil spots. S3, grayscale processing, uses color feature-based grayscale processing to improve the quality of the acquired image; S4, Image Filtering: Gaussian filtering is used for image preprocessing to remove noise while preserving the image's edges and other important features. S5, Image Meansing, employs preprocessing techniques to reduce the mean of image data, making image features have zero mean and unit variance, thereby accelerating the training process and improving the model's convergence speed; S6, Image Segmentation, uses YOLOv8 to classify each pixel in the image in order to identify specific object instances; S7, Oil spot extraction: After extracting the mask of the oil spot region from the output of YOLOv8, the OpenCV findContours function is used to detect the contour of the oil spot region, and the contourArea function is used to calculate the area of the contour. S8, image preprocessing, performs a series of preprocessing steps to reduce interference from various influencing factors; This includes grayscale processing based on color features, image filtering, and image averaging; S9, Feature Recognition and Post-processing, uses the YOLOv8 object detection and instance segmentation model to provide fast and accurate prediction, identify the object category and location in the image, and generate a segmentation mask for each object, i.e., a pixel-level label; the label includes loading the YOLOv8 model, image detection, extracting the image mask, contour detection, and oil spot area extraction. S10, oil leak alarm. The image is segmented using the YOLOv8 model, and then the area change information of the image is obtained through OpenCV. The detected visual information is transmitted to the industrial control computer and the alarm is triggered by the Siemens PLC.
2. The machine vision-based method for detecting oil leakage in a reducer according to claim 1, characterized in that: in In S1, the lens selection factor is focal length, assuming the field of view is... The horizontal and vertical directions are respectively and The horizontal and vertical dimensions of the camera chip target surface are respectively and The detection distance is then focal length The calculation formula is: ; 。 3. The machine vision-based method for detecting oil leakage in a reducer according to claim 1, characterized in that: In S3, grayscale processing includes the following steps: S3-1, Color Space Conversion, converts the original image from the RGB color space to another color space, which includes HSV hue, saturation, and lightness or Lab brightness, as well as the a channel or b channel; S3-2, Color Feature Extraction: Extracting channels related to specific color features from the transformed color space; S3-3, Color thresholding: Based on the extracted color features, a threshold is set to divide the pixels in the image into foreground and background. S3-4, Binarization processing: The image after color thresholding is binarized to obtain a binary image, in which the oil spot area is the foreground and the rest of the area is the background; S3-5, Post-processing: Perform morphological operations on the binary image to remove noise or refine contours; perform connected component analysis on the binary image to extract oil spot regions.
4. The machine vision-based method for detecting oil leakage in a reducer according to claim 1, characterized in that: in In S4, image filtering includes the following steps: S4-1, Select Gaussian kernel size. Choose an appropriate Gaussian kernel size based on the type of noise you need to remove. S4-2, Construct a Gaussian kernel. Construct a two-dimensional Gaussian kernel, which is a discrete approximation of a two-dimensional Gaussian function; S4-3, Normalized Gaussian kernel: To ensure that the sum of the filters is 1, the Gaussian kernel is normalized; calculate the sum of all elements, and then divide each element by this sum; S4-4, Image Convolution: A normalized Gaussian kernel is used to perform a convolution operation with the image. For each pixel in the image, the Gaussian kernel is multiplied by the value of that pixel and its surrounding pixels, and the sum is obtained to get a new pixel value.
5. The machine vision-based method for detecting oil leakage in a reducer according to claim 1, characterized in that: In S5, image averaging includes the following steps: S5-1, Calculate the mean file, use all images in the training set to calculate the average image, that is, calculate the average pixel value of all training images for each pixel position; S5-2, Subtract the mean: For each input image, subtract the corresponding mean value from each pixel position; S5-3, Standardization: To further improve the convergence speed of the model, we choose to standardize the image after subtracting the mean, that is, divide it by the standard deviation or a fixed value, so that the features have unit variance.
6. The machine vision-based method for detecting oil leakage in a reducer according to claim 1, characterized in that: in In S6, image segmentation includes the following steps: S6-1, Input image, feed the input image into the YOLOv8 network; S6-2, Feature Extraction: Multi-scale feature maps of the image are extracted through the backbone network and the neck network. S6-3, Segmentation prediction, performs prediction on the feature map. Each prediction unit corresponds to a location in the image. For instance segmentation, each prediction unit outputs a class prediction and a segmentation mask. S6-4, Post-processing: Perform NMS (Non-maximum Suppression) on the prediction results to remove duplicate detection results, and filter out the final detection results based on the confidence threshold.
7. The machine vision-based method for detecting oil leakage in a reducer according to claim 1, characterized in that: in In S7, the contourArea function is used to calculate the area of a given contour. This function returns the area of the region enclosed by the contour, and specifically includes the following steps: S7-1, YOLOv8 instance segmentation output: First, the YOLOv8 model segments the input image and generates a segmentation mask for each detected oil spot. S7-2, Extract Mask: Extract the segmentation mask for each oil spot from the output of YOLOv8; S7-3, Contour Detection: Use OpenCV's findContours function to detect contours in each oil spot mask; S7-4, Calculate the area using the contourArea function to calculate the area of each contour.
8. The machine vision-based method for detecting oil leakage in a reducer according to claim 1, characterized in that: in In S8, image mean normalization adjusts the image data by subtracting a mean vector, making the input data have zero mean. This is performed during the input data preprocessing stage of the deep learning model. By reducing redundancy in the training data, mean normalization makes the model more likely to converge. Its core calculation process includes the following steps: S8-1, calculate the mean vector. Define a two-dimensional array M to represent the pixel value matrix of all images in the training set. M is a four-dimensional tensor with dimensions N, H, W, and C, where N is the number of images, H is the height of the image, W is the width of the image, and C is the number of channels of the image. For grayscale images, C=1; for RGB images, C=3. Then calculate the mean vector μ. S8-2, Subtract the mean: For a new input image I, convert it into a three-dimensional array, and for each pixel position (i,j,c), subtract the corresponding mean. S8-3, to further improve the convergence speed of the model, we choose to standardize the image after subtracting the mean, that is, divide it by the standard deviation or a fixed value, so that the features have unit variance.
9. The machine vision-based method for detecting oil leakage in a reducer according to claim 1, characterized in that: In S9, contour detection, based on segmentation masks, uses OpenCV's findContours function to detect contours within each mask. Contour detection helps understand the specific shape and distribution of oil spots. A contour is a series of continuous boundary points that form a closed shape. For segmentation masks, the contour refers to the boundary line of the oil spot. The specific steps include: S9-1, Convert the mask to a binary image. If the segmentation mask is not given in the form of a binary image, first convert it to a black and white binary image. S9-2, Find Contours: Use the findContours function to find the boundary formed by all non-zero pixels in the image; S9-3, Contour sorting: If there are multiple contours, sort them according to area size or other criteria so that the largest contour can be selected as the primary target. S9-4, Contour Drawing: The detected contours are drawn on the original image to visually display the segmentation results.
10. The machine vision-based method for detecting oil leakage in a reducer according to claim 1, characterized in that: in In S10, the oil leak alarm specifically includes the following steps: S10-1, Image Acquisition and Processing: First, OpenCV is used to acquire real-time images from the camera, and image processing and target detection are performed. The images are preprocessed, including grayscale conversion, filtering, or contrast enhancement to improve detection accuracy. Finally, the YOLOv8 image segmentation model is applied to analyze the images, identify and segment the oil stain regions. S10-2, Data transmission: A TCP / IP connection is established through Python's socket library to send the detection results, including the location coordinates and area of oil spots, from the industrial computer to the PLC. S10-3, PLC Programming: Configure the PLC in TIAPortal to ensure that the PLC's Ethernet communication module can receive data from the industrial computer. Use the TCP / IP communication library in TIAPortal to write a PLC program to receive and parse the coordinate and area data sent by the industrial computer. Write logic in the PLC to parse the received data and determine whether to trigger alarm conditions based on the detection results, including if the oil stain area exceeds the set threshold. S10-4, Alarm system control: When the PLC detects that the oil stain area exceeds a predetermined threshold, an alarm signal is triggered; the PLC controls an external alarm device through a relay or output module.
Citation Information
Patent Citations
Pedestrian matching method and device, electronic equipment and storage medium
CN116434271A
Transformer main transformer oil leakage analysis and abnormal oil leakage image early warning device
CN214151955U