Tea garden camera dynamic exposure control method and system based on random forest prediction model
By employing a random forest prediction model in the tea garden image acquisition system, combined with image quality and ambient light parameters, dynamic exposure control of the tea garden camera was achieved. This solved the problem of underexposure or overexposure in complex environments, improved the robustness and adaptability of image acquisition, and ensured the accuracy of bud identification.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-01-06
- Publication Date
- 2026-03-27
AI Technical Summary
In existing technologies, tea garden image acquisition systems lack highly adaptable exposure control methods in complex natural environments, resulting in underexposure or overexposure of images, which affects the accuracy of pest and disease identification and analysis of bud growth status. Furthermore, existing model training relies on complex annotations or has high computational overhead, making it difficult to deploy on resource-constrained agricultural equipment.
A dynamic exposure control method based on a random forest prediction model is adopted. By collecting image quality parameters and ambient light parameters, a random forest regression model is constructed. Combined with the local photoresponse difference spectrum, the camera exposure parameters are adaptively adjusted, including image acquisition, quality extraction, ambient light acquisition, model training and real-time prediction.
Under varying natural lighting conditions, the system can quickly predict the optimal exposure parameters, improving the image clarity and depth of the target area of the tender buds, enhancing the robustness and adaptability of the tea garden image acquisition system, and avoiding exposure imbalance caused by sudden changes in lighting and shadows.
Smart Images

Figure CN121751001A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of exposure control technology, and in particular to a dynamic exposure control method and system for a tea garden camera based on a random forest prediction model. Background Technology
[0002] In intelligent agricultural monitoring scenarios, especially in the identification of pests and diseases and the analysis of the growth status of tender buds in tea gardens, higher requirements are placed on the quality of image acquisition. Due to the extremely complex natural lighting conditions in the tea garden environment, such as shading by branches and leaves, cloud changes, and changes in the angle of sunlight in the morning and evening, images are often underexposed or overexposed, which seriously affects the accuracy of subsequent image-based automatic identification, segmentation, and classification tasks. Therefore, achieving a highly adaptable exposure control method for complex natural environments has become a key technical bottleneck in improving the performance of intelligent image acquisition systems for tea gardens.
[0003] Most existing exposure control strategies are based on single-dimensional adjustment methods such as fixed exposure strategies, global average brightness, or grayscale contrast. These strategies lack perception and evaluation of the current image quality and fail to fully utilize the correlation information between historical images and illumination. Some studies have attempted to introduce machine learning methods for exposure prediction, but these methods suffer from problems such as reliance on complex annotations or high computational costs, making them difficult to deploy on resource-constrained agricultural data collection equipment. Therefore, there is an urgent need for a prediction model that combines image quality feedback and ambient light information, possesses high generalization ability, and has low computational burden, to achieve dynamic adaptive control of camera exposure parameters in natural scenes. Summary of the Invention
[0004] This invention provides a method and system for dynamic exposure control of a tea garden camera based on a random forest prediction model.
[0005] A dynamic exposure control method for tea garden cameras based on a random forest prediction model includes the following steps: S1: Collect image data of the tea garden under different lighting conditions and extract image quality parameters of the tender bud area in each image; S2: Synchronously acquire ambient light parameters during the capture of each image; S3: Construct and train a random forest prediction model based on image quality parameters and ambient light parameters; S4: Real-time acquisition of current ambient light parameters and image quality parameters of the previous frame; S5: Input the current ambient light parameters and the image quality parameters of the previous frame into the trained random forest prediction model to predict the optimal exposure parameters for the current frame; S6: Adjust the camera exposure settings according to the optimal exposure parameters and capture the current frame image; S7: Collect the local photoresponse difference spectrum between the bud region and the background region in the current frame image, and compare it with the response spectrum under standard illumination to generate an exposure compensation sensitivity map; the exposure compensation sensitivity map characterizes the distribution of the sensitivity of the image region to the adjustment of exposure parameters under the current illumination angle and leaf surface reflection conditions; based on the exposure compensation sensitivity map, perform local offset correction on the optimal exposure parameters predicted by the random forest model to achieve exposure interference suppression in high-reflectivity heterogeneous regions.
[0006] Optionally, S1 includes: S11: Fixedly deploy image acquisition equipment in the tea garden to periodically acquire original images of the tea garden within a preset period covering different sunrise and sunset times and various weather types; S12: For each original image of the tea garden, the tender bud area in the image is identified and extracted using an image segmentation algorithm; S13: Based on the extracted bud region, calculate the image quality parameters of the bud region, including the average gray value, standard deviation contrast, and sharpness evaluation value based on the edge detection operator of the bud region.
[0007] Optionally, S13 includes: Based on the extracted bud region, the average gray value of all pixels in the bud region is calculated as the average gray value of the bud region. Based on the average gray value of the sprout region, the standard deviation of the gray value of each pixel in the sprout region is calculated to obtain the standard deviation contrast of the sprout region. The Sobel edge detection operator is applied to the sprout region to calculate the gradient magnitude of each pixel within the sprout region, and the average value is taken as the sharpness evaluation value.
[0008] Optionally, S2 includes: S21: Deploy a light sensor at a position that faces the same direction as the camera lens or at a preset angle; S22: At the moment the camera triggers the shooting, the light sensor is triggered to collect data through a hardware synchronization signal, and the unified timing module assigns the same high-precision timestamp to the image shooting event and the light sensor data collection event; S23: Record the ambient light parameters collected by the light sensor, wherein the ambient light parameters include at least light intensity and color temperature; S24: Establish a correlation between each set of ambient light parameters and the image frame acquired at the corresponding time to form a synchronized data pair.
[0009] Optionally, S3 includes: S31: Construct each set of synchronized data obtained into a training sample; S32: Construct a random forest model with regression as the task, wherein the random forest model consists of a preset number of decision trees; S33: Using the entire training sample set, generate a training subset for each decision tree by random sampling, and train each decision tree by recursively selecting the feature that maximizes the reduction of node data impurity for splitting. S34: The predicted output of a trained random forest model is the average of the predicted values of multiple decision trees; The input feature vector of the training sample is composed of the combination of the ambient light parameters and the image quality parameters, and the output label is the optimal exposure parameter determined by optimization for the image in the corresponding synchronous data.
[0010] Optionally, S4 includes: S41: Real-time reading of the current ambient light parameters collected by the light sensor and synchronized with the current moment; S42: After completing the acquisition of the previous frame image, immediately extract the bud region of the previous frame image, calculate the image quality parameters, and then store the image quality parameters in the prior parameter buffer. S43: When the exposure parameters need to be predicted in the current frame, read the image quality parameters of the previous frame image from the prior parameter buffer.
[0011] Optionally, S5 includes: S51: Combine the current ambient light parameters acquired in real time with the image quality parameters of the previous frame image read from the prior parameter buffer into a current input feature vector in a preset order; S52: Input the current input feature vector into the trained random forest prediction model that has been loaded into memory; S53: Each decision tree in the random forest prediction model makes an independent prediction based on the current input feature vector and outputs a predicted value; S54: Aggregate the predicted values of all decision trees in the random forest prediction model and calculate the average value as the prediction result of the best exposure parameter for the current frame.
[0012] Optionally, S6 includes: S61: The predicted optimal exposure parameters are parsed into control instructions that the camera can execute, including control of shutter speed and photosensitive gain; S62: The control command is sent to the camera through the camera control interface to drive the camera to complete the adjustment of exposure parameters; S63: After confirming that the camera exposure parameters have been adjusted, immediately trigger the camera to acquire the current frame image.
[0013] Optionally, S7 includes: S71: Extract the local photoresponse difference spectrum between the bud region and the background region in the current frame image; S72: Compare the difference spectrum with the response spectrum under standard illumination to generate an exposure compensation sensitivity map; S73: Based on the exposure compensation sensitivity map, perform local offset correction on the optimal exposure parameters predicted by the random forest model for the next frame.
[0014] A dynamic exposure control system for tea garden cameras based on a random forest prediction model, used to implement the aforementioned dynamic exposure control method for tea garden cameras based on a random forest prediction model, includes the following modules: Image acquisition module: Acquires image data of the tea garden under different lighting conditions; Image quality extraction module: Extracts image quality parameters of the bud area from each image; Ambient light parameter acquisition module: synchronously acquires ambient light parameters at the time of each image capture; Model training module: Constructs and trains a random forest prediction model based on image quality parameters and ambient light parameters; Real-time input feature construction module: acquires the current ambient light parameters and the image quality parameters of the previous frame in real time, and combines them to form the current input feature vector; Exposure parameter prediction module: Inputs the current input feature vector into the trained random forest prediction model to predict the optimal exposure parameters for the current frame; Camera control module: Generates camera control commands based on the optimal exposure parameters and sends them to the camera to complete the exposure setting adjustment; Image acquisition control module: After the camera completes the exposure parameter adjustment, it triggers the camera to acquire the current frame image; Exposure compensation sensitivity map generation and adaptive correction module: Based on the differences in the response of different regions in the current frame image to illumination, an exposure compensation sensitivity map is constructed, and the exposure parameters predicted by the random forest model are spatially corrected accordingly.
[0015] The beneficial effects of this invention are: This invention proposes a dynamic exposure control method for tea garden cameras that combines image quality parameters, ambient light parameters, and local photoresponse differences. By constructing and training a random forest regression model, the system can quickly predict the optimal exposure parameters for the current frame under varying natural lighting conditions, achieving automatic exposure adjustment for the target area of tender buds. Compared with traditional exposure strategies based on fixed thresholds or simple regression, this method introduces the image quality information of the previous frame as a feedback quantity and combines it with the current environmental parameters for time-aware prediction, improving the robustness and adaptability of exposure control and effectively avoiding exposure imbalance caused by sudden changes in lighting, shadows, or changes in the angle of sunlight.
[0016] This invention innovatively introduces the construction and application of exposure compensation sensitivity maps. Based on the local photoresponse difference spectrum between the bud and background regions in the current frame, it extracts sensitivity distribution information under different reflection conditions and performs local offset correction on the exposure parameters predicted by random forest. This mechanism can accurately identify the interference effect of high-reflectivity heterogeneous regions on the overall exposure, thereby spatially adaptively adjusting the predicted exposure value, improving the clarity and layering of the bud image region, and providing high-quality visual input for subsequent tea bud identification, grading, or harvesting operations. Attached Figure Description
[0017] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only for this invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0018] Figure 1 This is a schematic diagram of the method flow according to an embodiment of the present invention; Figure 2 This is a schematic diagram of the system modules in an embodiment of the present invention. Detailed Implementation
[0019] The present invention will now be described in detail with reference to the accompanying drawings and specific embodiments. Those skilled in the art may employ other alternative methods to implement some well-known technologies; moreover, the accompanying drawings are only for more specific description of the embodiments and are not intended to specifically limit the present invention.
[0020] like Figure 1 As shown, a dynamic exposure control method for a tea garden camera based on a random forest prediction model includes the following steps: S1: Collect image data of the tea garden under different lighting conditions and extract image quality parameters of the tender bud area in each image; S1 specifically includes: S11, Original Tea Garden Image Acquisition: Image acquisition equipment is permanently deployed in the tea garden, and original tea garden images are acquired periodically or triggered within a preset period covering different lighting conditions and various weather scenarios, generating an image set, represented as: ; in, This represents the image dataset, which is the collection of all original images acquired. For the i-th acquired image, where n is the total number of images; S12, bud region extraction: for each image Using image segmentation algorithms, the bud region in the image is extracted. And establish a region mask, represented as: ; in, For image The tender bud area, For image segmentation functions, to achieve high robustness and high accuracy in automatic segmentation, a semantic segmentation neural network based on the U-Net structure is adopted, including an encoder-decoder structure. The image segmentation algorithm specifically includes the following steps: S121, Data Preparation and Labeling: Original image: ; Manually labeled bud masks: ; The training set is constructed as follows: ; in, For the i-th acquired image, RGB three channels, The tea garden images must be high-resolution, ensuring that the structure of the tender buds is distinguishable; the resolution should not be too low. Simultaneously, the computing power of the deployed equipment must be considered. Let be the bud mask corresponding to the i-th image, where 1 represents the bud region and 0 represents the background. Consistent spatial dimensions For the labeled dataset, N is the total number of sample pairs, ranging from 100 to 10000; S122, Model Training: The U-Net network is trained using Dice coefficient loss, as shown below: ; in, This is the sprout probability map output by the model, showing the probability that a pixel represents a sprout. This is the actual label mask, i.e., the pixel markers in the mask image, which are only 0 or 1. The Dice loss function is used to measure the consistency between predictions and annotations. The Dice loss is sensitive to imbalanced classes and can strengthen boundary judgment, making it suitable for segmentation tasks of small objects such as sprouts. S123, Model Inference and Region Extraction: For each image Inputting the U-Net model yields the probability map. Set the binarization threshold T=0.5, perform binarization processing, and represent it as: ; That is, complete the tender shoot area Automatic extraction.
[0021] in, This is the probability map of new shoots output by the model. T is the binarization threshold, used to convert the probability map into a hard-label mask. A higher threshold is more conservative, and a lower threshold is more lenient. The image shows the result of binary segmentation, where 0 represents the background and 1 represents the predicted sprout.
[0022] S13, Calculation of sprout image quality parameters: For the sprout region extracted from each image Calculate the set of image quality parameters ,include: S131, Average Gray Value: ; in, Let be the average gray level of the sprout region in the i-th image. It is a key indicator of exposure; a higher gray level indicates higher overall image brightness. However, both excessively high and low gray levels may negatively impact recognition performance. This represents the number of pixels in the region. For the image in coordinates grayscale value; The average gray value reflects the overall brightness level of an image and is the most basic indicator for measuring the current exposure level. In actual tea garden shooting scenarios, lighting conditions change drastically. If the exposure is too low, the image will be too dark and the details of the tender buds will be difficult to identify; if the exposure is too high, the image will be overexposed, resulting in color distortion. Therefore, extracting the average gray value of the tender bud area helps to accurately reflect whether the target area is within a reasonable brightness range and serves as an important input feature for the model to determine whether the exposure needs to be increased or decreased.
[0023] S132, grayscale standard deviation contrast ratio: ; in, The grayscale contrast ratio represents the degree of dispersion in the distribution of pixel brightness within a given area. Gray-scale standard deviation represents the dispersion of gray-scale values of image pixels and can reflect the contrast of the image. For tea bud recognition tasks, too low contrast will make it difficult to distinguish the tender buds from the background, especially in cloudy or backlit conditions. Introducing standard deviation as a contrast index can help evaluate the visual layering and texture differentiation of the image, and is an important basis for focusing on the detail expression of the target area in exposure adjustment.
[0024] S133, Sharpness rating: ; in, Sharpness based on edge detection, which measures whether an image is blurry, is one of the core reference dimensions for dynamic exposure control. The magnitude of the image gradient; Image gradients were extracted using the Sobel operator, and edge responses were calculated in both the horizontal and vertical directions. The Sobel operator is a differential operator with a smoothing effect, possessing advantages such as strong noise resistance and sharp edge response, making it particularly suitable for evaluating the sharpness of bud images in natural scenes. Horizontal gradient Vertical gradient For any pixel in the image Calculate the gradient magnitude Represented as: ; in, This represents the gradient value in each direction after the Sobel convolution, with a range of values. .
[0025] The sharpness evaluation value uses the average image gradient amplitude as a metric, which can effectively reflect the sharpness of edges. During dynamic imaging, inaccurate focusing, motion blur, or lighting fluctuations may cause image edges to become blurred, thus affecting the recognition accuracy of the bud area. Using edge gradient as a sharpness indicator can not only evaluate whether the image is sharp, but also help determine whether it is necessary to improve image stability and sharpness through exposure time and other methods. It is a supplement to image quality in a higher dimension than brightness and contrast.
[0026] S134, the image quality parameter of the bud region in the i-th image is defined as: .
[0027] S2: Synchronously acquire ambient light parameters during the capture of each image; S2 specifically includes: S21, Light sensor deployment and lighting consistency: Oriented in the same direction as the camera lens or at a preset angle. Deploy light sensor units to ensure that their sensing direction covers the tender bud area in the tea garden image, forming a synchronous light acquisition structure; in, The angle between the light sensor and the camera's principal optical axis. In field deployments, if the incident light angle deviates too much from the shooting angle, it will cause inconsistencies between the sensing results and the image brightness performance. Range setting... Ensure that the directionality of light perception is consistent with that of image capture.
[0028] S22, Shooting-Light Synchronization Mechanism: Each time the camera triggers to capture an image frame... The moment Light acquisition synchronization is achieved through hardware-triggered signal synchronization and unified time synchronization, as shown below: ; ; in, This indicates that the image acquisition signal is used as an external trigger signal for the optical sensor. This indicates the synchronization timestamp assigned by the high-precision time synchronization module. Let i be the ambient light sampling value of the i-th time. In the tea garden scene, the lux is about 2000-5000-lux on cloudy days and can reach 50000-lux on sunny days. Direct sunlight at noon can exceed 90000 lux. The range setting covers sunrise-sunset and various weather conditions. S23, Ambient Light Parameter Acquisition: Capture time for each frame of image Record the corresponding ambient light parameter pairs, represented as: ; in, Let i be the ambient light parameters corresponding to the i-th frame image. The ambient light intensity represents the illuminance in the current area of the bud. For ambient color temperature, This indicates the color temperature characteristics of the current light source, which affects the color tone deviation of the image; S24, Image and Light Parameter Alignment: Each frame of the image is bound to its corresponding ambient light parameters at that moment, forming an image-lighting data pair, represented as: ; in, This is an image and ambient light synchronization dataset, where n is the number of image acquisition frames, and its value ranges from 1 to 2. This fully covers various lighting and exposure conditions, ensuring the diversity and generalization ability of model training, and is used to build training samples for subsequent use, so as to support the random forest model in learning the mapping relationship between lighting conditions, image quality and exposure parameters.
[0029] S3: Construct and train a random forest prediction model based on image quality parameters and ambient light parameters; S3 specifically includes: S31, Constructing the training sample set: Extracting image quality parameters Ambient light parameters acquired synchronously The combined training samples are represented by the following input feature vector: ; in, It is the average grayscale value of the bud region in the i-th frame of the image, ranging from 0 to 255. It reflects the overall brightness of the image and is a direct indicator of whether the exposure is appropriate. This is the standard deviation contrast of the budding area, ranging from 0 to 127.5. It is half the grayscale value and represents the degree of brightness fluctuation within the area. A higher value indicates richer image detail, which is beneficial for target recognition. This is the sharpness evaluation value for the bud area, which is based on the average value of the edge gradient. The value ranges from 10 to 300. The higher the value, the sharper the image and the more obvious the edges. It is the core indicator for sharpness evaluation. This refers to the light intensity during image acquisition, ranging from 0 to 100,000. Under natural light conditions, it is approximately 2,000-5,000 lux on cloudy days and can reach 100,000 lux at noon, covering the entire range of light intensity variations in the tea garden throughout the day. This refers to the color temperature during image acquisition, ranging from 2000 to 10000. Different color temperatures affect the image's hue. The influence of color temperature on exposure adjustment and image performance should also be considered. It is the input feature vector formed after combination; For each set of ambient light and image quality inputs Automatic search for exposure control parameters that optimize image quality As supervisory labels for the training samples, the exposure control parameters include exposure time, simulated gain, and ISO value; taking exposure time as an example, it specifically includes: (1) Define the exposure control parameter space: Let the exposure control parameter to be optimized be the exposure time. This can be extended to multi-dimensional parameters, and the search space can be defined as follows: ; in, The exposure time is set within a range based on the actual camera capabilities of the tea garden.
[0030] (2) Constructing image quality evaluation functions: Calculate the corresponding image quality function for each image. As the objective function of Bayesian optimization, it is expressed as: ; in, The average gray value of the image. For image contrast, It refers to image sharpness, specifically the magnitude of edge gradients. Weighting coefficients , , This reflects the weight of the three factors in the overall quality. This indicates that the indicator has been normalized and scaled to... The interval is used to facilitate fusion calculation.
[0031] (3) Bayesian optimization iterative process: Bayesian optimization efficiently searches in a low-dimensional parameter space using probabilistic modeling, thereby improving the image quality function. Maximizing, specifically includes: 1) Initial sample acquisition: Select k initial exposure time points within the parameter range. Acquire images and calculate corresponding , It is used to establish the initial Gaussian process regression model.
[0032] 2) Constructing a surrogate model: The distribution of the objective function is modeled using a Gaussian process, expressed as: ; in, To predict the mean, The covariance function is RBF kernel, and the prediction result is for each candidate point. The expected value and uncertainty.
[0033] 3) Select the next evaluation point: Use the acquisition function to select the next evaluation point, expressed as: ; in, To balance exploration and utilization, a UCB (Unified Confidence Bound) strategy is introduced. This strategy comprehensively considers the model's predicted mean and uncertainty for a given parameter point, favoring locations that are likely to produce good results while also providing new information. This increases the probability of discovering the global optimum. By calculating the prediction results output by the current surrogate model, the exposure parameter that maximizes the acquisition function value is selected as a candidate point for the next evaluation, denoted as... ; 4) Update the model and iterate to optimize: Once the next exposure parameters are determined... Immediately control the camera to take pictures and calculate the image quality evaluation value of the acquired images. The sample, along with the corresponding exposure parameters, is added to the current sample set as a new sample. Based on the expanded sample set, the Gaussian process surrogate model is retrained to update its predictive ability for the current search space. After the model update is completed, the sampling strategy is executed again to determine the next evaluation point. This process iterates continuously, forming a closed-loop optimization process of sampling-modeling-selection-expansion, until the preset termination conditions are met, including: Reaching the maximum number of assessments; The image quality improvement rate is less than a set threshold for several consecutive rounds; Or the prediction results tend to converge and the changes slow down; The exposure parameter with the highest corresponding image quality rating is selected from all evaluated exposure parameters and used as the optimal exposure parameter under the current lighting and image conditions.
[0034] (4) Output optimal exposure parameters: After optimization, select the exposure time corresponding to the maximum image quality function value, expressed as: ; Exposure time corresponding to the maximum image quality function value The optimal exposure parameters for the current frame image are written into the training sample labels, and are represented as follows: ; in, These are the final, optimal exposure parameters.
[0035] S32, Constructing the Random Forest Model Structure: Build a regression-type random forest model. It consists of T regression decision trees, represented as: ; in, For the first There are 100 regression trees, where T is the number of decision trees in the forest, and its value ranges from 1 to 10. ; S33, Decision Tree Training Process: For each tree Training is conducted through the following process: S331, Sample Extraction: From The training subset is generated using random sampling with replacement, denoted as: ; S332, Recursive Splitting Training: For each tree node, select the feature that minimizes the mean squared error (MSE) of the objective function for splitting, specifically including: 1) Given the current node's sample set D, its MSE is defined as: ; in, For the sample size, For the first The true label of each sample For the first The mean of all sample labels for a given sample, i.e., the predicted output; 2) For a certain feature To attempt splitting, set the splitting threshold to s, and divide the samples into: Left subset: ; Right Subset: ; Where s represents the feature The set partitioning threshold is used to divide the sample set D into two subsets, left and right. ; 3) The total weighted MSE after partitioning is: ; in, and The mean square error of the node samples; 4) The purity level is increased as follows: ; Decision trees enumerate each feature dimension And candidate classification points s, select to make The largest group As the optimal partition for the current node; S34, Model Prediction Mechanism: The trained Random Forest model predicts new inputs. The corresponding exposure parameter output is the average of the prediction results for each tree, expressed as: ; in, The model's predicted output is represented by the average voting strategy of the ensemble regression, which improves robustness and avoids overfitting.
[0036] S4: Real-time acquisition of current ambient light parameters and image quality parameters of the previous frame; S4 specifically includes: S41, Real-time reading of current ambient light parameters: In the current frame image Before data acquisition, ambient light parameters synchronized with the current time t are obtained using a light sensor, forming the following vector, as shown below: ; in, The ambient light parameters for the current frame. The current light intensity, with a value range of [value range missing]. lux, The color temperature of the current light source, with a value range of [value range missing]. K, this parameter is synchronized with image acquisition via hardware triggering or timing module to ensure real-time exposure prediction.
[0037] S42, extract and cache the image quality parameters of the previous frame: previous frame image Immediately after data collection, extract the bud area from the image. And calculate the corresponding image quality parameters. , represented as: ; in, The average grayscale value reflects the overall brightness of the image. The standard deviation of grayscale and the contrast ratio are given. The sharpness evaluation value is based on edge detection. The previous frame image The corresponding image quality parameters; Then Store in prior parameter cache Used for exposure prediction in the next frame, and is represented as: ; S43, Read the image quality parameters of the previous frame for prediction of the current frame: when the current frame When it is necessary to predict exposure parameters, the image quality parameters of the previous frame are read from the prior parameter buffer. , represented as: ; in, This refers to the image quality parameters of the previous frame.
[0038] S5: Input the current ambient light parameters and the image quality parameters of the previous frame into the trained random forest prediction model to predict the optimal exposure parameters for the current frame; S5 specifically includes: S51, Feature Vector Construction: Constructing the current ambient light parameters Image quality parameters compared to the previous frame The combination forms the input feature vector of the current frame, represented as: ; in, This represents the average grayscale value of the bud area in the previous frame image. The standard deviation of the contrast of the bud area in the previous frame image. It is the sharpness evaluation value of the bud area in the previous frame image. The ambient light intensity of the current frame. The ambient color temperature of the current frame; S52, Input to the Random Forest Prediction Model: Input the completed current frame feature vector. Input to the pre-trained random forest prediction model that has been loaded into memory In this context, the function used to predict exposure parameters is represented as: ; S53, Each decision tree makes independent predictions: Random Forest model Including T trained decision trees Each tree is based on the input feature vector. Output a predicted value , represented as: ; S54, Aggregate prediction results and calculate the average as the final output: Average the predictions from all decision trees to obtain the optimal exposure parameter prediction result for the current frame. , represented as: ; Final prediction results This indicates the optimal exposure parameters to be used for acquiring the current frame image, including the exposure time. Analog gain ISO value.
[0039] S6: Adjust the camera exposure settings according to the optimal exposure parameters and capture the current frame image; S6 specifically includes: S61, Exposure parameters are interpreted as control commands: The optimal exposure parameters will be obtained. This is parsed into the low-level instruction set required for camera control, represented as: ; in, The shutter speed of the predicted current frame image, in milliseconds. The predicted photosensitive gain of the current frame image, i.e., the ISO value or digital gain coefficient; This parsing process converts numerical exposure parameters into a standard control command format based on the camera parameter control protocol. , represented as: ; in, This represents an encoding function that conforms to a specific camera communication protocol. The conversion steps include: S611 will predict the output. The control bytes converted to the camera shutter register are represented as: ; in, This is the control byte for the camera shutter register. This is the minimum shutter speed step defined in the camera control protocol, with a value of 0.1ms. This indicates a floor function that ensures the control byte is an integer. S612, ISO encoding: predict the output Normalized and mapped to gain control bits, it is represented as: ; in, This is the gain control bit. Gain control mapping table; S613, Assemble Control Command: Combines two control sub-items into a complete camera control command frame, represented as: ; in, To fix the message header for control commands, This is the checksum calculated based on the message content. This indicates byte concatenation.
[0040] S62, Control Command Issuance and Exposure Setting Adjustment: Control commands are transmitted via the camera control interface. When sent to the camera module, it is represented as: ; The control interface is responsible for accurately issuing the above instructions and driving the camera to complete the real-time adjustment of the exposure settings for the current frame, including mechanical / electronic adjustment of shutter speed and parameter setting of sensor gain factor; S63, Trigger Image Acquisition: Upon receiving a feedback signal from the camera and confirming that the exposure parameters have been set, an image acquisition command is immediately sent to execute the acquisition operation of the current frame image, as shown below: ; in, This represents the image data of the current frame. After acquisition, it will enter the input process for image quality assessment and the next round of exposure prediction, forming a closed loop to create an inter-frame adaptive exposure control mechanism.
[0041] S7: Collect the local photoresponse difference spectrum between the bud region and the background region in the current frame image, and compare it with the response spectrum under standard illumination to generate an exposure compensation sensitivity map; the exposure compensation sensitivity map characterizes the distribution of the sensitivity of the image region to the adjustment of exposure parameters under the current illumination angle and leaf surface reflection conditions; based on the exposure compensation sensitivity map, perform local offset correction on the optimal exposure parameters predicted by the random forest model to achieve exposure interference suppression in high-reflectivity heterogeneous regions.
[0042] S7 specifically includes: S71, Local Optical Response Difference Spectrum Extraction: From the current frame image Divide the area into two sections to create a tender shoot area. With background area The photoresponse vectors are extracted separately, and the local response difference spectrum is calculated, which is expressed as: ; ; ; in, This represents the brightness value or channel vector of the current frame image. These represent the average light response of the bud region and the background region, respectively. This is the local optical response difference spectrum of the current frame, used to characterize the reflection differences between regions.
[0043] S72, Construction of Exposure Compensation Sensitivity Map: Constructing Local Response Difference Spectra Reference response spectrum under standard illumination conditions By comparing and calculating the exposure sensitivity factor for each region, a two-dimensional exposure compensation sensitivity map is generated, represented as follows: ; ; in, This is a spectrum of the difference between the bud and background response collected under standard illumination. Represents pixels Relative sensitivity to exposure adjustments This is an exposure compensation sensitivity map for the entire image region.
[0044] S73, Local Offset Correction: Based on Exposure Compensation Sensitivity Map The optimal exposure parameters for the current frame predicted by the random forest model. Perform local offset correction and calculate the final exposure parameters, expressed as follows: ; in, These are the exposure parameters predicted by the model. This indicates the corrected final exposure parameters. For sensitivity higher than a preset sensitivity threshold The set of regions, This indicates the number of pixels in the highly sensitive region. This is an adjustment factor for exposure shift, ranging from 0.1 to 0.3. It controls the weight of the sensitive area's influence on exposure correction; too large a value may lead to overcorrection, while too small a value will have little effect. The sensitivity threshold is set to 0.2-0.4, which indicates which areas need to participate in the exposure shift. Setting it too high may ignore important areas, while setting it too low may introduce noise.
[0045] like Figure 2 As shown, a dynamic exposure control system for a tea garden camera based on a random forest prediction model is used to implement the aforementioned dynamic exposure control method for a tea garden camera based on a random forest prediction model. The system includes the following modules: Image acquisition module: Acquires image data of the tea garden under different lighting conditions; Image quality extraction module: Extracts image quality parameters of the bud area from each image; Ambient light parameter acquisition module: synchronously acquires ambient light parameters at the time of each image capture; Model training module: Constructs and trains a random forest prediction model based on image quality parameters and ambient light parameters; Real-time input feature construction module: acquires the current ambient light parameters and the image quality parameters of the previous frame in real time, and combines them to form the current input feature vector; Exposure parameter prediction module: Input the current input feature vector into the trained random forest prediction model to predict the optimal exposure parameters for the current frame; Camera control module: Generates camera control commands based on the optimal exposure parameters and sends them to the camera to complete the exposure setting adjustment; Image acquisition control module: After the camera completes the exposure parameter adjustment, it triggers the camera to acquire the current frame image; Exposure compensation sensitivity map generation and adaptive correction module: Based on the differences in the response of different regions in the current frame image to illumination, an exposure compensation sensitivity map is constructed, and the exposure parameters predicted by the random forest model are spatially corrected accordingly.
[0046] This invention encompasses any substitutions, modifications, equivalent methods, and solutions made within the spirit and scope of this invention. To provide the public with a thorough understanding of this invention, specific details are described in detail in the following preferred embodiments; however, those skilled in the art will fully understand the invention even without these details. Furthermore, to avoid unnecessary misunderstanding of the essence of this invention, well-known methods, processes, procedures, components, and circuits are not described in detail.
[0047] The above description is only a preferred embodiment of the present invention. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.
Claims
1. A dynamic exposure control method for tea garden cameras based on a random forest prediction model, characterized in that, Includes the following steps: S1: Collect image data of the tea garden under different lighting conditions and extract image quality parameters of the tender bud area in each image; S2: Synchronously acquire ambient light parameters during the capture of each image; S3: Construct and train a random forest prediction model based on image quality parameters and ambient light parameters; S4: Real-time acquisition of current ambient light parameters and image quality parameters of the previous frame; S5: Input the current ambient light parameters and the image quality parameters of the previous frame into the trained random forest prediction model to predict the optimal exposure parameters for the current frame; S6: Adjust the camera exposure settings according to the optimal exposure parameters and capture the current frame image; S7: Collect the local photoresponse difference spectrum between the bud area and the background area in the current frame image, and compare it with the response spectrum under standard illumination to generate an exposure compensation sensitivity map; the exposure compensation sensitivity map characterizes the distribution of the sensitivity of the image area to the adjustment of exposure parameters under the current illumination angle and leaf surface reflection conditions. The optimal exposure parameters predicted by the random forest model are locally offset and corrected based on the exposure compensation sensitivity map in order to suppress exposure interference in high-reflectivity heterogeneous regions.
2. The dynamic exposure control method for tea garden cameras based on a random forest prediction model according to claim 1, characterized in that, S1 includes: S11: Fixedly deploy image acquisition equipment in the tea garden to periodically acquire original images of the tea garden within a preset period covering different sunrise and sunset times and various weather types; S12: For each original image of the tea garden, the tender bud area in the image is identified and extracted using an image segmentation algorithm; S13: Based on the extracted bud region, calculate the image quality parameters of the bud region, including the average gray value, standard deviation contrast, and sharpness evaluation value based on the edge detection operator of the bud region.
3. The dynamic exposure control method for tea garden cameras based on a random forest prediction model according to claim 2, characterized in that, S13 includes: Based on the extracted bud region, the average gray value of all pixels in the bud region is calculated as the average gray value of the bud region. Based on the average gray value of the sprout region, the standard deviation of the gray value of each pixel in the sprout region is calculated to obtain the standard deviation contrast of the sprout region. The Sobel edge detection operator is applied to the sprout region to calculate the gradient magnitude of each pixel within the sprout region, and the average value is taken as the sharpness evaluation value.
4. The dynamic exposure control method for tea garden cameras based on a random forest prediction model according to claim 1, characterized in that, S2 includes: S21: Deploy a light sensor at a position that faces the same direction as the camera lens or at a preset angle; S22: At the moment the camera triggers the shooting, the light sensor is triggered to collect data through a hardware synchronization signal, and the unified timing module assigns the same high-precision timestamp to the image shooting event and the light sensor data collection event; S23: Record the ambient light parameters collected by the light sensor, wherein the ambient light parameters include at least light intensity and color temperature; S24: Establish a correlation between each set of ambient light parameters and the image frame acquired at the corresponding time to form a synchronized data pair.
5. The dynamic exposure control method for tea garden cameras based on a random forest prediction model according to claim 1, characterized in that, S3 includes: S31: Construct each set of synchronized data obtained into a training sample; S32: Construct a random forest model with regression as the task, wherein the random forest model consists of a preset number of decision trees; S33: Using the entire training sample set, generate a training subset for each decision tree by random sampling, and train each decision tree by recursively selecting the feature that maximizes the reduction of node data impurity for splitting. S34: The predicted output of a trained random forest model is the average of the predicted values of multiple decision trees; The input feature vector of the training sample is composed of the combination of the ambient light parameters and the image quality parameters, and the output label is the optimal exposure parameter determined by optimization for the image in the corresponding synchronous data.
6. The dynamic exposure control method for tea garden cameras based on a random forest prediction model according to claim 5, characterized in that, S4 includes: S41: Real-time reading of the current ambient light parameters collected by the light sensor and synchronized with the current moment; S42: After completing the acquisition of the previous frame image, immediately extract the bud region of the previous frame image, calculate the image quality parameters, and then store the image quality parameters in the prior parameter buffer. S43: When the exposure parameters need to be predicted in the current frame, read the image quality parameters of the previous frame image from the prior parameter buffer.
7. The dynamic exposure control method for tea garden cameras based on a random forest prediction model according to claim 6, characterized in that, S5 includes: S51: Combine the current ambient light parameters acquired in real time with the image quality parameters of the previous frame image read from the prior parameter buffer into a current input feature vector in a preset order; S52: Input the current input feature vector into the trained random forest prediction model that has been loaded into memory; S53: Each decision tree in the random forest prediction model makes an independent prediction based on the current input feature vector and outputs a predicted value; S54: Aggregate the predicted values of all decision trees in the random forest prediction model and calculate the average value as the prediction result of the best exposure parameter for the current frame.
8. The dynamic exposure control method for a tea garden camera based on a random forest prediction model according to claim 7, characterized in that, S6 includes: S61: The predicted optimal exposure parameters are parsed into control instructions that the camera can execute, including control of shutter speed and photosensitive gain; S62: The control command is sent to the camera through the camera control interface to drive the camera to complete the adjustment of exposure parameters; S63: After confirming that the camera exposure parameters have been adjusted, immediately trigger the camera to acquire the current frame image.
9. A dynamic exposure control method for a tea garden camera based on a random forest prediction model according to claim 8, characterized in that, S7 includes: S71: Extract the local photoresponse difference spectrum between the bud region and the background region in the current frame image; S72: Compare the difference spectrum with the response spectrum under standard illumination to generate an exposure compensation sensitivity map; S73: Based on the exposure compensation sensitivity map, perform local offset correction on the optimal exposure parameters predicted by the random forest model for the next frame.
10. A dynamic exposure control system for a tea garden camera based on a random forest prediction model, used to implement the dynamic exposure control method for a tea garden camera based on a random forest prediction model as described in any one of claims 1-9, characterized in that, Includes the following modules: Image acquisition module: Acquires image data of the tea garden under different lighting conditions; Image quality extraction module: Extracts image quality parameters of the bud area from each image; Ambient light parameter acquisition module: synchronously acquires ambient light parameters at the time of each image capture; Model training module: Constructs and trains a random forest prediction model based on image quality parameters and ambient light parameters; Real-time input feature construction module: acquires the current ambient light parameters and the image quality parameters of the previous frame in real time, and combines them to form the current input feature vector; Exposure parameter prediction module: Inputs the current input feature vector into the trained random forest prediction model to predict the optimal exposure parameters for the current frame; Camera control module: Generates camera control commands based on the optimal exposure parameters and sends them to the camera to complete the exposure setting adjustment; Image acquisition control module: After the camera completes the exposure parameter adjustment, it triggers the camera to acquire the current frame image; Exposure compensation sensitivity map generation and adaptive correction module: Based on the differences in the response of different regions in the current frame image to illumination, an exposure compensation sensitivity map is constructed, and the exposure parameters predicted by the random forest model are spatially corrected accordingly.