A stripe structured light based auto exposure method and stripe light structured camera
By using a mask divided by gray values in a striped structured light camera, the cost of brightness difference is calculated, and exposure parameters are automatically adjusted, solving the problem of exposure parameter setting in the measurement of highly and lightly reflective surfaces, and improving image quality and measurement accuracy.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- HANGZHOU HIKROBOT TECH CO LTD
- Filing Date
- 2026-02-28
- Publication Date
- 2026-06-05
Smart Images

Figure CN122160631A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer vision technology, and in particular to an automatic exposure method and a striped light structured light camera based on striped structured light. Background Technology
[0002] A striped light structure camera is an active 3D measurement device that projects a series of alternating light and dark stripe patterns onto the object to be measured and uses one or more cameras to observe the deformation of these stripes on the surface of the object, thereby calculating the 3D coordinates of each point on the object's surface.
[0003] However, the working environment of a striped structured light camera is quite complex. The object under test usually has both highly reflective and low-reflective surface characteristics. The response of high-reflective and low-reflective areas to light is very different. If the exposure is increased in order to see the low-reflective dark areas clearly, the signal of the high-reflective bright areas will be oversaturated, the stripe information will be completely lost, and holes will appear after reconstruction. If the exposure is reduced in order to protect the high-reflective bright areas, the signal of the low-reflective dark areas will be too weak and drowned out by noise, resulting in phase calculation errors and reconstruction results full of noise or missing data.
[0004] Therefore, how to automatically set appropriate exposure parameters so that the striped structured light camera can capture high-quality images in each acquisition, thereby ensuring the measurement of high-precision 3D point cloud data, is the key to improving the ease of use and measurement accuracy of the striped structured light camera. Summary of the Invention
[0005] The purpose of this application is to provide an automatic exposure method and a fringe structured light camera based on fringe structured light, so as to improve the ease of use and measurement accuracy of the fringe structured light camera. The specific technical solution is as follows:
[0006] A first aspect of this application provides an automatic exposure method based on striped structured light, the method comprising:
[0007] Obtain multiple masks divided according to gray values, wherein the masks have no overlap and their combination forms a complete image region;
[0008] Under multiple preset first exposures, acquire black and white images captured by the image acquisition device under each of the preset first exposures;
[0009] For each of the aforementioned masks, the cost under each of the aforementioned preset first exposures is calculated, wherein the cost is positively correlated with the brightness difference; the brightness difference is the difference between the brightness of the mask region in the white image under the preset first exposure and the brightness of the mask region in the black image under the preset first exposure.
[0010] Based on the cost of each preset first exposure, the optimal exposure range corresponding to each mask is determined; wherein, any exposure in the optimal exposure range satisfies the following condition: the cost of that exposure satisfies the high cost condition.
[0011] The target exposure is determined based on the optimal exposure range corresponding to each of the masks.
[0012] In one possible implementation, the mask includes a first mask, a second mask, and a third mask, each of which is divided in the following manner:
[0013] Acquire an image under a preset second exposure, with a white projection pattern projected;
[0014] Based on the grayscale value of the image, mask segmentation is performed to obtain three masks; wherein, the grayscale value of the first mask is not greater than the lower grayscale threshold, and the grayscale value of the third mask is not less than the upper grayscale threshold.
[0015] In one possible implementation, the upper grayscale threshold and the lower grayscale threshold are obtained as follows:
[0016] The grayscale histogram of the image was obtained statistically.
[0017] In the grayscale histogram, three peaks are determined in descending order of peak value, and the grayscale values of the three peaks are recorded as the first grayscale value, the second grayscale value, and the third grayscale value in ascending order of grayscale value of the peaks.
[0018] The median of the first gray value and the second gray value is used as the lower gray value threshold, and the median of the second gray value and the third gray value is used as the upper gray value threshold.
[0019] In one possible implementation, the cost includes a first sub-cost and a second sub-cost, wherein the first sub-cost is the ratio of the brightness of the mask region in the white image under the preset first exposure to the brightness of the mask region in the black image under the preset first exposure, and the second sub-cost is the difference between the brightness of the mask region in the white image under the preset first exposure and the brightness of the mask region in the black image under the preset first exposure.
[0020] The step of determining the optimal exposure range corresponding to each mask based on the cost under each preset first exposure includes:
[0021] The first sub-cost and the second sub-cost under each preset first exposure are weighted and summed to obtain the cost under each preset first exposure.
[0022] For each of the aforementioned masks, the response function of the mask is determined based on each of the aforementioned preset first exposures and the costs under each of the aforementioned preset first exposures;
[0023] The exposure range corresponding to the first exposure value at the maximum value of the response function is determined as the optimal exposure range for the mask.
[0024] In one possible implementation, determining the exposure range containing the exposure value corresponding to the maximum value of the response function includes:
[0025] Obtain the maximum value of the response function, the first exposure value corresponding to the maximum value, and the weight value pre-set for the mask;
[0026] Calculate the product of the weight value and the maximum value, and use it as the first function value;
[0027] Determine the exposure range that allows the response function to be greater than the first function value.
[0028] In one possible implementation, the method further includes:
[0029] The optimal exposure ranges corresponding to each mask are sorted in descending order of their area;
[0030] Determining the target exposure based on the optimal exposure range corresponding to each of the masks includes:
[0031] If the first exposure value within the optimal exposure range ranked first by area is within the other two optimal exposure ranges, then the first exposure value corresponding to the optimal exposure range ranked first by area is determined as the target exposure.
[0032] If the first exposure value in the optimal exposure interval of the first area ranking is not in the optimal exposure interval of the second area ranking, then the intersection of the optimal exposure interval of the first area ranking and the optimal exposure interval of the second area ranking is calculated to obtain the first exposure interval, and the boundary value in the first exposure interval that is closest to the first exposure value in the optimal exposure interval of the first area ranking is determined as the target exposure.
[0033] If the first exposure value within the optimal exposure range of the first area ranking is within the optimal exposure range of the second area ranking but not within the optimal exposure range of the third area ranking, then the intersection of the optimal exposure range of the first area ranking and the optimal exposure range of the second area ranking is calculated to obtain the first exposure range. The intersection of the first exposure range and the optimal exposure range of the third area ranking is calculated to obtain the second exposure range. The boundary value in the second exposure range that is closest to the first exposure value within the optimal exposure range of the first area ranking is determined as the target exposure.
[0034] If the second exposure interval does not intersect with the third-ranked optimal exposure interval in terms of area, then the boundary value in the second exposure interval that is closest to the third-ranked optimal exposure interval in terms of area is determined as the target exposure.
[0035] A second aspect of this application provides a striped light structure camera, the camera including an image acquisition device and a control module;
[0036] The image acquisition device is used to capture black and white images under the control of the control module;
[0037] The control module is used to execute any of the automatic exposure methods described above.
[0038] A third aspect of this application provides an automatic exposure apparatus based on striped structured light, the apparatus comprising:
[0039] The mask acquisition module is used to acquire multiple masks divided according to gray values, wherein the masks have no overlap and their combination forms a complete image region;
[0040] The shooting control module is used to acquire black and white images captured by the image acquisition device under each of the preset first exposures under multiple preset first exposures;
[0041] The cost calculation module is used to calculate the cost for each of the masks under each of the preset first exposures, wherein the cost is positively correlated with the brightness difference; the brightness difference is the difference between the brightness of the mask area in the white image under the preset first exposure and the brightness of the mask area in the black image under the preset first exposure.
[0042] The interval determination module is used to determine the optimal exposure interval corresponding to each of the masks based on the cost under each preset first exposure; wherein, any exposure in the optimal exposure interval satisfies the following: the cost under that exposure satisfies the high cost condition;
[0043] The exposure determination module is used to determine the target exposure based on the optimal exposure range corresponding to each of the masks.
[0044] In one possible implementation, the mask includes a first mask, a second mask, and a third mask, each of which is divided in the following manner:
[0045] Acquire an image under a preset second exposure, with a white projection pattern projected;
[0046] Based on the grayscale value of the image, mask segmentation is performed to obtain three masks; wherein, the grayscale value of the first mask is not greater than the lower grayscale threshold, and the grayscale value of the third mask is not less than the upper grayscale threshold.
[0047] In one possible implementation, the upper grayscale threshold and the lower grayscale threshold are obtained as follows:
[0048] The grayscale histogram of the image was obtained statistically.
[0049] In the grayscale histogram, three peaks are determined in descending order of peak value, and the grayscale values of the three peaks are recorded as the first grayscale value, the second grayscale value, and the third grayscale value in ascending order of grayscale value of the peaks.
[0050] The median of the first gray value and the second gray value is used as the lower gray value threshold, and the median of the second gray value and the third gray value is used as the upper gray value threshold.
[0051] In one possible implementation, the cost includes a first sub-cost and a second sub-cost, wherein the first sub-cost is the ratio of the brightness of the mask region in the white image under the preset first exposure to the brightness of the mask region in the black image under the preset first exposure, and the second sub-cost is the difference between the brightness of the mask region in the white image under the preset first exposure and the brightness of the mask region in the black image under the preset first exposure.
[0052] The interval determination module specifically includes:
[0053] The weighted summation submodule is used to perform a weighted summation of the first sub-cost and the second sub-cost under each preset first exposure to obtain the cost under each preset first exposure.
[0054] The function determination submodule is used to determine the response function of each mask based on each preset first exposure and the cost under each preset first exposure.
[0055] The interval determination submodule is used to determine the exposure interval in which the first exposure value corresponding to the maximum value of the response function is located, as the optimal exposure interval corresponding to the mask.
[0056] In one possible implementation, the interval determination submodule includes:
[0057] The acquisition unit acquires the maximum value of the response function, the first exposure value corresponding to the maximum value, and the weight value preset for the mask.
[0058] A calculation unit is used to calculate the product of the weight value and the maximum value as the first function value;
[0059] A determining unit is used to determine the exposure range that allows the response function to be greater than the first function value.
[0060] In one possible implementation, the device further includes:
[0061] The optimal exposure ranges corresponding to each mask are sorted in descending order of their area;
[0062] The exposure determination module is specifically used for:
[0063] If the first exposure value within the optimal exposure range ranked first by area is within the other two optimal exposure ranges, then the first exposure value corresponding to the optimal exposure range ranked first by area is determined as the target exposure.
[0064] If the first exposure value in the optimal exposure interval of the first area ranking is not in the optimal exposure interval of the second area ranking, then the intersection of the optimal exposure interval of the first area ranking and the optimal exposure interval of the second area ranking is calculated to obtain the first exposure interval, and the boundary value in the first exposure interval that is closest to the first exposure value in the optimal exposure interval of the first area ranking is determined as the target exposure.
[0065] If the first exposure value within the optimal exposure range of the first area ranking is within the optimal exposure range of the second area ranking but not within the optimal exposure range of the third area ranking, then the intersection of the optimal exposure range of the first area ranking and the optimal exposure range of the second area ranking is calculated to obtain the first exposure range. The intersection of the first exposure range and the optimal exposure range of the third area ranking is calculated to obtain the second exposure range. The boundary value in the second exposure range that is closest to the first exposure value within the optimal exposure range of the first area ranking is determined as the target exposure.
[0066] If the second exposure interval does not intersect with the third-ranked optimal exposure interval in terms of area, then the boundary value in the second exposure interval that is closest to the third-ranked optimal exposure interval in terms of area is determined as the target exposure.
[0067] A fourth aspect of this application provides an electronic device, including:
[0068] Memory, used to store computer programs;
[0069] The processor, when executing a program stored in memory, implements any of the above-described automatic exposure methods.
[0070] A fifth aspect of this application provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements any of the above-described automatic exposure methods.
[0071] This application also provides a computer program product containing instructions that, when run on a computer, cause the computer to perform any of the automatic exposure methods described above.
[0072] Beneficial effects of the embodiments in this application:
[0073] This application provides an automatic exposure method and a striped structured light camera based on striped structured light. Since each mask is divided according to grayscale value, and the masks do not overlap and their combined form a complete image region, different brightness regions can be processed independently for different masks. Under multiple preset first exposures, black and white images captured by the image acquisition device under each preset first exposure are acquired, and the cost of each mask under each preset first exposure is calculated. Since the cost of each mask under each preset first exposure is positively correlated with the difference in brightness between the mask region in the white image under that first exposure and the mask region in the black image under that preset first exposure, the change in contrast of each mask region with exposure can be quantified by calculating the cost under different preset first exposures. Furthermore, since the optimal exposure range corresponding to each mask satisfies the condition that the cost under that exposure satisfies the high cost condition, that is, in this application, the exposure range that results in higher contrast is determined as the optimal exposure range. Thus, the final target exposure can achieve relatively high contrast for each mask region without overexposure or underexposure, thereby improving the image contrast while ensuring that image details are not lost, improving image quality, and thus improving measurement accuracy. Furthermore, this application can determine the optimal exposure by calculating the cost of each mask under each preset first exposure and calculating the optimal exposure range of each mask based on the cost, without the need for manual setting of exposure parameters, thus improving the ease of use of the structured light stripe camera.
[0074] Of course, implementing any product or method of this application does not necessarily require achieving all of the advantages described above at the same time. Attached Figure Description
[0075] To more clearly illustrate the technical solutions in the embodiments of this application 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 some embodiments of this application. For those skilled in the art, other embodiments can be obtained based on these drawings.
[0076] Figure 1 A schematic diagram of an automatic exposure method based on striped light provided in an embodiment of this application;
[0077] Figure 2 Example diagrams of various masks provided in the embodiments of this application;
[0078] Figure 3 Example graph showing the curve of cost variation with preset first exposure provided for embodiments of this application;
[0079] Figure 4 A schematic diagram of mask division provided for an embodiment of this application;
[0080] Figure 5 A schematic diagram illustrating the statistical determination of grayscale thresholds provided in the embodiments of this application;
[0081] Figure 6 A flowchart for determining the peak value provided in this application embodiment;
[0082] Figure 7 A schematic diagram illustrating the determination of the optimal exposure range provided in an embodiment of this application;
[0083] Figure 8 Example diagram of the optimal exposure range provided in the embodiments of this application;
[0084] Figure 9 A schematic diagram illustrating the target determination process provided in an embodiment of this application;
[0085] Figure 10a A first flowchart for determining target exposure provided in an embodiment of this application;
[0086] Figure 10b A second flowchart for determining target exposure provided in an embodiment of this application;
[0087] Figure 11 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0088] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art based on this application are within the scope of protection of this application.
[0089] First, let's explain the technical terms used in this application:
[0090] Striped structured light: an important three-dimensional topography measurement technique that reconstructs the surface shape of an object by projecting specific light stripe patterns and analyzing their deformation, including but not limited to phase-shifted stripes, Gray code, etc.
[0091] Automatic exposure: a key technology in image processing that can automatically adjust camera parameters according to ambient lighting conditions to obtain images with appropriate brightness.
[0092] Contrast: Indicates the degree of difference between the brightest and darkest areas of an image.
[0093] To achieve automatic exposure, two common approaches are used in related technologies: the first selects the optimal exposure based on the integrity and exposure relationship after 3D depth reconstruction; the second sets a target grayscale based on the grayscale information captured by the 2D camera, and obtains the exposure that captures the target grayscale through different strategies. While the first approach achieves better integrity, it requires multiple exposures to correspond to the depth information, making it unusable in real-time and requiring a long runtime. The runtime is directly proportional to the number of multiple exposures, resulting in poor camera usability. In the second approach, simple grayscale information cannot reflect 3D information, and therefore cannot reconstruct the 3D structure of the scene.
[0094] To improve the ease of use and measurement accuracy of fringe structured light cameras, a first aspect of this application provides an automatic exposure method based on fringe structured light, such as... Figure 1 The diagram shown is a schematic representation of an automatic exposure method based on striped light provided in an embodiment of this application. The method includes the following steps:
[0095] Step S101: Obtain multiple masks divided according to grayscale values;
[0096] Among them, each mask has no overlap and the set of masks constitutes a complete image region;
[0097] Step S102: Under multiple preset first exposures, acquire the black and white images captured by the image acquisition device under each preset first exposure;
[0098] Step S103: For each mask, calculate the cost under each preset first exposure;
[0099] Among them, the cost is positively correlated with the brightness difference, which is the difference between the brightness of the mask area in the white image under the preset first exposure and the brightness of the mask area in the black image under the preset first exposure.
[0100] Step S104: Determine the optimal exposure range for each mask based on the cost of each preset first exposure.
[0101] Among them, any exposure within the optimal exposure range satisfies the following condition: the cost under this exposure satisfies the high cost condition.
[0102] Step S105: Determine the target exposure based on the optimal exposure range corresponding to each mask.
[0103] In this embodiment, since each mask is divided according to grayscale value, and the masks do not overlap and their combined form a complete image region, different brightness regions can be processed independently for different masks. Under multiple preset first exposures, black and white images captured by the image acquisition device under each preset first exposure are obtained, and the cost of each mask under each preset first exposure is calculated. Since the cost of each mask under each preset first exposure is positively correlated with the difference in brightness between the mask region in the white image under that first exposure and the mask region in the black image under that preset first exposure, the change in contrast of each mask region with exposure can be quantified by calculating the cost under different preset first exposures. Furthermore, since the optimal exposure range corresponding to each mask satisfies the condition that the cost under that exposure satisfies the high cost condition, that is, in this application, the exposure range that results in higher contrast is determined as the optimal exposure range. Thus, the final target exposure can achieve relatively high contrast for each mask region without overexposure or underexposure, thereby improving the contrast of the image while ensuring that image details are not lost, improving image quality, and thus improving measurement accuracy. Furthermore, this application can determine the optimal exposure by calculating the cost of each mask under each preset first exposure and calculating the optimal exposure range of each mask based on the cost, without the need for manual setting of exposure parameters, thus improving the ease of use of the structured light stripe camera.
[0104] The following provides a detailed explanation of steps S101 to S105:
[0105] In step S101 above, each mask is a binary mask pre-divided based on the gray values of each pixel in the same image. The gray values of each pixel within the same mask region are the same or similar, for example, the difference between the gray values of each pixel within the same mask region is less than a preset difference threshold. No overlap between masks means that there is no overlap between the mask regions in the image. The combination of masks forming a complete image region means that the mask regions constitute a complete region of the image without any missing pixels.
[0106] For example, assuming the image includes regions 1, 2, and 3, where the grayscale values of all pixels in region 1 are in the range [0, 100], the pixel values of all pixels in region 2 are in the range [101, 200], and the pixel values of all pixels in region 3 are in the range [201, 255], then masks 1, 2, and 3 can be obtained, corresponding to regions 1, 2, and 3 respectively. The specific methods for dividing each mask are described below and will not be repeated here.
[0107] In step S102 above, the number of preset first exposures is not less than two, and the exposure values of different preset first exposures are different. It can be understood that the number of preset first exposures and the exposure values of each preset first exposure can be preset based on actual experience and needs.
[0108] To avoid overexposure or underexposure in the same area in images captured under each preset first exposure, the exposure values of each preset first exposure are distributed as widely as possible. In another possible implementation, the exposure values of each preset first exposure can also be calculated based on the maximum and minimum exposure values. For example, assuming there are 6 preset first exposures, and the exposure value of each preset first exposure is min... exp +n Δ, where Δ = (max exp -min exp The value of n is determined based on practical experience. For example, if n is [2, 5, 10, 25, 50, 100], then the exposure values for the six preset first exposures are: min exp +(max exp -min exp ) / 50、min exp +(max exp -min exp ) / 20、min exp +(max exp -min exp ) / 10、min exp +(max exp -min exp ) / 4、min exp +(max exp -min exp ) / 2、min exp +(max exp -min exp ).
[0109] The black and white images captured by the image acquisition device under each preset first exposure can refer to target projection patterns that simultaneously include black and white projection patterns projected onto the object under test under each preset first exposure. While projecting the target projection pattern, the image acquisition device captures an image of the object under test. The sub-image containing the black projection pattern in the captured image is then designated as the black image under that preset first exposure, and the sub-image containing the white projection pattern in the captured image is designated as the white image under that preset first exposure. The image captured when projecting the black projection pattern is the black image under that preset first exposure, and the image captured when projecting the white projection pattern is the white image under that preset first exposure. The target projection pattern can be a black and white striped pattern, or other projection patterns that simultaneously include black and white projection patterns; this application embodiment does not limit this.
[0110] The black and white images captured by the image acquisition device under each preset first exposure can also refer to projecting a black projection pattern and a white projection pattern onto the object under test under each preset first exposure, and controlling the image acquisition device to capture images of the object under test while projecting the black and white projection patterns respectively. The image captured when projecting the black projection pattern is the black image under that preset first exposure, and the image captured when projecting the white projection pattern is the white image under that preset first exposure. For example, at an exposure value of min... exp +(max exp -min exp When the exposure value is 50, the image captured when projecting a black pattern onto the object under test is the image with the exposure value min. exp +(max exp -min exp The image is a black image at 50°. It is understood that in this case, a black projection pattern refers to a pure black pattern, and a white projection pattern refers to a pure white pattern. For ease of description, the automatic exposure method of this application will be explained below using examples of obtaining black and white images by projecting black and white projection patterns respectively.
[0111] Taking the example of 6 preset first exposures, step S102 yields 6 white images and 6 black images under the preset first exposures. For ease of description, the following text uses 6 preset first exposures as an example, and denotes the 6 black and white images under the preset first exposures as: black image 1 to black image 6, white image 1 to white image 6, and white image n and black image n as the white and black images captured under the nth preset first exposure.
[0112] It is understood that each black image and each white image can be divided into regions based on the acquired mask. For example, assuming the masks acquired in step S101 are a first mask, a second mask, and a third mask, then each white image n and each black image can be divided into three regions using the first mask, the second mask, and the third mask. It is understood that in each white image and each black image, the region corresponding to the same mask has the same position in the image. For example, as... Figure 2 The diagram shown is an example of each mask provided in the embodiments of this application. In each black or white image, region 1 is the first mask region, region 2 is the second mask region, and region 3 is the third mask region. If black images 1 to 6 and white images 1 to 6 are obtained by shooting under 6 preset first exposures, then each image (black image and white image) can be divided into three regions according to the three masks. The positions of the first mask regions in each image are the same, the positions of the second mask regions in each image are the same, and the positions of the third mask regions in each image are the same.
[0113] In step S103 above, calculating the cost for each mask under each preset first exposure means calculating the cost of each mask region in each image under each preset first exposure. Specifically, this can be calculated based on the brightness of each mask region in the black and white images under the preset first exposure. For example, the cost of mask A under the preset first exposure can be represented by the difference in average brightness between the white and black images obtained under the preset first exposure. Alternatively, the cost of mask A under the preset first exposure can be represented by the standard deviation of the brightness of mask A in the white and black images obtained under the preset first exposure. Another method is to perform a weighted fusion of the difference and ratio of the brightness of mask A in the white and black images obtained under the preset first exposure to obtain a fusion difference representing the cost of mask A under the preset first exposure. Other methods can also be used to calculate the difference in brightness of the same mask region in the white and black images; this embodiment does not limit this method.
[0114] It is understandable that the cost of each mask under each preset first exposure is positively correlated with the difference between the brightness of the mask area in the white image under the preset first exposure and the brightness of the mask area in the black image under the preset first exposure. That is, for the same mask area, in the black image and white image obtained under the same preset first exposure, the greater the cost of the mask under the preset first exposure, the greater the difference between the brightness of the mask area in the white image and the brightness of the mask area in the black image.
[0115] In step S104 above, the high-cost condition is preset. Specifically, the high-cost condition is that the cost is greater than a preset cost threshold. The preset cost threshold can be set based on experience, determined based on the cost of each preset first exposure of the mask, or determined based on the maximum cost of each preset first exposure of the mask. This application embodiment does not limit this.
[0116] Based on the cost of each preset first exposure, the optimal exposure range corresponding to each mask is determined. This can be done by sorting the preset first exposures in ascending or descending order for each mask, and then directly determining the exposure range formed by at least x adjacent preset first exposures with costs greater than a preset cost threshold as the optimal exposure range corresponding to that mask. For example, assuming that the preset first exposures are sorted in ascending order of exposure value as exposure 1, exposure 2, exposure 3, and exposure 4, and the costs of mask A under exposure 1 to exposure 4 are cost 1, cost 2, cost 3, and cost 4 respectively, if only cost 2 and cost 3 are greater than the preset cost threshold, then the optimal exposure range is [exposure 2, exposure 3]; if cost 1, cost 2, and cost 3 are greater than the preset cost threshold, then the optimal exposure range is [exposure 1, exposure 3].
[0117] In another possible implementation, for each mask, a curve showing the cost changing with a preset first exposure can be fitted and plotted. Then, the exposure range in the curve where the cost is greater than a preset cost threshold is determined as the optimal exposure range corresponding to that mask. For example, as shown... Figure 3 The figure shown is an example of the curve showing the change of cost with the preset first exposure provided in the embodiment of this application. The preset cost threshold is approximately 133, so the optimal exposure range can be determined as [2.2, 4.4].
[0118] In step S105 above, the target exposure is determined based on the optimal exposure range corresponding to each mask. This can be done by calculating the intersection of the optimal exposure ranges corresponding to each mask and selecting an exposure value from the intersection as the target exposure; or by weighting each optimal exposure range according to the mask area to obtain the target exposure range and selecting an exposure value from the target exposure range as the target exposure; or by other methods to determine the target exposure.
[0119] Understandably, since the optimal exposure ranges determined for different masks may not overlap, the goal is to minimize overexposure or underexposure in the area with the largest mask area. In this case, the target exposure can be determined based on the optimal exposure range corresponding to the mask with the largest area. The specific process for determining the target exposure is described below and will not be repeated here.
[0120] The above text is about Figure 1Steps S101 to S105 have been explained. Taking a mask consisting of three masks as an example, the specific division method of each mask will be explained below. See [link to documentation]. Figure 4 , Figure 4 A schematic diagram of mask division provided for an embodiment of this application includes the following steps:
[0121] Step S201: Acquire an image under a preset second exposure when a white projection pattern is projected;
[0122] Step S202: Perform mask segmentation based on the grayscale values of the image to obtain three masks.
[0123] In step S201, the preset second exposure can be the same as or different from one of the multiple preset first exposures. It is understood that, since the area of overexposed region in the image when projecting a white projection pattern under high exposure is usually larger than the area of overexposed region when projecting a white projection pattern under low exposure, the preset second exposure is usually a low exposure value to reduce the overexposed area. A low exposure value means an exposure value less than a preset exposure threshold, which is set empirically.
[0124] In step S202 above, the three masks are the first mask, the second mask, and the third mask. The gray value of the first mask is not greater than the lower gray value threshold, and the gray value of the third mask is not less than the upper gray value threshold. The upper and lower gray value thresholds can be set in advance based on experience and requirements, or they can be obtained by statistically analyzing the gray values of each pixel in the image obtained in step S201.
[0125] When the upper and lower grayscale thresholds are obtained by statistically analyzing the grayscale values of each pixel in the image, the upper and lower grayscale thresholds can be obtained through histogram statistics, or through other methods. This application does not limit these methods.
[0126] Taking the determination of the upper and lower grayscale thresholds through histogram statistics as an example, the specific statistical process is explained below. Figure 5 , Figure 5 The schematic diagram for obtaining the grayscale threshold through statistics provided in the embodiments of this application includes the following steps:
[0127] Step S501: Obtain the grayscale histogram of the image;
[0128] Step S502: In the grayscale histogram, three peaks are determined in descending order of peak value, and the grayscale values of the three peaks are recorded as the first grayscale value, the second grayscale value, and the third grayscale value in ascending order of grayscale value of the peaks.
[0129] Step S503: The median of the first gray value and the second gray value is used as the lower gray value threshold, and the median of the second gray value and the third gray value is used as the upper gray value threshold.
[0130] For example, suppose that three peaks are determined in step S502: peak 1, peak 2, and peak 3, the gray value at peak 1 is gray value 1, the gray value at peak 2 is gray value 2, and the gray value at peak 3 is gray value 3, and gray value 1 > gray value 2 > gray value 3. Then the median value of gray value 1 and gray value 2 is used as the upper limit threshold of gray value, and the median value of gray value 2 and gray value 3 is used as the lower limit threshold of gray value.
[0131] Specifically, the three mask regions can be determined using the following formula:
[0132]
[0133] in, Indicates the first mask. Indicates the third mask. Indicates the second mask. The grayscale value of a pixel. This is the lower limit threshold for grayscale. This is the upper limit threshold for grayscale.
[0134] In this embodiment, image grayscale values are used for mask segmentation to ensure that different mask regions can reflect the reflectivity of different areas on the object under test. This determines the target exposure to be consistent with the exposure values of more exposure areas, thereby improving image quality. Furthermore, by statistically analyzing the grayscale values of each pixel in the image to determine the upper and lower grayscale thresholds, the grayscale thresholds can be flexibly set according to different image data, making the determined mask more accurate.
[0135] In one possible implementation, since there may be more than three peaks in the histogram, in this case, it can be done by, for example... Figure 6 The method shown identifies three peaks in the histogram.
[0136] After obtaining the histogram, find the peak value in the histogram and determine whether the gray value corresponding to the peak value is 0 or 255. If it is 0 or 255, calculate separately whether the peak value is the maximum value within the preset window. If it is not 0 or 255, determine whether the peak value is greater than the data on the left and right. If the peak value is not greater than the data on the left and right, return to the step of finding the peak value.
[0137] If the peak value is greater than the data on the left and right, determine whether the peak value is the maximum value within the preset window. If not, return to the step of finding the peak value. If so, determine whether the data change trends on the left and right sides of the peak value are opposite. If not, return to the step of finding the peak value. If they are opposite, record the gray value and number corresponding to the current peak value, and determine whether the distance between adjacent peak values is less than the preset distance threshold.
[0138] If the distance between adjacent peaks is not less than the preset peak threshold, then the peak is output; if the distance between adjacent peaks is less than the preset peak threshold, then the adjacent peaks are merged, the merged peak is output as a single peak, and then the search for peaks continues until all peaks in the histogram have been traversed.
[0139] As mentioned above, in this application, the cost of mask A under the preset first exposure can be represented by weighted fusion of the difference and ratio of the brightness of mask A region in the white image and black image obtained under the preset first exposure. In this case, the cost of each mask under each preset first exposure includes a first sub-cost and a second sub-cost. The first sub-cost is the ratio of the brightness of the mask region in the white image under the preset first exposure to the brightness of the mask region in the black image under the preset first exposure, and the second sub-cost is the difference between the brightness of the mask region in the white image under the preset first exposure and the brightness of the mask region in the black image under the preset first exposure.
[0140] In this embodiment, the optimal exposure range corresponding to each mask is determined through the following steps S1041 to S1043:
[0141] Step S1041: The first sub-cost and the second sub-cost under each preset first exposure are weighted and summed to obtain the cost under each preset first exposure;
[0142] Step S1042: For each mask, determine the response function of the mask based on each preset first exposure value and the cost under each preset first exposure.
[0143] Step S1043: Determine the exposure range where the first exposure value corresponding to the maximum value of the response function is located, and use it as the optimal exposure range corresponding to the mask.
[0144] Steps S1041 to S1043 are Figure 1One specific implementation of step S104 in the illustrated embodiment. In step S1041, when performing a weighted summation of the first sub-cost and the second sub-cost under each preset first exposure, the weight values of the first sub-cost and the second sub-cost are preset based on experience. For example, the weight values of both the first sub-cost and the second sub-cost can be set to 0.5, or the weight value of the first sub-cost can be set to 0.6 and the weight value of the second sub-cost can be set to 0.4, or other values can be used. This embodiment of the application does not limit this.
[0145] Specifically, the cost under the preset first exposure can be calculated using the following formula. :
[0146]
[0147] in, This refers to the first sub-cost under the preset first exposure. The second sub-cost is the first exposure under the preset condition.
[0148] Through the above step S1041, the cost of different masks under different preset first exposures can be obtained. For example, the cost of mask A under preset first exposure 1 to preset first exposure 6 is 1 to 6, the cost of mask B under preset first exposure 1 to preset first exposure 6 is 7 to 12, and the cost of mask C under preset first exposure 1 to preset first exposure 6 is 13 to 18.
[0149] In step S1042 above, determining the mask's response function based on each preset first exposure and the cost under each preset first exposure means fitting the mask's response function based on the cost of the mask under each preset first exposure and the preset first exposure, i.e., the function represented by the curve showing the cost changing with the preset first exposure mentioned above. For example, for mask A, the response function 1 of mask A is obtained by fitting (preset first exposure 1, cost 1), (preset first exposure 2, cost 2), (preset first exposure 3, cost 3), (preset first exposure 4, cost 4), (preset first exposure 5, cost 5), and (preset first exposure 6, cost 6). The curve of the obtained response function is shown below. Figure 3 As shown.
[0150] In step S1043 above, after determining the maximum value of the response function and the first exposure value corresponding to the maximum value, the optimal exposure range can be determined based on the first exposure value ±x. Alternatively, the first exposure value corresponding to the maximum value can be used as one boundary of the optimal exposure range, and the first exposure value ±y can be used as the other boundary of the optimal exposure range. Other methods can also be used to determine the optimal exposure range. Here, x and y are preset based on experience and requirements. The values of x and y can be the same or different; this embodiment does not limit this.
[0151] By using the embodiments of this application, the optimal exposure range is automatically determined through the same response function, and the exposure range corresponding to the maximum value is selected as the optimal range to ensure that overexposure or underexposure is not easy in this range, thus preserving the effective information of the image.
[0152] In another possible implementation, it can also be achieved through, for example... Figure 7 The method shown involves determining the optimal exposure range, including the following steps:
[0153] Step S701: Obtain the maximum value of the response function, the first exposure value corresponding to the maximum value, and the weight value pre-set for the mask;
[0154] Step S702: Calculate the product of the weight value and the maximum value, and use it as the first function value;
[0155] Step S703: Determine the exposure range that allows the response function to be greater than the first function value;
[0156] Steps S701 to S703 are a specific implementation of step S1043 described above. The weight values set for different masks can be the same or different. In one possible implementation, the weight values can be set for each mask according to its area; the larger the mask area, the larger the weight value set for it.
[0157] For example, such as Figure 8 The figure shown is an example of the optimal exposure range provided in the embodiment of this application. The first exposure value m corresponding to the maximum value M of the response function curve of mask A (i.e., the curve represented by the thick solid line) is set to a weight value a for mask A. Then, the exposure range (x, y) that makes the response function greater than M×a is determined as the optimal exposure range.
[0158] In one possible implementation, if the preset cost threshold is determined based on the maximum cost of each mask under each preset first exposure, the first function value can also be calculated as the preset cost threshold according to the above steps S701 to S702. The specific calculation process will not be described here.
[0159] By selecting the embodiments of this application, by setting weight values for each mask and using their respective weight values to determine the optimal exposure range of each mask, high-quality imaging of mask areas with higher weights can be achieved, while improving the imaging quality of mask areas with lower weights as much as possible.
[0160] Understandably, since the optimal exposure ranges corresponding to each mask may not overlap, the specific process for determining the target exposure is explained in detail below. (See also...) Figure 9 , Figure 9 A schematic diagram of the target determination process provided for embodiments of this application includes the following steps:
[0161] Step S901: Sort the optimal exposure ranges corresponding to each mask according to the order of their areas from largest to smallest.
[0162] Step S902: If the first exposure value in the optimal exposure interval ranked first by area is in one of the other two optimal exposure intervals, then the first exposure value corresponding to the optimal exposure interval ranked first by area is determined as the target exposure.
[0163] Step S903: If the first exposure value in the optimal exposure interval ranked first by area is not in the optimal exposure interval ranked second by area, then calculate the intersection of the optimal exposure interval ranked first by area and the optimal exposure interval ranked second by area to obtain the first exposure interval, and determine the boundary value in the first exposure interval that is closest to the first exposure value in the optimal exposure interval ranked first by area as the target exposure.
[0164] Step S904: If the first exposure value in the optimal exposure interval ranked first by area is in the optimal exposure interval ranked second by area but not in the optimal exposure interval ranked third by area, then calculate the intersection of the optimal exposure interval ranked first by area and the optimal exposure interval ranked second by area to obtain the first exposure interval. Calculate the intersection of the first exposure interval and the optimal exposure interval ranked third by area to obtain the second exposure interval. Determine the boundary value in the second exposure interval that is closest to the first exposure value in the optimal exposure interval ranked first by area as the target exposure.
[0165] Step S905: If the second exposure interval does not intersect with the third-ranked optimal exposure interval in terms of area, then the boundary value in the second exposure interval that is closest to the third-ranked optimal exposure interval in terms of area is determined as the target exposure.
[0166] The process of determining target exposure is explained below with reference to a flowchart. For example... Figure 10a and Figure 10bThe diagram shows two flowcharts for determining target exposure provided in the embodiments of this application. Assume that the areas of the three masks are r1, r2, and r3 in descending order, and the corresponding optimal exposure ranges are range1, range2, and range3, respectively, with the corresponding first exposure values being best_r1, best_r2, and best_r3.
[0167] like Figure 10a As shown, when best_r1 is in range2 and / or range3, the intersection of range1 and range2 or range3 is calculated. The calculation is based on the intersection range. If the intersection range intersects with another range, the intersection result is calculated, and the exposure value closest to best_r1 in the intersection result is determined as the target exposure. If the intersection range does not intersect with another range, the boundary value closest to the other range in the intersection range is determined, and this boundary value is determined as the target exposure. For example, the intersection range1-2 of range1 and range2 is calculated. If range1-2 intersects with range3, the exposure value closest to best_r1 in the intersection of range1-2 and range3 is determined as the target exposure. If range1-2 does not intersect with range3, the boundary value closest to best_r3 in range1-2 is determined as the target exposure. It can be understood that when best_r1 is in both range2 and range3, best_r1 is determined as the target exposure.
[0168] like Figure 10b As shown, when best_r1 is not in range2 or range3, the intersection of range1 with range2 and range3 is calculated respectively. If range1 intersects with range2 and range3, the exposure value closest to best_r1 in the intersection is determined as the target exposure. If range1 does not intersect with range2 and range3, best_r1 is determined as the target exposure. If range1 intersects with either range2 or range3, the boundary value closest to another range in the single intersection is determined as the target exposure. For example, if range1 only intersects with range3 (range1-3), the exposure value closest to range2 in the intersection range1-3 is determined as the target exposure.
[0169] By using the embodiments of this application, the exposure requirements of large areas are prioritized by sorting by area, and the globally acceptable exposure value is determined by interval intersection operation. This achieves intelligent compromise decision-making when there are conflicts in the requirements of multiple areas. It prioritizes ensuring the best exposure quality of the main area of the image, and in the case of unavoidable conflicts, selects the feasible exposure that is closest to the optimal value of the large area, thereby balancing the requirements of the main and secondary areas in the global exposure optimization.
[0170] Corresponding to the first aspect mentioned above, a second aspect of the embodiments of this application provides a striped light structure camera, the camera including an image acquisition device and a control module;
[0171] An image acquisition device is used to capture black and white images under the control of the control module;
[0172] The control module is used to execute any of the automatic exposure methods described above.
[0173] In this embodiment, since each mask is divided according to grayscale value, and the masks do not overlap and their combined form a complete image area, different brightness areas can be processed independently for different masks. Under multiple preset first exposures, the image acquisition device is controlled to capture black and white projection patterns respectively to obtain black and white images under each preset first exposure. The cost of each mask under each preset first exposure is calculated. Since the cost of each mask under each preset first exposure is positively correlated with the difference in brightness between the mask area in the white image under that first exposure and the mask area in the black image under that preset first exposure, the change in contrast of each mask area with exposure can be quantified by calculating the cost under different preset first exposures. Furthermore, since the optimal exposure range corresponding to each mask satisfies the condition of high cost under that exposure, that is, in this application, the exposure range that results in higher contrast is determined as the optimal exposure range. Thus, the final target exposure can achieve relatively high contrast for each mask area without overexposure or underexposure, thereby improving image contrast while ensuring no loss of image details, improving image quality, and thus improving measurement accuracy. Furthermore, this application can determine the optimal exposure by calculating the cost of each mask under each preset first exposure and calculating the optimal exposure range of each mask based on the cost, without the need for manual setting of exposure parameters, thus improving the ease of use of the structured light stripe camera.
[0174] Corresponding to the first aspect mentioned above, a third aspect of the embodiments of this application provides an automatic exposure apparatus based on striped structured light, the apparatus comprising:
[0175] The mask acquisition module is used to acquire multiple masks divided according to gray values, wherein the masks have no overlap and their combination forms a complete image region;
[0176] The shooting control module is used to acquire black and white images captured by the image acquisition device under each of the preset first exposures under multiple preset first exposures;
[0177] The cost calculation module is used to calculate the cost for each of the masks under each of the preset first exposures, wherein the cost is positively correlated with the brightness difference; the brightness difference is the difference between the brightness of the mask area in the white image under the preset first exposure and the brightness of the mask area in the black image under the preset first exposure.
[0178] The interval determination module is used to determine the optimal exposure interval corresponding to each of the masks based on the cost under each preset first exposure; wherein, any exposure in the optimal exposure interval satisfies the following: the cost under that exposure satisfies the high cost condition;
[0179] The exposure determination module is used to determine the target exposure based on the optimal exposure range corresponding to each of the masks.
[0180] In this embodiment, since each mask is divided according to grayscale value, and the masks do not overlap and their combined form a complete image area, different brightness areas can be processed independently for different masks. Under multiple preset first exposures, the image acquisition device is controlled to capture black and white projection patterns respectively to obtain black and white images under each preset first exposure. The cost of each mask under each preset first exposure is calculated. Since the cost of each mask under each preset first exposure is positively correlated with the difference in brightness between the mask area in the white image under that first exposure and the mask area in the black image under that preset first exposure, the change in contrast of each mask area with exposure can be quantified by calculating the cost under different preset first exposures. Furthermore, since the optimal exposure range corresponding to each mask satisfies the condition of high cost under that exposure, that is, in this application, the exposure range that results in higher contrast is determined as the optimal exposure range. Thus, the final target exposure can achieve relatively high contrast for each mask area without overexposure or underexposure, thereby improving image contrast while ensuring no loss of image details, improving image quality, and thus improving measurement accuracy. Furthermore, this application can determine the optimal exposure by calculating the cost of each mask under each preset first exposure and calculating the optimal exposure range of each mask based on the cost, without the need for manual setting of exposure parameters, thus improving the ease of use of the structured light stripe camera.
[0181] In one possible implementation, the mask includes a first mask, a second mask, and a third mask, each of which is divided in the following manner:
[0182] Acquire an image under a preset second exposure, with a white projection pattern projected;
[0183] Based on the grayscale value of the image, mask segmentation is performed to obtain three masks; wherein, the grayscale value of the first mask is not greater than the lower grayscale threshold, and the grayscale value of the third mask is not less than the upper grayscale threshold.
[0184] In one possible implementation, the upper grayscale threshold and the lower grayscale threshold are obtained as follows:
[0185] The grayscale histogram of the image was obtained statistically.
[0186] In the grayscale histogram, three peaks are determined in descending order of peak value, and the grayscale values of the three peaks are recorded as the first grayscale value, the second grayscale value, and the third grayscale value in ascending order of grayscale value of the peaks.
[0187] The median of the first gray value and the second gray value is used as the lower gray value threshold, and the median of the second gray value and the third gray value is used as the upper gray value threshold.
[0188] In one possible implementation, the cost includes a first sub-cost and a second sub-cost, wherein the first sub-cost is the ratio of the brightness of the mask region in the white image under the preset first exposure to the brightness of the mask region in the black image under the preset first exposure, and the second sub-cost is the difference between the brightness of the mask region in the white image under the preset first exposure and the brightness of the mask region in the black image under the preset first exposure.
[0189] The interval determination module specifically includes:
[0190] The weighted summation submodule is used to perform a weighted summation of the first sub-cost and the second sub-cost under each preset first exposure to obtain the cost under each preset first exposure.
[0191] The function determination submodule is used to determine the response function of each mask based on each preset first exposure and the cost under each preset first exposure.
[0192] The interval determination submodule is used to determine the exposure interval in which the first exposure value corresponding to the maximum value of the response function is located, as the optimal exposure interval corresponding to the mask.
[0193] In one possible implementation, the interval determination submodule includes:
[0194] The acquisition unit acquires the maximum value of the response function, the first exposure value corresponding to the maximum value, and the weight value preset for the mask.
[0195] A calculation unit is used to calculate the product of the weight value and the maximum value as the first function value;
[0196] A determining unit is used to determine the exposure range that allows the response function to be greater than the first function value.
[0197] In one possible implementation, the device further includes:
[0198] The optimal exposure ranges corresponding to each mask are sorted in descending order of their area;
[0199] The exposure determination module is specifically used for:
[0200] If the first exposure value within the optimal exposure range ranked first by area is within the other two optimal exposure ranges, then the first exposure value corresponding to the optimal exposure range ranked first by area is determined as the target exposure.
[0201] If the first exposure value in the optimal exposure interval of the first area ranking is not in the optimal exposure interval of the second area ranking, then the intersection of the optimal exposure interval of the first area ranking and the optimal exposure interval of the second area ranking is calculated to obtain the first exposure interval, and the boundary value in the first exposure interval that is closest to the first exposure value in the optimal exposure interval of the first area ranking is determined as the target exposure.
[0202] If the first exposure value within the optimal exposure range of the first area ranking is within the optimal exposure range of the second area ranking but not within the optimal exposure range of the third area ranking, then the intersection of the optimal exposure range of the first area ranking and the optimal exposure range of the second area ranking is calculated to obtain the first exposure range. The intersection of the first exposure range and the optimal exposure range of the third area ranking is calculated to obtain the second exposure range. The boundary value in the second exposure range that is closest to the first exposure value within the optimal exposure range of the first area ranking is determined as the target exposure.
[0203] If the second exposure interval does not intersect with the third-ranked optimal exposure interval in terms of area, then the boundary value in the second exposure interval that is closest to the third-ranked optimal exposure interval in terms of area is determined as the target exposure.
[0204] This application also provides an electronic device, such as... Figure 11 As shown, it includes:
[0205] Memory 1101 is used to store computer programs;
[0206] When processor 1102 executes the program stored in memory 1101, it performs the following steps:
[0207] Obtain multiple masks divided according to gray values, wherein the masks have no overlap and their combination forms a complete image region;
[0208] Under multiple preset first exposures, the image acquisition device is controlled to capture black projection patterns and white projection patterns respectively, thereby obtaining black images and white images under each preset first exposure;
[0209] For each of the aforementioned masks, a cost is calculated under each of the aforementioned preset first exposures, wherein the cost is positively correlated with the difference between the brightness of the mask region in the white image under the preset first exposure and the brightness of the mask region in the black image under the preset first exposure;
[0210] Based on the cost of each preset first exposure, the optimal exposure range corresponding to each mask is determined; wherein, any exposure in the optimal exposure range satisfies the following condition: the cost of that exposure satisfies the high cost condition.
[0211] The target exposure is determined based on the optimal exposure range corresponding to each of the masks.
[0212] Furthermore, the aforementioned electronic device may also include a communication bus and / or a communication interface, with the processor 1102, the communication interface, and the memory 1101 communicating with each other via the communication bus.
[0213] The communication bus mentioned in the above electronic devices can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This communication bus can be divided into address bus, data bus, control bus, etc. For ease of illustration, only one thick line is used to represent it in the diagram, but this does not mean that there is only one bus or one type of bus.
[0214] The communication interface is used for communication between the aforementioned electronic devices and other devices.
[0215] The memory may include random access memory (RAM) or non-volatile memory (NVM), such as at least one disk storage device. Optionally, the memory may also be at least one storage device located remotely from the aforementioned processor.
[0216] The processors mentioned above can be general-purpose processors, including central processing units (CPUs), network processors (NPs), etc.; they can also be digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.
[0217] In another embodiment provided in this application, a computer-readable storage medium is also provided, which stores a computer program that, when executed by a processor, implements the steps of any of the above-described automatic exposure methods.
[0218] In another embodiment provided in this application, a computer program product containing instructions is also provided, which, when run on a computer, causes the computer to perform any of the automatic exposure methods described above.
[0219] In the above embodiments, implementation can be achieved entirely or partially through software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented entirely or partially in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a solid-state drive (SSD), etc.
[0220] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0221] The various embodiments in this specification are described in a related manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the device and stripe structured light camera embodiments are basically similar to the method embodiments, so the descriptions are relatively simple; relevant parts can be referred to the descriptions of the method embodiments.
[0222] The above description is merely a preferred embodiment of this application and is not intended to limit the scope of protection of this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application are included within the scope of protection of this application.
Claims
1. An automatic exposure method based on striped structured light, characterized in that, The method includes: Obtain multiple masks divided according to gray values, wherein the masks have no overlap and their combination forms a complete image region; Under multiple preset first exposures, acquire black and white images captured by the image acquisition device under each of the preset first exposures; For each of the aforementioned masks, the cost under each of the aforementioned preset first exposures is calculated, wherein the cost is positively correlated with the brightness difference; the brightness difference is the difference between the brightness of the mask region in the white image under the preset first exposure and the brightness of the mask region in the black image under the preset first exposure. Based on the cost of each preset first exposure, the optimal exposure range corresponding to each mask is determined; wherein, any exposure in the optimal exposure range satisfies the following condition: the cost of that exposure satisfies the high cost condition. The target exposure is determined based on the optimal exposure range corresponding to each of the masks.
2. The method according to claim 1, characterized in that, The mask includes a first mask, a second mask, and a third mask, each of which is obtained by dividing the mask in the following manner: Acquire an image under a preset second exposure, with a white projection pattern projected; Based on the grayscale value of the image, mask segmentation is performed to obtain three masks; wherein, the grayscale value of the first mask is not greater than the lower grayscale threshold, and the grayscale value of the third mask is not less than the upper grayscale threshold.
3. The method according to claim 2, characterized in that, The upper and lower grayscale thresholds are obtained as follows: The grayscale histogram of the image was obtained statistically. In the grayscale histogram, three peaks are determined in descending order of peak value, and the grayscale values of the three peaks are recorded as the first grayscale value, the second grayscale value, and the third grayscale value in ascending order of grayscale value of the peaks. The median of the first gray value and the second gray value is used as the lower gray value threshold, and the median of the second gray value and the third gray value is used as the upper gray value threshold.
4. The method according to claim 1, characterized in that, The cost includes a first sub-cost and a second sub-cost. The first sub-cost is the ratio of the brightness of the mask region in the white image under the preset first exposure to the brightness of the mask region in the black image under the preset first exposure. The second sub-cost is the difference between the brightness of the mask region in the white image under the preset first exposure and the brightness of the mask region in the black image under the preset first exposure. The step of determining the optimal exposure range corresponding to each mask based on the cost under each preset first exposure includes: The first sub-cost and the second sub-cost under each preset first exposure are weighted and summed to obtain the cost under each preset first exposure. For each of the aforementioned masks, the response function of the mask is determined based on each of the aforementioned preset first exposures and the costs under each of the aforementioned preset first exposures; The exposure range corresponding to the first exposure value at the maximum value of the response function is determined as the optimal exposure range for the mask.
5. The method according to claim 4, characterized in that, Determining the exposure range corresponding to the maximum value of the response function includes: Obtain the maximum value of the response function, the first exposure value corresponding to the maximum value, and the weight value preset for the mask; Calculate the product of the weight value and the maximum value, and use it as the first function value; Determine the exposure range that allows the response function to be greater than the first function value.
6. The method according to claim 5, characterized in that, The method further includes: The optimal exposure ranges corresponding to each mask are sorted in descending order of their area; Determining the target exposure based on the optimal exposure range corresponding to each of the masks includes: If the first exposure value within the optimal exposure range ranked first by area is within the other two optimal exposure ranges, then the first exposure value corresponding to the optimal exposure range ranked first by area is determined as the target exposure. If the first exposure value in the optimal exposure interval of the first area ranking is not in the optimal exposure interval of the second area ranking, then the intersection of the optimal exposure interval of the first area ranking and the optimal exposure interval of the second area ranking is calculated to obtain the first exposure interval, and the boundary value in the first exposure interval that is closest to the first exposure value in the optimal exposure interval of the first area ranking is determined as the target exposure. If the first exposure value within the optimal exposure range of the first area ranking is within the optimal exposure range of the second area ranking but not within the optimal exposure range of the third area ranking, then the intersection of the optimal exposure range of the first area ranking and the optimal exposure range of the second area ranking is calculated to obtain the first exposure range. The intersection of the first exposure range and the optimal exposure range of the third area ranking is calculated to obtain the second exposure range. The boundary value in the second exposure range that is closest to the first exposure value within the optimal exposure range of the first area ranking is determined as the target exposure. If the second exposure interval does not intersect with the third-ranked optimal exposure interval in terms of area, then the boundary value in the second exposure interval that is closest to the third-ranked optimal exposure interval in terms of area is determined as the target exposure.
7. A striped light structure camera, characterized in that, The camera includes an image acquisition device and a control module; The image acquisition device is used to capture black and white images under the control of the control module; The control module is used to execute the method according to any one of claims 1-6.
8. An automatic exposure device based on striped structured light, characterized in that, The device includes: The mask acquisition module is used to acquire multiple masks divided according to gray values, wherein the masks have no overlap and their combination forms a complete image region; The shooting control module is used to acquire black and white images captured by the image acquisition device under each of the preset first exposures under multiple preset first exposures; The cost calculation module is used to calculate the cost for each of the masks under each of the preset first exposures, wherein the cost is positively correlated with the brightness difference; the brightness difference is the difference between the brightness of the mask area in the white image under the preset first exposure and the brightness of the mask area in the black image under the preset first exposure. The interval determination module is used to determine the optimal exposure interval corresponding to each of the masks based on the cost under each preset first exposure; wherein, any exposure in the optimal exposure interval satisfies the following: the cost under that exposure satisfies the high cost condition; The exposure determination module is used to determine the target exposure based on the optimal exposure range corresponding to each of the masks.
9. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor, when executing a program stored in memory, implements the method of any one of claims 1-6.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the method described in any one of claims 1-6.