An automatic adjustment method and system for machine vision detection parameters
By automatically adjusting the emission time of the detection camera's light source using a smart camera and a preset grayscale relationship formula, the problem of inconsistent image grayscale in machine vision inspection is solved, achieving efficient and consistent detection results.
Patent Information
- Application Number
- CN202511269615.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-08
- Publication Date
- 2025-11-25
- Estimated Expiration
- 2045-09-08
AI Technical Summary
In machine vision inspection, the same type of object may have different surface properties due to differences in production processes, resulting in inconsistent image grayscale, which affects the detection accuracy. Existing technologies require manual adjustment of equipment parameters or the use of multiple devices, which is cumbersome and wasteful of resources.
By analyzing the grayscale values of objects using a smart camera and combining them with a preset grayscale relationship formula, the system automatically adjusts the emission time of the light source accompanying the detection camera to ensure that the image grayscale reaches the target range, thus achieving automatic parameter adjustment.
It achieves automatic adjustment based on the surface roughness and reflectivity of the object, ensuring that the image grayscale is within a controllable range, and realizing unified and efficient detection.
Smart Images

Figure CN120761297B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of machine vision, in particular to an automatic adjustment method and system for machine vision detection parameters. BACKGROUND
[0002] In the field of machine vision surface detection, the same type of object often has obvious differences in surface properties due to differences in production links. Specifically, different production processes or batches can cause significant differences in the gray level and smoothness of the product surface. For example, in tire detection, the reflectivity of the tire surface will differ if different materials are used; and the reflectivity of a permanent magnet will also differ after different surface treatment processes.
[0003] Such differences in surface properties can directly affect the detection link, specifically, when using the same equipment to collect images of these objects, the resulting image gray levels are often inconsistent. This problem can further interfere with subsequent image processing, resulting in a significant reduction in processing accuracy.
[0004] To solve this problem, the common approach is to adjust the equipment parameters to adapt to objects with different properties, but this process is tedious and requires a high level of expertise from the operator; another way is to provide different detection equipment for objects with different properties, which undoubtedly causes a huge waste of resources. SUMMARY
[0005] To solve the above technical problems in the related art, the present application provides an automatic adjustment method and system for machine vision detection parameters, which can solve the above problems, and the specific principle is that the image shooting gray level of the same sample mainly depends on the camera aperture size, camera exposure time and light source brightness. In a fixed environment, the camera exposure time covers the light source emission time, and adjusting the light source emission time within the camera exposure time range can change the light source luminosity, thereby changing the shooting gray level of the sample.
[0006] To achieve the above technical purposes, the technical solution of the present application is as follows:
[0007] An automatic adjustment method for machine vision detection parameters, comprising the following steps:
[0008] S100, using an intelligent camera to collect images of the measured object and analyzing and calculating the gray value of the measured object;
[0009] S200, calculating the expected gray value of the measured object under the detection camera according to the gray value collected by the intelligent camera and combining the preset gray relationship formula between the intelligent camera and the detection camera;
[0010] S300, adjusting the light-emitting time of the light source matched with the detection camera according to the comparison result of the expected gray value and the target gray value, so that the image gray value collected by the detection camera under the detection camera reaches the target gray value range;
[0011] S400, the light source controller controls the detection camera and its matched light source to collect images according to the adjusted light-emitting time parameter.
[0012] Further, in S100, if the gray value of the current measured object is within the target gray value range, no adjustment is performed, and if it is out of the target gray value range, S200-S400 are executed.
[0013] Further, the target gray value range is the ideal gray value range that the measured object image should reach, which is set by the upper computer in advance.
[0014] Further, the gray relationship formula between the intelligent camera and the detection camera in S200 is obtained by the following steps:
[0015] S210, select a plurality of measured samples with equal interval difference from dark to light;
[0016] S220, under the fixed light-emitting time, use the intelligent camera and the detection camera to collect images of the measured samples respectively, and calculate the average gray values respectively;
[0017] S230, according to the collected gray value data, the gray relationship formula between the intelligent camera and the detection camera is fitted.
[0018] Further, the relationship between the light-emitting time of the light source matched with the detection camera and the shooting gray in S300 is determined by the following steps:
[0019] S310, under the condition that the shooting environment is fixed, use the same sample, set equal interval light source light-emitting time, and use the detection camera to collect sample gray, to obtain a set of gray values;
[0020] S320, according to the collected gray value data, the linear relationship formula between the light-emitting time and the shooting gray is fitted.
[0021] Further, a reference light-emitting time is set, the reference light-emitting time and the reference gray value of the image collected by the detection camera under the reference light-emitting time are recorded, the change multiple of the shooting gray of the detection camera under different light-emitting time and the reference gray value is recorded as the reference value change multiple, and the reference value change multiple and the light-emitting time are in linear relationship.
[0022] An automatic adjustment system for machine vision detection parameters. It comprises:
[0023] The intelligent camera is used for image acquisition of a measured object, and analyzes and calculates a gray value of the measured object, and calculates an expected gray value of the measured object under a detection camera according to a preset gray relationship formula;
[0024] The detection controller is connected with the intelligent camera, receives the gray value detection result, judges whether the current measured object needs to be adjusted in sending time and in which channel, and calculates corresponding adjustment parameters, and when the measured object reaches a working position of the corresponding channel, the adjustment parameters are sent to the light source controller.
[0025] The light source controller is connected with the detection controller, one light source controller controls one or more light sources and detection cameras, and after the light source controller receives the adjustment parameters sent by the detection controller, the light source controller adjusts the light emitting time of the light source correspondingly.
[0026] A plurality of detection cameras and a plurality of light sources are connected with the light source controller, and are used for image acquisition according to the control parameters of the light source controller.
[0027] Further, an upper computer connected with the intelligent camera, the detection camera and the detection controller is further included, the upper computer is used for setting working parameters of the detection controller and initial parameters of the intelligent camera, and the upper computer is further used for presetting the target gray value, and adjusting the light emitting time of the light source matched with the detection camera according to a comparison result of the expected gray value and the target gray value.
[0028] Further, all light emitting time parameters are bound to the measured object in a queue mode to form a queue and are sent to the light source controller, the light source controller is responsible for receiving the sent light emitting time parameters, and the light source controller modifies the specified light source brightness according to the light emitting time parameters, and the light source controller determines the photographing positions of the plurality of detection cameras through signal counting, and triggers the working position camera and the matched light source to perform photographing in sequence according to the counting.
[0029] Further, a motor and a photoelectric sensor electrically connected with the detection controller are further included, an output end of the motor is connected with a turntable, the motor is used for driving the turntable to convey the measured object to a to-be-acquired position, and the photoelectric sensor is used for sensing the measured object and sending a trigger signal to the detection controller, so that the camera acquires the image of the measured object.
[0030] The present application has the advantages that the present application can automatically adjust detection parameters according to different surface roughness and reflectivity of the same kind of object, so that the image gray value output by the whole device is fixed in a controllable range, and unified, efficient and real-time detection is realized. BRIEF DESCRIPTION OF DRAWINGS
[0031] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings needed in the embodiments. Obviously, the drawings described below only illustrate some of the embodiments of the present application, and other drawings can be obtained by those of ordinary skill in the art without any creative effort based on these drawings.
[0032] The present application will be further described in detail below according to the drawings.
[0033] Fig. 1 is a flow chart of an automatic adjustment method for machine vision detection parameters according to an embodiment of the present application;
[0034] Fig. 2 is a system architecture diagram of an automatic adjustment system for machine vision detection parameters according to an embodiment of the present application;
[0035] Fig. 3 is a different light source gray value and light emitting time proportional relationship diagram according to an embodiment of the present application. DETAILED DESCRIPTION
[0036] The technical solutions in the embodiments of the present application will be described clearly and completely below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments only represent some of the embodiments of the present application, rather than all the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments in the present application belong to the scope of protection of the present application.
[0037] As Figs. 1-3As shown, the application discloses an automatic adjustment method for machine vision detection parameters, which comprises the following steps: an intelligent camera is used to collect images of a measured object, and the gray value of the measured object is calculated and analyzed, if the gray value of the current measured object is within a target gray value range, no adjustment is performed, if the gray value exceeds the target gray value range, the following adjustment operation is performed; according to the gray value collected by the intelligent camera, in combination with a preset gray relationship formula of the intelligent camera and a detection camera, the expected gray value of the measured object under the detection camera is calculated; according to the comparison result of the expected gray value and the target gray value, the light-emitting time of the light source matched with the detection camera is adjusted, so that the image gray value collected by the detection camera under the measured object reaches the target gray value range; the light source controller controls the detection camera and the matched light source to collect images according to the adjusted light-emitting time parameter. The application further discloses an automatic adjustment system for machine vision detection parameters, which comprises: an intelligent camera, which is used to collect images of a measured object, and the gray value of the measured object is calculated and analyzed; a detection controller, which is connected with the intelligent camera, is used to receive the gray value collected by the intelligent camera, and calculate the expected gray value of the measured object under the detection camera according to a preset gray relationship formula; a light source controller, which is connected with the detection controller, is used to control the detection camera and the matched light source to collect images according to the adjustment parameter calculated by the detection controller; a plurality of detection cameras and a plurality of light sources, which are connected with the light source controller, are used to collect images according to the control parameter of the light source controller.
[0038] In a specific embodiment of the application, the system needs to determine the linear parameters of the intelligent camera for analysis and calculation, mainly including the exposure linearity of the intelligent camera and the photosensitive linearity of the intelligent camera. The gray relationship of the intelligent camera and the detection camera collecting images of the same object is determined. The proportional relationship between the light-emitting time of the light source and the image gray value collected by the detection camera is determined.
[0039] (1) Intelligent camera linear parameter test
[0040] The exposure linearity of the intelligent camera is selected, a standard light source is selected, the light-emitting time of the light source is adjusted to be much greater than the exposure time of the camera, the image gray mean value is controlled to be about 150 (the gray value range of the image is 0-255, and about 1 / 2-2 / 3 of the gray range of the camera is selected) by adjusting the aperture. After the whole system parameters are fixed, the exposure time of the camera is adjusted at equal intervals, images are collected respectively, and the image gray value changes linearly, so that the exposure linearity of the intelligent camera is good.
[0041] The photosensitive linearity of the intelligent camera is selected, a standard light source is selected, a lower light-emitting value T1 is set, an image is collected by the intelligent camera, the gray mean value G1 of the image is calculated, a higher light-emitting value T2 is set, T2=2T1, another image is collected by the intelligent camera, and the gray mean value G2 of the image is calculated. After multiple tests, if all satisfy , then the photosensitive linearity of the intelligent camera is good.
[0042] (2) Fixed light-emitting time, the relationship between the gray scale of the intelligent camera and the detection camera
[0043] Find several samples with roughly equal intervals from dark to light, set the fixed light-emitting time as the reference time, generally recommended 200ms. Collect the image under the intelligent camera and calculate the average gray scale Y n , collect the image under the detection camera and calculate the average gray scale X n , and fit the curve according to the actual experimental data, the relationship between the gray scale of the intelligent camera and the detection camera is linear when the light-emitting time is fixed, and the formula ① is as follows: Y n =kX n +b, wherein k and b are parameters.
[0044] In this way, for any sample, set the same light-emitting time, collect the image under the intelligent camera and calculate the gray scale value, and then the gray scale value of the image collected under the detection camera can be calculated.
[0045] (3) Relationship between light-emitting time of detection camera supporting light source and shooting gray scale
[0046] Under the condition that the shooting environment is fixed, use the same sample, set the light-emitting time X 1n of the light source at equal intervals, and collect the sample gray scale by the detection camera to obtain a group of gray scale values Y 1n , under the premise that the photosensitive linearity of the detection camera and the light-emitting linearity of the supporting light source are linear, the approximate fitting curve 1 is obtained, which is also linear, Y 1n =k1X 1n +b1.
[0047] Without changing other environments, only change the type of light source (such as selecting ring light, strip light, and surface light), the image gray scale is different for different light source types, set the light-emitting time X 2n at equal intervals, obtain a group of gray scale values Y 2n , Y 2n =k2X 2n +b2, and the parameters k2 and b2 of the fitting curve 2 are obtained.
[0048] Without changing other environments, change the camera aperture, set the light-emitting time X 3n at equal intervals, obtain a group of gray scale values Y 3n , Y 3n =k3X 3n +b3, and the parameters k3 and b3 of the fitting curve 3 are obtained, and a group of parameters k 3n and b 3n.
[0049] Tests have shown that the relationship between grayscale and emission time is unstable and affected by the environment. However, if a baseline emission time T is set... b (=100ms) Detect the grayscale mean G of the image from the camera. b (=57.91), regardless of changes in the light source type or lens aperture, the grayscale value g and the reference grayscale value G will remain the same. b The ratio of to has a linear proportional relationship with the emission time. Fig. 3 For example, the coefficient k = 0.0052 can be calculated. From this, the difference between the captured grayscale value and the reference grayscale value G under different illumination times of the detection camera can be obtained. b The change factor is: the change factor of the benchmark value. Light emission time.
[0050] (4) Parameter calculation process
[0051] The emission time of the intelligent camera and the detection camera is set to a baseline value (100ms recommended). The average gray level (g) is calculated by capturing images of the standard sample under both the intelligent camera and the detection camera. 智能b g 检测b Set the target grayscale value g of the object being detected under the detection camera. Aim .
[0052] Setting the emission time as the baseline value, the average grayscale value of the detected object, captured by the smart camera, is calculated and recorded as G. 智能, The average gray level (G) is calculated by capturing images under the detection camera. 检测 The following results can be calculated using formula ①, for the sample: Items being tested: .
[0053] The grayscale change ratio between the tested item and the standard sample under the testing camera is E:
[0054] ;
[0055] Therefore, the grayscale value of the inspected item at the reference emission time of the detection camera can be calculated as follows:
[0056] ;
[0057] Based on the relationship between the emission time of the camera's matching light source and the captured grayscale in (3), it can be deduced that:
[0058] Achieving the target grayscale change ratio: .
[0059] Target emission time: .
[0060] (5) Work process
[0061] In practical applications, the host computer sets the target gray value of all industrial cameras for shooting the measured object, that is, the use gray value when the shooting effect is best.
[0062] The intelligent camera is located before the workstation camera, and the measured object passes through the intelligent camera. The intelligent camera collects the image of the measured object and analyzes the sample gray value. The gray value of the measured object shot by the intelligent camera is brought into the formula to calculate the light-emitting time parameters required for all workstations to reach the target gray value. All light-emitting time parameters are bound together in a queue with the sample to form a queue and are sent to the light source controller.
[0063] The light source controller is responsible for receiving the sent light-emitting time parameters, modifying the specified light source brightness according to the parameters, determining the shooting positions of multiple industrial cameras through signal counting, and triggering the workstation camera and its matched light source in turn according to the counting to shoot.
[0064] In a specific embodiment of the present application, as shown in Fig. 2 The adjustment system of the present application includes an intelligent camera, a detection controller, multiple light source controllers, multiple detection cameras, and multiple light sources. One detection camera can work with multiple light sources, and each light source can realize independent parameter setting to meet the free combination of light sources and detection cameras.
[0065] The host computer sets the working parameters of the detection controller, such as the working of several light sources, the light-emitting time of each light source, and the light-emitting delay. The host computer sets the initial parameters of the intelligent camera, such as the target gray value range. When starting to work, the detection controller sends a start working signal to the motor, and the motor drives the rotating disc to rotate. When the measured object arrives, the rotating disc drives the measured object to pass through the photoelectric sensor, and the photoelectric sensor sends a signal to the detection controller. The detection controller triggers the intelligent camera to collect the image and performs real-time image processing. It is detected whether the gray value of the measured object in the current shooting is within the target gray value range. If it is within the target gray value range, the system does not process it. If it is beyond the target gray value range, the adjustment parameters of the subsequent controller are calculated, and the result parameters are set to the detection controller. The rotating disc turns the measured object to the detection camera of different workstations. The detection controller drives each light source controller to work according to the new detection parameters to collect the image. At this time, the image collected by each detection camera meets the image processing condition. After the detection image is uploaded to the host computer for image processing, the subsequent process is performed. If there is a defect in the detection, the control is kicked to the waste workstation for processing, and the entire detection process can be completed.
[0066] The above only describes the preferred embodiments of the present application and is not intended to limit the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principles of the present application shall be included in the protection scope of the present application.
Claims
1. A method for automatic adjustment of machine vision detection parameters, characterized in that, The method comprises the following steps: S100, using an intelligent camera to collect images of the measured object and analyzing and calculating the gray value of the measured object; S200, calculating the expected gray value of the measured object under the detection camera according to the gray value collected by the intelligent camera and combining a preset gray relationship formula of the intelligent camera and the detection camera; The gray relationship formula of the intelligent camera and the detection camera in S200 is obtained by the following steps: S210, selecting a plurality of measured samples with equal intervals from dark to light; S220, using the intelligent camera and the detection camera to collect images of the measured samples under a fixed light-emitting time and calculating the average gray value of each; S230, fitting the gray relationship formula of the intelligent camera and the detection camera according to the collected gray value data; S300, adjusting the light-emitting time of the light source matched with the detection camera according to the comparison result of the expected gray value and the target gray value, so that the gray value of the image collected by the detection camera reaches the target gray value range; The light-emitting time and the shooting gray relationship of the light source matched with the detection camera in S300 are determined by the following steps: S310, using the same sample, setting equal interval light-emitting time, and collecting sample gray value by the detection camera under the condition that the shooting environment is fixed; S320, fitting the linear relationship formula of the light-emitting time and the shooting gray according to the collected gray value data; A reference light-emitting time is set, the reference light-emitting time and the reference gray value of the image collected by the detection camera under the reference light-emitting time are recorded, the change multiple of the shooting gray of the detection camera under different light-emitting time and the reference gray value is recorded as the reference value change multiple, and the reference value change multiple and the light-emitting time are in linear relationship; S400, the light source controller controls the detection camera and the matched light source to collect images according to the adjusted light-emitting time parameter.
2. The method for automatic adjustment of machine vision detection parameters according to claim 1, wherein, If the gray value of the current measured object is within the target gray value range in S100, no adjustment is performed, and if it is out of the target gray value range, S200-S400 are executed.
3. The method for automatic adjustment of machine vision detection parameters according to claim 2, wherein, The target gray value range is the ideal gray value range that the image of the measured object should reach, which is preset by the upper computer.
4. An automatic adjustment system for machine vision detection parameters for performing the automatic adjustment method according to any one of claims 1 to 3, characterized in that, The method comprises the following steps: The intelligent camera is used to collect images of the measured object and analyze and calculate the gray value of the measured object, and the expected gray value of the measured object under the detection camera is calculated according to the preset gray relationship formula; The detection controller is connected with the intelligent camera, receives the gray value detection result, judges whether the current measured object needs to be adjusted in the sending time and in which channel, calculates the corresponding adjustment parameter, and sends the adjustment parameter to the light source controller when the measured object reaches the corresponding channel station; The light source controller is connected with the detection controller, one light source controller controls one or more light sources and detection cameras, and the light source controller adjusts the light-emitting time of the light source after receiving the adjustment parameter sent by the detection controller; A plurality of detection cameras and a plurality of light sources are connected with the light source controller and are used to collect images according to the control parameter of the light source controller.
5. The automatic adjustment system for machine vision detection parameters according to claim 4, wherein, The application relates to a system for detecting the color of an object, which comprises an upper computer connected with an intelligent camera, a detection camera and a detection controller, the upper computer is used for setting the working parameters of the detection controller and the initial parameters of the intelligent camera, the upper computer is also used for pre-setting the target gray value, and the light emitting time of the light source matched with the detection camera is adjusted according to the comparison result of the expected gray value and the target gray value.
6. The automatic adjustment system for machine vision detection parameters according to claim 4, wherein, All the light emitting time parameters are bound to the measured object in the form of a queue to form a queue and are sent to a light source controller, the light source controller is responsible for receiving the sent light emitting time parameters, modifying the specified light source brightness according to the light emitting time parameters, the light source controller determines the shooting positions of the multiple detection cameras through signal counting, and triggers the shooting of the work station camera and the matched light source in sequence according to the counting.
7. The automatic adjustment system for machine vision detection parameters according to claim 4, wherein, The system further comprises a motor and a photoelectric sensor electrically connected with the detection controller, the output end of the motor is connected with a rotating disc for driving the rotating disc to convey the measured object to a to-be-collected position, and the photoelectric sensor is used for sensing the measured object and sending a trigger signal to the detection controller, so that the camera collects the image of the measured object.
Citation Information
Patent Citations
Tunnel multi-section visual detection system and adaptive adjustment method
CN114166180A
Industrial camera self-adaptive exposure method and device for dimming film and electronic equipment
CN118042285A