A method for acquiring log images

Through the coordinated adjustment of the LED lamp source and the laser emitter, the problem of uneven brightness of the log end surface image is solved, and more accurate measurement and calculation is achieved.

CN115689854BActive Publication Date: 2025-08-08SHENZHEN ZEFENG PHOTOELECTRIC TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211510135.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Priority Date
2022-01-14
Filing Date
2022-11-29
Publication Date
2025-08-08
Estimated Expiration
2042-11-29

AI Technical Summary

Technical Problem

When taking pictures in outdoor environments to obtain the image of the log end face, the uneven image brightness leads to large measurement and calculation errors, affecting the accuracy of the log end face extraction and area calculation.

Method used

The LED light source and the light source of the laser emitter are projected on the end surface of the log at the same time, adjusting the output energy of both to ensure uniform image brightness, and using the image threshold segmentation algorithm to extract the high and low gray areas, adjusting the camera exposure time to obtain a clear log contour image.

Benefits of technology

The brightness of the log end face image is achieved, the measurement and calculation error is reduced, and the accuracy of log end face extraction and area calculation is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115689854B_ABST
    Figure CN115689854B_ABST
Patent Text Reader

Abstract

The present invention relates to a log image acquisition method that simultaneously projects light from an LED light source and a laser transmitter onto a log end face, and simultaneously activates a camera to capture the log image. By adjusting the output energy of the LED light source and the output energy of the laser transmitter, the log end face outline in the log image is clearly displayed, and the brightness of the light source on the log end face is uniform, significantly reducing the difficulty of subsequent log end face extraction and area calculation, and also reducing measurement and calculation errors.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of log image acquisition, and in particular to a log image acquisition method. Background Art

[0002] When taking photos to measure log end faces, cameras are typically equipped with an LED light source to provide illumination. However, since measurements are taken outdoors, affected by variations in sunlight, shadows, and the degree of log surface corrosion, the images captured by the camera can produce images with insufficient brightness (too dark) or excessive brightness (too bright) in different areas of the log end face, resulting in overall brightness differences and localized unevenness. This can negatively impact the subsequent log end face extraction and area calculation, increasing measurement errors.

[0003] Therefore, it is necessary to provide a log image acquisition method to solve the above problems. Summary of the Invention

[0004] The present invention relates to a log image acquisition method. The method simultaneously projects light from an LED light source and a laser transmitter onto a log end face, and simultaneously activates a camera to capture the log image. By adjusting the output energy of the LED light source and the output energy of the laser transmitter, the log end face contour is clearly displayed on the log image, and the brightness of the light source on the log end face is uniform. This significantly reduces the difficulty of subsequent log end face extraction and area calculation, and also reduces measurement and calculation errors. This method addresses the prior art problem of uneven image brightness, which adversely affects log end face extraction and area calculation, increasing measurement and calculation errors.

[0005] To solve the above problems, the present invention provides a log image acquisition method for assisting in obtaining log contours, comprising the following steps:

[0006] S110, the LED light source projects light onto the end face of the log, the camera captures an image of the log based on the projected light source, and generates a target image based on the log image; the area of a low-grayscale region is acquired based on the target image, and the average grayscale value of the low-grayscale region is calculated based on the area of the low-grayscale region;

[0007] S111, obtaining a first lower limit value; when the average grayscale value of the low grayscale area is less than the first lower limit value, increasing the output energy of the LED light source, thereby increasing the grayscale value of the target image, and returning to step S110; until the average grayscale value of the low grayscale area is greater than the first lower limit value;

[0008] S112, obtaining a first upper limit value; when the average grayscale value of the low grayscale area is greater than the second upper limit value, reducing the output energy of the LED light source, thereby reducing the grayscale value of the target image, and returning to step S110; until the average grayscale value of the low grayscale area is less than the first upper limit value;

[0009] S120, the LED light source and the laser emitter simultaneously project light toward the end face of the log based on the adjusted output energy of the LED light source;

[0010] The camera acquires a log image based on a projected light source, generates a target image based on the log image, and acquires an area of the target image, wherein the target image includes all high grayscale points;

[0011] Acquire the area of the high grayscale region based on all the high grayscale points, and calculate the area ratio of the high grayscale region based on the area of the high grayscale region and the area of the target image;

[0012] S121, obtaining a second lower limit value. When the area ratio of the high grayscale region is less than the second lower limit value, increasing the output energy of the laser emitter, thereby increasing the number of the high grayscale points, and returning to step S120; until the area ratio of the high grayscale region is greater than the second lower limit value;

[0013] S122, obtaining a second upper limit value, and when the area ratio of the high grayscale region is greater than the second upper limit value, reducing the output energy of the laser emitter, thereby reducing the number of the high grayscale points, and returning to step S120; until the area ratio of the high grayscale region is less than the second upper limit value; and

[0014] S130, the camera acquires the log image based on the adjusted output energy of the LED light source and the laser emitter.

[0015] Due to the adoption of the above-mentioned log image acquisition method, the present invention has the following beneficial effects compared to the prior art: the present invention relates to a log image acquisition method, wherein the light source of an LED light source and a laser transmitter are simultaneously projected onto the end face of a log, and a camera is synchronously activated to capture the log image. The output energy of the LED light source and the output energy of the laser transmitter are adjusted so that the outline of the log end face on the log image is clearly displayed, and the brightness of the light source on the log end face is uniform, which greatly reduces the difficulty of the next step of log end face extraction and area calculation, and also reduces the error in measurement and calculation, thereby solving the problem in the prior art that uneven image brightness adversely affects log end face extraction and area calculation, thereby increasing the error in measurement and calculation. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments. The drawings described below are only drawings corresponding to some embodiments of the present invention.

[0017] Figure 1 This is a schematic diagram of the installation of the camera, LED light source, and laser transmitter;

[0018] Figure 2 This is a schematic diagram of a laser emitter and an LED light source projecting light onto the end face of a log to be tested and a camera taking a picture;

[0019] Figure 3 1 is a flow chart of an embodiment of a method for acquiring a log image according to the present invention;

[0020] Figure 4 This is a flow chart of an embodiment of adjusting the output energy of an LED light source in a log image acquisition method of the present invention;

[0021] Figure 5 This is a schematic flow chart of an embodiment of adjusting the output energy of a laser transmitter in a log image acquisition method of the present invention;

[0022] Figure 6 A schematic diagram of an embodiment of a log image in which the proportion of high grayscale is too low in a specific embodiment of a log image acquisition method of the present invention;

[0023] Figure 7 for Figure 6 Schematic diagram of a log image with a normal high grayscale area ratio obtained by increasing the laser pulse width of the laser transmitter;

[0024] Figure 8 A schematic diagram of an embodiment of a log image in which the high grayscale area accounts for an excessively large proportion in a specific embodiment of a log image acquisition method of the present invention;

[0025] Figure 9 for Figure 8 Schematic diagram of a log image with a normal high grayscale area ratio obtained by reducing the laser pulse width of the laser transmitter;

[0026] Figure 10 A schematic diagram of an embodiment of a log image in which the high grayscale area accounts for an excessively large proportion in a specific embodiment of a log image acquisition method of the present invention;

[0027] Figure 11 for Figure 10 Schematic diagram of a log image with a normal high grayscale area ratio obtained by reducing the pulse width of the LED light source;

[0028] Figure 12A schematic diagram of an embodiment of a log image in which the grayscale mean value of the low grayscale area is too low in a specific embodiment of a log image acquisition method of the present invention;

[0029] Figure 13 for Figure 12 Schematic diagram of a log image with a normal high grayscale area ratio obtained by increasing the brightness of the LED light source.

[0030] Figure 14 The process of detecting parameters of the log image of the present invention;

[0031] Figure 15 is an example diagram of an initial image in an embodiment of the present invention;

[0032] Figure 16 is an example diagram of a first image that has undergone texture filtering in an embodiment of the present invention;

[0033] Figure 17 This is an example diagram of a second image after adaptive threshold segmentation processing in an embodiment of the present invention;

[0034] Figure 18 This is an example diagram of the third image after morphological opening processing in an embodiment of the present invention;

[0035] Figure 19 This is an example diagram of a candidate target area in an embodiment of the present invention;

[0036] Figure 20 This is an example diagram of a distance transformation image in an embodiment of the present invention;

[0037] Figure 21 This is an example of an image after watershed segmentation processing in an embodiment of the present invention;

[0038] Figure 22 This is an example diagram of a target outline in an embodiment of the present invention;

[0039] Figure 23 This is an example diagram of the long diameter and short diameter in an embodiment of the present invention.

[0040] Figure 24 Schematic diagram of a flow chart of an embodiment of a method for determining a posture of the present invention;

[0041] Figure 25 This is a schematic diagram of the laser projecting a laser line onto the end face of a log, a target object of the present invention, and photographing the same with a camera;

[0042] Figure 26 The present invention is a method for determining the posture using the grayscale centroid method to extract the centerline cross-section division diagram. DETAILED DESCRIPTION

[0043] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without making any creative efforts shall fall within the scope of protection of the present invention.

[0044] The terms "first" and "second" in the present invention are used for descriptive purposes only and should not be understood as indicating or implying relative importance, and should not be used as a limitation on the order of precedence.

[0045] In the figures, structurally similar elements are denoted by the same reference numerals.

[0046] Please refer to Figure 1 、 Figure 2 In this embodiment, the log image acquisition method uses two sets of "cross" laser emitters 11 with a central wavelength of 850nm to project line structured light when measuring the diameter of the log end face 15 based on machine vision. A ring-shaped LED light source 12 (central wavelength 850nm) provides active light illumination, and an industrial camera 13 is used to capture the log image. The camera 13 is positioned in the middle of the trigger 14, and two sets of LED light sources 12 and laser emitters 11 are provided, one at each of the four corners of the trigger 14. The two sets of laser emitters 11 are positioned diagonally, as are the two sets of LED light sources 12, to ensure that the projected light source is evenly distributed on the log end face 15. First, aim the measuring device at the log end face 15, then pull the trigger 14 to trigger the laser emitter 11 and LED light source 12 to light up simultaneously, while simultaneously opening the shutter of the camera 13 to capture the image. After acquiring the image, the percentage of high-grayscale areas (representing the laser pattern) within the target image is calculated. The average grayscale value of the low-grayscale areas (remaining after removing the high-grayscale areas, representing the logs) is then calculated. Grayscale adaptive adjustment ends only when both the percentage of high-grayscale areas and the average grayscale value of low-grayscale areas meet the specified requirements.

[0047] In this embodiment, please refer to Figure 3 , the log image acquisition method includes the following steps:

[0048] S110, an LED light source projects light onto the end face of the log, the camera acquires an image of the log based on the projected light source, and generates a target image based on the log image; the area of a low-grayscale region is acquired based on the target image, and the average grayscale value of the low-grayscale region is calculated based on the area of the low-grayscale region;

[0049] S111, obtaining a first lower limit value; when the average grayscale value of the low grayscale area is less than the first lower limit value, increasing the output energy of the LED light source, thereby increasing the grayscale value of the target image, and returning to step S110; until the average grayscale value of the low grayscale area is greater than the first lower limit value;

[0050] S112, obtaining a first upper limit value; when the average grayscale value of the low grayscale area is greater than the second upper limit value, reducing the output energy of the LED light source, thereby reducing the grayscale value of the target image, and returning to step S110; until the average grayscale value of the low grayscale area is less than the first upper limit value;

[0051] S120, the LED light source and the laser emitter simultaneously project light toward the end face of the log based on the adjusted output energy of the LED light source;

[0052] The camera captures the log image based on the projected light source, generates the target image based on the log image, and obtains the area of the target image. The target image includes all high-grayscale points.

[0053] The area of the high grayscale region is obtained based on all high grayscale points, and the area ratio of the high grayscale region is calculated based on the area of the high grayscale region and the area of the target image;

[0054] S121, obtaining a second lower limit value. When the proportion of the high grayscale area is less than the second lower limit value, increasing the output energy of the laser emitter, thereby increasing the number of high grayscale points, and returning to step S120; until the proportion of the high grayscale area is greater than the second lower limit value;

[0055] S122, obtaining a second upper limit value. When the proportion of the high grayscale area is greater than the second upper limit value, reducing the output energy of the laser emitter, thereby reducing the number of high grayscale points, and returning to step S120; until the proportion of the high grayscale area is less than the second upper limit value; and

[0056] At step S130 , the camera acquires an image of the log based on the output energy of the LED light source and the laser emitter after adjustment.

[0057] The following describes in detail the process of obtaining the log image in this embodiment.

[0058] In step S110, the laser emitter is turned off, and only the light from the LED light source is turned on, so that the light from the LED light source illuminates the end face of the log. At the same time, the camera is aimed at the end face of the log and the shutter is opened to take a photo and record it as the log image. The control system analyzes the log image transmitted by the camera and extracts the high-grayscale points in the log image. The control system then generates a target image based on the distribution position of all high-grayscale points. The target image is set as a circular structure, and all high-grayscale points are located within the target image. Based on the target image, the control system extracts the area of the target image and the area occupied by all high-grayscale points. Then, the area of the grayscale region is calculated to obtain the average grayscale value of the low-grayscale region. The low-grayscale region refers to the area remaining in the target image after removing the high-grayscale region. The average grayscale value of the low-grayscale region is compared with the limit range preset in the control system to ensure that the brightness of the log image captured by the camera is not too dark or too bright.

[0059] The calculation method for calculating the average gray value of the low gray area includes:

[0060] The pixels in the target image can be represented as a two-dimensional array f(i, j) consisting of M rows and N columns, where (i, j) are discrete coordinates, i = 0, 1, 2, ..., M-1, and j = 0, 1, 2, ..., N-1. Let R represent the area occupied by all pixels in the target image, (i, j) represent a pixel in R, and g(i, j) represent the grayscale value of the pixel. The image threshold segmentation algorithm can then be used to obtain the area H of the high grayscale region in the target image:

[0061] H={(i,j)∈R / g(i,j)>T}

[0062] Where H is the area of high grayscale region; T is a certain segmentation threshold.

[0063] Let L represent the area of low grayscale region, then

[0064] L=RH

[0065] The average gray value of the low gray area can be calculated by the following formula:

[0066]

[0067] Where m represents the average gray value of the low gray area.

[0068] Please refer to Figure 4 In this embodiment, the preset grayscale target range is denoted as [G1, G2], where G1 is the first lower limit of the grayscale target range and G2 is the first upper limit of the grayscale target range. The control system adjusts the brightness of the LED light source so that the average grayscale value m of the low-grayscale region of the acquired target image falls within the grayscale target range [G1, G2]. If the average grayscale value m of the low-grayscale region falls within [G1, G2], the log image containing the target image is output. If m falls outside [G1, G2], m is compared with the first lower limit G1 or the first upper limit G2.

[0069] In step S111, when the average grayscale value m in the low-grayscale region is less than the first lower limit G1, indicating that the image light source brightness of the log end face is insufficient, making it difficult to identify the log end face in the log image, the control system generates an adjustment instruction to increase the brightness of the LED light source. By increasing the output energy of the LED light source, the grayscale value of the target image is increased, so that the average grayscale value of the low-grayscale region exceeds the first lower limit G1.

[0070] The following is a detailed description of the method for increasing the output energy of LED light sources.

[0071] The control system first obtains the current light source pulse width P of the LED light sourceled当 , use the preset light source pulse width single adjustment amount ΔP led To increase the current light source pulse width P led当 , thereby increasing the brightness of the LED light source, allowing more output energy to enter the camera within the same exposure time of the camera, which can improve the brightness of the log image. led To adjust the LED light source, you can adjust it in layers to avoid adjusting too much or too little at one time, thus improving the efficiency of adjustment. led调 =P led当 +ΔP led . The adjusted light source pulse width P led调 Set to the current light source pulse width P led当 , then returns to step S110 and repeats the operation until the average grayscale value m of the low grayscale area is greater than the first lower limit value G1.

[0072] When the current light source pulse width P led当 Greater than the maximum pulse width P of the LED light source ledMax , it indicates that the brightness of the LED light source has been adjusted to the maximum value, but the brightness of the image light source of the end face of the log is still insufficient. At this time, the brightness of the image of the end face of the log can be improved by adjusting the exposure time of the camera so that the camera can absorb more output energy of the LED light source. Get the current exposure time t1 of the camera, use the preset exposure time single time adjustment amount Δt to increase the current exposure time, and generate the adjusted exposure time t2. Among them, t2 = t1 + Δt. Set the adjusted exposure time t2 as the current exposure time t1, and return to step S110 until the average grayscale value m of the low grayscale area is greater than the first lower limit value G1.

[0073] In step S112, if the average grayscale value m of the low-grayscale region is greater than the second upper limit G2, indicating that the image light source brightness of the log end face is too bright, making it difficult to identify the log end face in the log image, the control system generates an adjustment instruction to reduce the output power of the LED light source. By reducing the output power of the LED light source, the grayscale value of the target image is reduced, so that the average grayscale value m of the low-grayscale region is less than the first upper limit G2.

[0074] The following is a detailed description of the method for reducing the output energy of LED light sources.

[0075] The control system obtains the current light source pulse width P of the LED light source led当 , use the preset light source pulse width single adjustment amount ΔP led To reduce the current light source pulse width P led当, the brightness of the LED light source can be reduced, and the output energy absorbed by the camera within the same exposure time can be decreased, thereby reducing the brightness on the log image. The pulse width P of the adjusted light source led调 = P led当 - ΔP led . Set the pulse width P of the adjusted light source led调 as the current pulse width P of the light source led当 , and return to step S110. Repeat the operation until the average gray value m in the low gray area is less than the first upper limit value G2.

[0076] Keep reducing the brightness of the LED light source until the current pulse width of the light source is equal to the preset minimum pulse width of the light source. When it is impossible to adjust the light source brightness by reducing the pulse width of the LED light source, the brightness of the light source can be adjusted by adjusting the exposure time of the camera. At this time, it also indicates that the external environment is relatively bright. In this case, the LED light source can be not used. The control system obtains the current exposure time t1 of the camera, and uses the preset single - time adjustment amount Δt of the exposure time to reduce the current exposure time t1, so that the camera reduces the absorption of the output energy of the LED light source, thereby reducing the brightness of the log end face image. Generate the adjusted exposure time t2 through the current exposure time t1, where t2 = t1 + Δt. Set the adjusted exposure time t2 as the current exposure time t1, and return to step S110 until the average gray value m in the low gray area is less than the first upper limit value G2.

[0077] After debugging, the average gray value m in the low gray area is between the first lower limit value G1 and the second lower limit value G2. Briefly speaking, it can be briefly summarized as follows:

[0078] Compare the gray - scale mean value m of the low - gray area of the current image with the upper and lower limits G1, G2 of the gray - scale mean value. If m < G1, increase the pulse width of the LED light source, that is, the new pulse width value of the light source is P led调 = P led当 + ΔP led , until m ∈ [G1, G2]. When P led > P ledMax , if m < G1, at this time, increase the camera exposure time value, that is, the new exposure time is t = t + Δt, until m ∈ [G1, G2]. Similarly, when m > G2, reduce the pulse width of the LED light source, that is, the new pulse width value of the light source is P led调 = P led当 - ΔP led , until m ∈ [G1, G2]. When P led = 0, if m > G2, then reduce the camera exposure time value, that is, the new exposure time is t = t - Δt, until m ∈ [G1, G2].

[0079] At this point, the debugging of the LED light source is completed. The next step is to confirm whether the light source of the laser transmitter meets the requirements.

[0080] In this embodiment, please refer to Figure 5 In step S120, the two sets of laser emitters are positioned so that the structured light rays emitted by them are parallel. The structured light rays emitted by each set of laser emitters form a cross shape, and the lines emitted by the two sets of laser emitters intersect with each other, ensuring that the structured light rays effectively cover the end face of the log to be measured. After the LED light source, laser emitter, and camera are set up, a trigger is pulled to simultaneously illuminate the laser and LED light sources, projecting the light onto the end face of the log. The camera shutter is opened to capture an image. The laser emitters use a preset laser pulse width, the LED light source uses the adjusted pulse width, and the camera exposure time refers to the exposure time used during LED light source debugging. If the camera exposure time was adjusted during LED light source debugging, the camera uses the adjusted exposure time; if not, the preset exposure time is used for image capture. The camera transmits the captured log image to the control system, which analyzes it and extracts all high-grayscale points in the log image. Then, a target image is generated based on all the high-grayscale points, and the area of the target image is obtained. The target image includes all the high-grayscale points. The high-grayscale area H is calculated based on all the high-grayscale points. The high-grayscale area ratio δ is calculated based on the high-grayscale area H and the area of the target image.

[0081] The calculation method of the high grayscale area ratio δ is as follows:

[0082] Let R represent the area occupied by all pixels in the target image, (i, j) represent a pixel in R, and g(i, j) represent the grayscale value of the pixel; then the area of the high grayscale region in the target image can be obtained by the image threshold segmentation algorithm:

[0083] H={(i,j)∈R / g(i,j)>T}

[0084] Where H is the area of high grayscale region; T is a certain segmentation threshold; then the areas of R and H can be expressed as:

[0085]

[0086] Then the area ratio of high grayscale area in the target image is:

[0087]

[0088] Where δ represents the area ratio of high grayscale area in the target image.

[0089] In this embodiment, the preset range of the high grayscale area ratio δ in the target image is recorded as [δ1, δ2], where δ1 is the second lower limit of the high grayscale ratio of the target image, and δ2 is the second upper limit of the high grayscale ratio of the target image. One of the goals of grayscale adaptive adjustment is to make the high grayscale value ratio δ∈[δ1,δ2] in the target image. The control system needs to adjust the light source brightness of the laser transmitter so that the high grayscale area ratio δ of the acquired target image is within the grayscale target range [δ1,δ2]. When the high grayscale area ratio δ is within [δ1,δ2], the log image containing the target image is output. If δ is outside [δ1,δ2], δ is compared with the second lower limit δ1 or the second upper limit δ2.

[0090] In step S121, if the high-grayscale area ratio δ is less than the second lower limit δ1, this indicates that the laser emitter's light source brightness is insufficient, and the high-grayscale area ratio is too small. The captured log image will adversely affect the subsequent log end face extraction and area calculation, increasing measurement errors. Therefore, it is necessary to increase the laser emitter's output energy to ensure that the camera absorbs more output energy within the same exposure time while maintaining the same LED light source brightness. This will increase the number of high-grayscale points in the log image and ensure that the high-grayscale area ratio δ exceeds the second lower limit δ1.

[0091] The following is a detailed description of the method for increasing the output energy of the laser transmitter.

[0092] The control system first obtains the laser pulse width P of the current laser transmitter laser当 , use the preset laser pulse width single adjustment amount ΔP laser To increase the current laser pulse width P laser当 , thereby increasing the brightness of the light source emitted by the laser emitter, allowing the camera to absorb more output energy of the laser emitter within the same exposure time, increasing the number of high grayscale points, and thus increasing the proportion of high grayscale area. The adjusted laser pulse width is P laser调 =P laser当 +ΔP laser The adjusted laser pulse width P laser调 Set to the current laser pulse width P laser当 , and returns to step S120. Repeat the adjustment until the high grayscale area ratio δ is greater than the second lower limit δ1.

[0093] The brightness of the laser emitter's light source is continuously increased until the current laser pulse width is greater than the maximum pulse width of the laser emitter, and the high grayscale area ratio δ is still less than the second lower limit δ1. This indicates that the brightness of the laser emitter's light source has been adjusted to the maximum value, but the number of high grayscale points on the log image is still insufficient. At this time, the number of high grayscale points on the log image can be increased by adjusting the camera's exposure time, so that the camera can absorb more of the laser emitter's output energy to increase the number of high grayscale points. The control system obtains the camera's current exposure time t1, uses the preset exposure time single time adjustment amount Δt to increase the current exposure time t1, and generates an adjusted exposure time t2. Wherein, t2 = t1 + Δt. The adjusted exposure time t2 is set as the current exposure time t1, and the process returns to step S120. Repeat the adjustment until the high grayscale area ratio δ is greater than the second lower limit δ1.

[0094] In step S121, if the high-grayscale area ratio δ exceeds the second upper limit δ2, indicating that there are too many high-grayscale points and their area is too large, the two cross-shaped lines formed by the laser light source on the log image will be unclear, affecting the subsequent extraction of the log end face contour and area calculation. The control system then generates an adjustment instruction to reduce the output energy of the laser emitter. By reducing the output energy of the laser emitter, the number of high-grayscale points is reduced, and the high-grayscale area ratio δ is reduced to less than the second upper limit δ2.

[0095] The following is a detailed description of the method for reducing the output energy of the laser transmitter.

[0096] First, the laser pulse width of the laser transmitter is adjusted. The control system obtains the current laser pulse width P of the laser transmitter. laser当 , use the preset laser pulse width single adjustment amount ΔP laser To reduce the current laser pulse width P laser当 , thereby reducing the brightness of the light source emitted by the laser emitter, so that the camera absorbs less output energy of the laser emitter within the same exposure time, reduces the number of high grayscale points, and thus reduces the proportion of high grayscale area. The adjusted laser pulse width is P laser调 =P laser当 -ΔP laser The adjusted laser pulse width P laser调 Set to the current laser pulse width P laser当 , and returns to step S120. Repeat the adjustment until the high grayscale area ratio δ is less than the second upper limit δ2.

[0097] The laser pulse width of the laser transmitter is continuously reduced until the current laser pulse width equals the preset minimum laser pulse width. However, if the high grayscale area ratio δ exceeds the second upper limit δ2, the brightness of the laser transmitter light source is still too bright. In this case, the brightness of the light source can be adjusted by adjusting the camera exposure time. The control system obtains the current camera exposure time t1 and uses the preset exposure time adjustment value Δt to reduce the current exposure time t1, causing the camera to absorb less output energy from the laser transmitter, thereby reducing the brightness of the log end image. The adjusted exposure time t2 is generated based on the current exposure time t1, where t2 = t1 - Δt. The adjusted exposure time t2 is set as the current exposure time t1, and the process returns to step S110 until the high grayscale area ratio δ is less than the second upper limit δ2. At this point, the adjusted exposure time t2 should satisfy the conditions that the low grayscale area average grayscale value m is between the first lower limit G1 and the second lower limit G2, and the high grayscale area ratio δ is between the second lower limit δ1 and the second upper limit δ2.

[0098] In short, the method for adjusting the output energy of the laser transmitter can be briefly summarized as follows:

[0099] Calculate the value of δ and compare it with the upper and lower limits δ1, δ2. If δ<δ1, increase the laser pulse width of the laser transmitter, that is, the new laser pulse width is P laser调 =P laser当 +ΔP laser , until δ∈[δ1,δ2]. When P laser >P laserMax When δ<δ1, increase the camera exposure time value, that is, the new exposure time is t2=t1+Δt, until δ∈[δ1,δ2]. When δ>δ2, reduce the laser pulse width, that is, the new laser pulse width is P laser调 =P laser当 -ΔP laser , until δ∈[δ1,δ2]. When P laser =0, if δ>δ2, the camera exposure time value is reduced, that is, the new exposure time is t2=t1-Δt, until δ∈[δ1,δ2].

[0100] At this point, the debugging of the laser transmitter is completed.

[0101] The control system replaces the adjusted parameters with the current ones. Specifically, the LED light source and the laser emitter simultaneously project light onto the log end face based on the adjusted light source pulse width, and the laser emitter and the laser emitter simultaneously project light onto the log end face based on the adjusted laser pulse width. The camera captures an image of the log end face based on the adjusted exposure time and transmits the captured image to the control system for the next step. If any of these three parameters do not require adjustment, the original settings are used directly. Furthermore, after acquiring a log image, the adjusted parameters can be used directly on the next log, greatly improving operation efficiency.

[0102] Adjusting the camera's exposure time during laser light adjustment can affect the LED light source. Overadjusting the camera's exposure time may require re-adjusting the LED light source to ensure the camera's exposure time meets the requirements of both the LED light source and the laser light source. Therefore, to minimize this issue, reduce repeated adjustments, and improve adjustment efficiency, a step S100 can be added before step S110. This involves roughly adjusting the laser emitter before adjusting the LED light source, narrowing the range of precise adjustments required later. After a rough adjustment of the laser emitter, the LED light source can be adjusted. When fine-tuning the laser emitter, the required adjustment range is significantly reduced, minimizing the impact on the LED light source. Even after adjusting the LED light source, the laser emitter can meet requirements without requiring fine-tuning.

[0103] In this embodiment, a range [δ3, δ4] is preset such that the high-grayscale area ratio δ lies between a third lower limit δ3 and a third upper limit δ4. The range [δ3, δ4] is greater than the range [δ1, δ2], i.e., δ3 < δ1 and δ4 > δ2. Extensive experiments have shown that the third lower limit δ3 can be set between 1 / 3*δ1 and 1 / 2*δ1, and the third upper limit δ4 can be set between 1.5*δ2 and 2*δ2. This significantly reduces the number of adjustments required and minimizes the impact on the LED light source. This also reduces the adjustment time required for precise adjustment of the laser emitter and improves adjustment efficiency. The detailed working principle of this step can be found in the aforementioned sections related to steps S120, S121, and S122. When the high-grayscale area ratio δ lies between the third lower limit δ3 and the third upper limit δ4, the output energy of the LED light source is adjusted so that the average grayscale value m of the low-grayscale area of the acquired target image falls within the grayscale target range [G1, G2]. The parameters subsequently used (exposure time of the camera, pulse width of the LED light source, and pulse width of the laser transmitter) are all adjusted based on the corresponding parameters after the rough adjustment.

[0104] The specific working principle of the log image acquisition method of the present invention is described below through a specific embodiment.

[0105] The following figure shows a series of grayscale adaptive adjustment results. The circular area represents the target image, and the darker areas represent high grayscale areas. Through the above operations, we can calculate the values of δ and m, respectively. By adjusting the LED light source pulse width, the laser transmitter pulse width, and the camera exposure time, we can obtain the target image that meets the requirements.

[0106] in Figure 6 This is a log image with a low percentage of high grayscale. As can be seen in the figure, there are almost no high grayscale points. The number of high grayscale points in the log image needs to be increased. The contour line of the log end face is relatively clear, indicating that the brightness of the LED light source meets the requirements. Therefore, by increasing the laser pulse width of the laser transmitter, the following can be obtained: Figure 7 The high grayscale area shown is the percentage of the normal log image.

[0107] in Figure 8 This is a log image with a high proportion of high grayscale areas. As can be seen in the figure, the outline of the log end face is relatively clear, indicating that the brightness of the LED light source meets the requirements; the two cross-shaped lines projected by the laser emitter on the log image are relatively thick, which means that there are too many high grayscale points. The number of high grayscale points in the log image needs to be reduced. Therefore, by reducing the laser pulse width of the laser emitter, the following can be obtained: Figure 9 The high grayscale area shown is the percentage of the normal log image.

[0108] in Figure 10 This is a log image with an excessively high proportion of high grayscale areas. As can be seen in the figure, the end of the log and the background behind it are both displayed, making it difficult to distinguish the outline of the end of the log, indicating that the brightness of the LED light source is too bright; the darker part accounts for a large proportion, indicating that there are too many high-grayscale points. The two cross-shaped lines projected by the laser transmitter on the log image are relatively clear, indicating that the excessive brightness of the LED light source causes an excessive number of high-grayscale points in the target image. It is necessary to reduce the number of high-grayscale points in the log image and the brightness of the light source on the end of the log. Therefore, by reducing the light source pulse width of the LED light source, the following can be obtained: Figure 11 The high grayscale area shown is the percentage of the normal log image.

[0109] in Figure 12This is a log image with a low grayscale mean in the low grayscale area. As can be seen in the figure, the insufficient brightness of the log end makes it impossible to identify the outline of the log end, indicating that the light source brightness of the LED light source is insufficient. The two cross-shaped lines projected by the laser light source on the log image are relatively uniform and clear, indicating that the light source brightness of the laser light source meets the requirements and the light source brightness of the LED light source needs to be increased. Therefore, by increasing the light source pulse width of the LED light source, the following can be obtained: Figure 13 The high grayscale area shown is the percentage of the normal log image.

[0110] This completes the process of acquiring a log image using a log image acquisition method of this specific embodiment.

[0111] After acquiring the log image, it is necessary to calculate the parameters of the log image and the pose of the log end face corresponding to the log image based on the acquired log image.

[0112] Specifically, the following steps are performed to obtain the parameters of the log image (the gauge diameter and the gauge diameter level of the log image).

[0113] Please refer to Figure 14 , Figure 14 This is the process of detecting parameters of the log image of the present invention. The detection process includes:

[0114] Step S201, capturing an initial image of a target object under illumination by a preset light source;

[0115] Step S202, performing texture filtering on the initial image to obtain a first image;

[0116] Step S203, performing adaptive threshold segmentation processing on the first image to obtain a second image;

[0117] Step S204, processing the second image based on a morphological opening algorithm to obtain a third image;

[0118] Step S205, extracting a candidate target area of the third image;

[0119] Step S206, performing watershed segmentation on the candidate target area to obtain partitions of the candidate target area;

[0120] Step S207, extracting the target contour of the target object from the candidate target area partitions;

[0121] Step S208, calculating the fitting equation of the target contour;

[0122] Step S209: Calculate target parameters of the target object based on the fitting equation.

[0123] In step S202, a two-dimensional convolution kernel template is generated based on the product of the one-dimensional convolution kernel and its transposed one-dimensional convolution kernel in the Laws texture energy method;

[0124] The initial image is filtered based on a filtering formula to obtain the first image, where the filtering formula is:

[0125]

[0126] Wherein, G(i,j) is the first image, K(i,j) is the two-dimensional convolution kernel template, F(i,j) is the initial image, and a is the convolution template size.

[0127] Here, a correction formula can also be used to filter the initial image to obtain the first image; the correction formula is:

[0128]

[0129] G'(i,j) is the corrected first image.

[0130] In step S204,

[0131] Performing corrosion processing on the second image based on the corrosion formula to obtain a second corrosion image;

[0132] Performing expansion processing on the second eroded image based on the expansion formula to obtain a third image;

[0133] The corrosion formula is:

[0134] g1Θs=min{g(i+m,j+n)-b(m,n)|(i+m,j+n)∈D g ,(m,n)∈D s};

[0135] The expansion formula is:

[0136]

[0137] Among them, g1(i,j) is the second image of the input image, g2(i,j) is the second eroded image of the input image, s(m,n) is the structural element, Dg and Ds represent the domains of the input image and the structural element, respectively.

[0138] In step S205, a connected component labeling operation is performed on the third image;

[0139] Calculate the area of each connected domain. The calculation formula for the area of the connected domain is:

[0140]

[0141] Wherein, Ri is the i-th connected domain in the third image, (r, c) is the coordinate, and Ai is the area of the i-th connected domain;

[0142] The candidate target region is determined based on the connected domain with the largest area.

[0143] In step S206, distance transformation processing is performed on the candidate target area based on a distance transformation formula to obtain a distance transformation image; the distance transformation formula is:

[0144]

[0145] Where dist(p,q) is the distance calculation function, O represents the candidate target area, B represents the background area, p and q are points in the candidate target area and the background area respectively;

[0146] Perform watershed segmentation on the distance transform image to obtain candidate target region partitions.

[0147] In step S208, the ellipse equation is set:

[0148] ax 2 +bxy+cy 2 +dx+ey+f=0

[0149] st4ac-b 2 >0

[0150] Where a, b, c, d, e, and f are equation parameters; x and y are the coordinates of the target area partition;

[0151] Let M = [a, b, c, d, e, f], X = [x 2 ,xy,y 2 ,x,y,1] T , then the ellipse fitting

[0152] The least squares optimization objective function is:

[0153] min||MX|| 2 =MXX T M T

[0154] sqM T >0

[0155] in,

[0156]

[0157] Solve the optimal solution M of the objective function based on the penalty function * =[a,b,c,d,e,f], determine the fitting equation.

[0158] In step S209, the center coordinates (x0, y0) are determined based on the fitting equation;

[0159] The semi-major axis r1 is calculated based on the fitting equation and the semi-major axis calculation formula; the semi-major axis calculation formula is:

[0160]

[0161] The minor semi-axis r2 is calculated based on the fitting equation and the minor semi-axis calculation formula, and the minor semi-axis calculation formula is:

[0162]

[0163] Determining a major axis and a minor axis based on the major semi-axis and the minor semi-axis, respectively;

[0164] determining a ruler diameter based on the major diameter and the minor diameter;

[0165] A gauge diameter grade is determined based on the gauge diameter.

[0166] The following describes in detail the process of detecting parameters of the log image of the present invention. The detection process includes:

[0167] Step S301: Control the preset light source to turn on.

[0168] The preset light source can be an LED ring light source, which can be pre-set in an integrated device that applies the parameter detection method of the present invention, or it can be independently set at a set position to form a detection system with other related devices such as a processing device, and communicate through wired or wireless means. The preset light source is controlled to be turned on or off by a controller. In some embodiments, the preset light source can be turned on based on a start detection instruction triggered by the user, or it can be automatically controlled to turn on after the device automatically detects and identifies the end face of the log. During the detection process, the end face of the log is placed within the irradiation range of the preset light source.

[0169] Step S302: capturing an initial image of the target object under the illumination of the preset light source.

[0170] like Figure 15 As shown, Figure 15 The following is an example of an initial image in an embodiment of the present invention. An initial image of the log end face under a preset light source can be captured using a preset image capture device, such as an industrial camera. The industrial camera can be installed within the aforementioned integrated device or independently at a predetermined location. In some embodiments, the image capture instruction can be automatically triggered after the light source is turned on, or image capture can be performed based on an image capture instruction manually triggered by the user. The initial image refers to the original, unprocessed image captured by the industrial camera.

[0171] Step S303: Perform texture filtering on the initial image to obtain a first image.

[0172] In order to highlight the contrast between the target area and the background area, it is necessary to first perform texture filtering on the initial image to obtain a first image with high contrast.

[0173] Step S303 includes:

[0174] Step S3031: Generate a two-dimensional convolution kernel template based on the product of the one-dimensional convolution kernel and its transposed one-dimensional convolution kernel in the Laws texture energy method.

[0175] Since the texture features of the log end area are more obvious, a filtering algorithm based on the Laws texture energy method can be used. The Laws texture method specifies seven one-dimensional convolution kernels, namely:

[0176] L = [1 6 15 20 15 6 1]

[0177] E=[-1 -4-5 0 5 4 1]

[0178] S=[-1 -2 1 4 1 -2-1]

[0179] W=[-1 0 3 0 -3 0 1]

[0180] R=[1 -2-1 4 -1-2 1]

[0181] U=[1 -4 5 0 -5 4 -1]

[0182] O=[-1 6 -15 20 -15 6 -1]

[0183] The above seven one-dimensional convolution kernels are used to extract the grayscale features, edge features, point features, ripple features, wave features, and oscillation features of the texture image respectively. By transposing one of the one-dimensional convolution kernels and multiplying it with the one-dimensional convolution kernel, a two-dimensional convolution template can be obtained. Through testing, it was found that the two-dimensional grayscale convolution template generated by the one-dimensional grayscale convolution kernel can significantly improve the grayscale value and texture features of the log area. The two-dimensional grayscale convolution template is generated by the following formula:

[0184]

[0185] Step S3032: Filter the initial image based on a filtering formula to obtain the first image. The filtering formula is:

[0186]

[0187] Among them, G(i,j) is the first image, K(i,j) is the two-dimensional convolution kernel template, F(i,j) is the initial image, a is the convolution template size, and p and q are convolution position parameters.

[0188] Specifically, based on the above steps, after obtaining the two-dimensional grayscale convolution template, the two-dimensional grayscale convolution template and the initial image are substituted into the above filtering formula for processing to obtain a first image processed by texture filtering. The filtering formula and the physical meaning of its parameters are as described above and will not be repeated here.

[0189] In this method, a two-dimensional convolution kernel template is generated by multiplying a one-dimensional convolution kernel and its transposed one-dimensional convolution kernel using the Laws texture energy method. The initial image is filtered using a filtering formula to obtain the first image. Using the Laws texture energy method for filtering better reflects the characteristics of the log end faces. The resulting first image, after texture filtering, significantly improves the grayscale values and texture features of the log region, and enhances the contrast between the target region and the background.

[0190] In some embodiments, in order to avoid excessive grayscale values in certain areas of the image (for an 8-bit grayscale image, the maximum grayscale value is 255), it is necessary to correct the grayscale values of the filtered image, or to correct the original filtering formula and use the corrected filtering formula for filtering.

[0191] Step S3032 may include:

[0192] The filtering formula is corrected based on the correction factor σ to obtain a corrected formula.

[0193] The initial image is filtered based on the correction formula to obtain the first image. The correction formula is:

[0194]

[0195] G'(i,j) is the corrected first image.

[0196] Among them, the correction factor σ is a grayscale value correction factor, which can be obtained in advance through experiments or tests, and the correction formula after the correction factor is directly obtained when performing texture filtering for filtering. For the end face of the log, the correction factor σ generally takes a value of 3 to 7. In the specific implementation process, the correction formula as described above can be used as a filtering formula and pre-stored in a set position. When filtering is performed, the formula is read for filtering processing to obtain the corrected first image. When executing step S304, the corrected first image is processed. Among them, the first image after texture filtering is as follows Figure 16 As shown, Figure 16This is an example diagram of a first image that has undergone texture filtering in an embodiment of the present invention.

[0197] It can be understood that the texture filtering method of the present invention is not limited to the Laws texture energy method. In some embodiments, texture filtering can also be performed by methods such as histogram analysis of image texture, autocorrelation function method of texture analysis, and gray-level co-occurrence matrix analysis. The above filtering methods are all within the protection scope of the present invention.

[0198] Step S304: performing adaptive threshold segmentation processing on the first image to obtain a second image.

[0199] Specifically, in some embodiments, the threshold of each pixel is determined by a neighborhood window centered on itself, and the median, mean, or Gaussian convolution is used as the threshold, or a constant value is added thereto to determine the adaptive threshold. Then, based on the adaptive preset determined by the method, the first image after texture filtering is segmented to obtain a segmented binary image. The second image after adaptive threshold segmentation is as follows: Figure 17 As shown, Figure 17 This is an example diagram of the second image after adaptive threshold segmentation processing in an embodiment of the present invention.

[0200] Step S305: Process the second image based on a morphological opening algorithm to obtain a third image. This may include:

[0201] Step S3051: performing corrosion processing on the second image based on the corrosion formula to obtain a second corrosion image.

[0202] Step S3052: Perform dilation processing on the second eroded image based on a dilation formula to obtain the third image.

[0203] The corrosion formula is:

[0204] g1Θs=min{g(i+m,j+n)-b(m,n)|(i+m,j+n)∈D g ,(m,n)∈D s};

[0205] The expansion formula is:

[0206] g2⊕s=min{g(i+m,j+n)-b(m,n)|(i+m,j+n)∈D g ,(m,n)∈D s};

[0207] Where g1(i,j) is the second image of the input image; g2(i,j) is the second eroded image of the input image; i and j are the image pixel position coordinates; s(m,n) is the structure element, and m and n are the size parameters of the structure element; Dg and Ds represent the domains of the input image and the structure element, respectively.

[0208] Specifically, there are many isolated small areas, burrs and other noises around the target area in the binary image (i.e., the second image) processed by the above steps, and the morphological opening operation can effectively remove these noise interferences. As a secondary operation of the corrosion operation and the dilation operation, the morphological opening operation first uses the corrosion formula to perform an corrosion operation on the second image to obtain a second corrosion image. The second corrosion image in the embodiment of the present invention refers to the image after the corrosion operation, that is, the result of g1Θs, that is, g2. Then, the above expansion formula is used to perform an expansion operation on the second corrosion image to obtain a third image, that is, the result of g2⊕s, that is, the result of g1Θs⊕s. Among them, the third image obtained after the morphological opening operation is as follows: Figure 18 As shown, Figure 18 This is an example diagram of the third image after morphological opening processing in an embodiment of the present invention.

[0209] In the above parameter detection method, the second image is corroded using an erosion formula to obtain a second corroded image, and the second corroded image is dilated using a dilation formula to obtain the third image. The morphological opening operation better reflects the actual characteristics of the log end face, effectively removing small areas of interest, burrs, and other noise, resulting in a cleaner image of the log end face, the third image.

[0210] It can be understood that in some embodiments, the morphological opening operation can also be combined with other types of morphological operations to process the image, such as morphological closing operation or morphological gradient, etc., and a variety of operations including morphological opening operation can be used to process the second image according to the type of target object and actual needs to obtain the third image.

[0211] Step S306: extracting candidate target areas from the third image. This may include:

[0212] Step S3061: Perform a connected component labeling operation on the third image.

[0213] In some embodiments, a direct scanning marking algorithm can be used to mark continuous areas with the same mark, such as a four-neighborhood marking algorithm and an eight-neighborhood marking algorithm. Taking the four-neighborhood marking algorithm as an example, during the marking process, it is determined whether there is a point at the far left or at the top of the four neighborhoods of a point. If there is no point at all, it indicates the beginning of a new area. If there is a point at the far left and no point at the top of the four neighborhoods of this point, then this point is marked as the value of the far left point; if there is no point at the far left and a point at the top of the four neighborhoods of this point, then this point is marked as the value of the top point. If there is a point at the far left and a point at the top of the four neighborhoods of this point, then this point is marked as the smallest marked point between the two, and the large mark is modified to a small mark.

[0214] In some embodiments, a fast algorithm for labeling connected domains of binary images can also be used for labeling. Before the labeling algorithm is performed, an independent image label cache and connectivity relationship array are opened up by hardware. Then, during the acquisition and transmission of the video stream, the image is scanned pixel by pixel in a pipeline manner in the order of video transmission. Then, the neighborhood of each pixel is checked for connectivity and the equivalent label relationship is merged in the counterclockwise and horizontal directions respectively. The detected results are used to update the label equivalent array and the label cache. After the acquisition and transmission of a frame of image is completed, the preliminary labeling result of the image and the connectivity relationship between the preliminary labels are obtained. Finally, the labels of the connectivity relationship array are merged from small to large according to the label transmission process. The merged connectivity relationship array is used to replace the labels in the image label cache. The replaced image is the final labeling result, and the connected domain is assigned a unique continuous natural number according to the scanning order.

[0215] It is understood that the above-mentioned connected domain marking method is only used for illustration and is not intended to limit the connected domain marking method of the present invention. The modification method of the connected domain marking based on the concept of the present invention is within the protection scope of the present invention.

[0216] Step S3062: Calculate the area of each connected domain. Specifically, the calculation formula for the area of the connected domain is:

[0217]

[0218] Where Ri is the i-th connected domain in the third image, (r, c) are the coordinates, and Ai is the area of the i-th connected domain. (r, c) can be point or pixel coordinates. When calculating the area of a connected domain, a unit area is counted for each point or pixel. The area of a connected domain is obtained by traversing all points in the connected domain. The above operation is performed for each connected domain to obtain the area of each connected domain.

[0219] Step S3063: Determine the candidate target region based on the connected domain with the largest area.

[0220] After obtaining the areas of each connected domain, the areas of each connected domain are compared to determine the connected domain with the largest area. This connected domain with the largest area is used as the candidate target region. The candidate target region refers to the further refined region containing the log end face, from which the corresponding region of the log end face can be extracted. Feature selection based on the largest area is performed, and the following is obtained:

[0221] Obj=max(Ai),i=1,2,...,n

[0222] Where Obj is the target area after feature selection, and n represents the number of connected domains in the binary image. Figure 19 As shown, Figure 19 is an example diagram of a candidate target area in an embodiment of the present invention. Figure 19 Shown are the results of target selection based on the largest area, i.e., the candidate target area of the log end face.

[0223] In the above parameter detection method, a connected domain labeling operation is performed on the third image; the area of each connected domain is calculated; and the candidate target region is determined based on the connected domain with the largest area. By the above method, the candidate target region can be extracted in a simple and accurate manner.

[0224] It is understood that the above-described method for extracting candidate target regions is provided for illustrative purposes only and is not intended to limit the present invention. In some embodiments, candidate target regions may also be extracted through machine learning. Specifically, a sufficient number of log end face contour images may be collected in advance, and the log end face contour images may be used as input to a neural network model. Pre-labeled recognition results may be used as outputs of the neural network model to train a candidate target region contour recognition model. The contour images of each connected domain may then be input into the trained recognition model for processing to identify candidate target regions.

[0225] In some embodiments, the contour features of the log end faces can also be pre-extracted through a feature extraction algorithm. When extracting candidate target areas, the contour features of each connected domain are compared with the extracted contour features, and the connected domain with the greatest similarity is used as the candidate target area.

[0226] Step S307: performing watershed segmentation on the candidate target area to obtain partitions of the candidate target area.

[0227] After the candidate target area is extracted, there are adhesion parts in the candidate target area of the log end face, such as Figure 19As shown in the figure, this adhesion area does not belong to the log end area and should be removed. Watershed segmentation, a mathematical morphology segmentation method based on topological theory, is highly responsive to weak edges. The log adhesion area is a weak edge region, which can be segmented using the watershed segmentation algorithm. The candidate target region partitions are the separated regions obtained after region segmentation using the watershed segmentation algorithm. These partitions contain the actual log end areas. The watershed algorithm requires appropriate transformation of the input image, and distance transformation can be used in conjunction with the watershed segmentation algorithm.

[0228] In some embodiments, the process before step S307 includes:

[0229] The candidate target area is subjected to distance transformation processing based on the distance transformation formula to obtain a distance transformation image. The distance transformation formula is:

[0230]

[0231] In this formula, dist(p,q) is the distance calculation function, O represents the candidate target area, B represents the background area, p and q represent the points in the candidate target area and the background area, respectively, and D(p) represents the distance transformation image. Distance calculation functions in digital images are generally divided into Euclidean distance, block distance, and checkerboard distance. Considering computational complexity, block distance can be used to calculate the distance between image pixels. Given any two points p(i,j) and q(m,n) in the image, the block distance can be expressed as:

[0232] dist4=|im|+|jn|

[0233] The above block distance calculation formula can be substituted into the distance transformation formula to perform distance transformation on the candidate target area to obtain the distance transformation image D(p), as shown in the following example: Figure 20 As shown, Figure 20 This is an example diagram of a distance transformation image in an embodiment of the present invention.

[0234] Step S307 may include:

[0235] Step S3071 : performing watershed segmentation on the distance transformed image to obtain candidate target region partitions.

[0236] Based on the above method, after obtaining the distance transform image, the distance transform image is subjected to watershed segmentation to obtain the candidate target area partitions. Specifically, all pixels in the gradient image can be classified according to the grayscale value, and a geodesic distance threshold is set. Find the pixel with the smallest grayscale value (marked as the lowest grayscale value point by default), and let the threshold grow from the minimum value, and these points are the starting points. In the process of growth, the horizontal plane will encounter the surrounding neighborhood pixels, and measure the geodesic distance of these pixels to the starting point (the lowest grayscale value point). If it is less than the set threshold, these pixels will be submerged, otherwise dams will be set on these pixels, so that these neighborhood pixels are classified. As the horizontal plane gets higher and higher, more and higher dams will be set until the grayscale value is maximum, and all areas meet on the watershed line. These dams partition the pixels of the entire image. As Figure 21 As shown, Figure 21 This is an example of an image after watershed segmentation processing in an embodiment of the present invention.

[0237] Step S308: extracting the target contour of the target object from the candidate target area partitions.

[0238] The target contour refers to the contour of the target area corresponding to the target object, that is, the contour of the target area corresponding to the log end face in the embodiment. Based on the above steps, if there is only one candidate target area partition, the candidate target area partition is directly used as the target area of the log end face, and the contour of the area is extracted as the target contour of the target object. If there are more than two candidate target area partitions, such as Figure 21 As shown, the target contour can be extracted by referring to the method of extracting candidate target areas in step S306. In some embodiments, the connected domain area of each candidate target region partition can be calculated respectively, and the target contour can be determined based on the candidate target region partition with the largest connected domain area. In some embodiments, the target contour can also be extracted by machine learning recognition or feature comparison recognition. The specific implementation method can refer to the above step S306 and will not be repeated here. Among them, the extracted target contour is as follows Figure 22 As shown, Figure 22 2 is an example diagram of the target contour in an embodiment of the present invention.

[0239] Step S309: Calculate the fitting equation of the target contour.

[0240] In some embodiments, when the target object is a log, for the end face of the log, step S309 may include:

[0241] Step S3091, set the ellipse equation.

[0242] ax 2 +bxy+cy 2 +dx+ey+f=0

[0243] st4ac-b 2 >0

[0244] Among them, a, b, c, d, e, and f are equation parameters; x and y are the coordinates of the target area partition.

[0245] Step S3092, let M = [a, b, c, d, e, f], X = [x 2 ,xy,y 2 ,x,y,1] T , then the optimization objective function of the least squares method for ellipse fitting is: min||MX|| 2 =MXX T M T

[0246] sqM T >0

[0247] in,

[0248]

[0249] Step S3093, solving the optimal solution M of the objective function based on the penalty function * =[a,b,c,d,e,f], determine the fitting equation.

[0250] The equation of the log end face approximates an ellipse. Therefore, the points of the target contour extracted in the above steps can be fitted with an ellipse. First, a general ellipse fitting equation can be set in step S3091. Then, in step S3092, the objective function can be optimized using the ellipse fitting least squares method. Finally, in step S3093, the optimal solution is solved and recorded based on a penalty function. The ellipse fitting equation can be determined by setting the coordinate system and the points on the target contour. In this way, the fitting equation for the log end face can be determined relatively accurately based on the actual characteristics of the log end face.

[0251] It is understood that in some embodiments, if the target object is not a log, but rather an object or product other than a log, a general fitting equation can be set based on the external shape or detection surface features of the other object or product, and then the general fitting equation can be solved. The equation setting and solution method for other objects can be similar to the process for logs and will not be further described here.

[0252] Step S310: Calculate target parameters of the target object based on the fitting equation.

[0253] Based on the above steps S3091 to S3093, when the target object is a log, in some implementations, step S310 may include:

[0254] Step S3101, determining the center coordinates (x0, y0) based on the fitting equation.

[0255] The center coordinates are the coordinates of the center of the ellipse on the end of the log. Based on the above method, after determining the fitting equation of the ellipse on the end of the log, the specific values of the equation parameters a, b, c, d, e, and f of the fitting equation are solved. According to the properties of the ellipse, the center coordinates (x0, y0) can be calculated using the following formula:

[0256]

[0257] Based on the above formula, the center coordinates (x0, y0) can be calculated.

[0258] Step S3102, calculating the semi-major axis r1 based on the fitting equation and the semi-major axis calculation formula; the semi-major axis calculation formula is:

[0259]

[0260] Step S3103, calculating the minor semi-axis r2 based on the fitting equation and the minor semi-axis calculation formula, the minor semi-axis calculation formula is:

[0261]

[0262] Step S3104 , determining the major axis and the minor axis based on the major semi-axis and the minor semi-axis respectively.

[0263] like Figure 23 As shown, Figure 23 The figure is an example of the major diameter and minor diameter in the embodiment of the present invention. Among them, d1 is the major diameter, d2 is the minor diameter, the major semi-axis r1 is half of the major diameter d1, that is, the line segment between the center of the ellipse and any major diameter endpoint, and the minor semi-axis r2 is half of the minor diameter d2, that is, the line segment between the center of the ellipse and any minor diameter endpoint. According to the characteristics of the ellipse, the major semi-axis and the minor semi-axis can be calculated respectively by the above-mentioned major semi-axis calculation formula and the minor semi-axis calculation formula. The fitting equation parameters and center coordinate values in the formula are all known. After calculating the major semi-axis and the minor semi-axis respectively in the above-mentioned manner, the major diameter and the minor diameter can be calculated.

[0264] Step S3105: determining a measuring diameter based on the major diameter and the minor diameter.

[0265] Step S3106: determining a ruler diameter level based on the ruler diameter.

[0266] According to the national standard for log inspection, the log gauge diameter can be calculated as follows: let the major diameter and minor diameter of the fitted ellipse be d1 and d2 respectively, and the gauge diameter be d (the units of major diameter, minor diameter and gauge diameter are all in cm).

[0267] d1-d2≥2cm d=round(d1-d2)

[0268] d1-d2<2cm d=round(d2)

[0269] In the formula, round() means rounding to the nearest integer.

[0270] Let the diameter of the ruler be d', " / " represents the integer quotient symbol for calculating the division of two integers, and "%" represents the remainder for calculating the division of two integers.

[0271] div=d / 2

[0272] mod=d%2

[0273] In the formula, div and mod represent the integer quotient and remainder respectively. Then the diameter grade d' of the measuring ruler can be calculated as follows:

[0274] mod≥1d′=(div+1)×2

[0275] mod<1d′=div×2

[0276] In the above method, the center coordinates (x0, y0) are determined based on the fitting equation; the major semiaxis r1 is calculated based on the fitting equation and the major semiaxis calculation formula; the minor semiaxis r2 is calculated based on the fitting equation and the minor semiaxis calculation formula; the major and minor diameters are determined based on the major and minor semiaxis, respectively; the gauge diameter is determined based on the major and minor diameters; and the gauge diameter grade is determined based on the gauge diameter. Through the above method, the gauge diameter and gauge diameter grade of the log end face can be calculated based on the fitting equation, eliminating the need for measurement and improving the efficiency of log end face inspection.

[0277] Specifically, the pose of the log image is obtained through the following steps.

[0278] Please refer to Figure 24 and Figure 25 , Figure 24 This is the process of confirming the posture of the log image corresponding to the log cross section of the present invention. Figure 25 This is a schematic diagram of a laser projecting a laser line onto the end face of a log to be measured and a camera taking a picture.

[0279] The laser of the present invention is used to project laser rays onto the end face of a log when measuring the end face of the log, and project a linear or elongated laser projection area onto the end face of the log, such as Figure 25As shown, L1 to L4, L1 to L4 can form a "well" shape. Of course, it is also possible to project only two intersecting or parallel projection areas, or more laser projection areas. In some embodiments, a laser including multiple laser light sources can emit laser rays to generate multiple laser rays on the end face of the log; in some embodiments, there can also be two or more lasers located on different sides of the laser to generate multiple laser rays respectively, such as Figure 25 Laser 1 and Laser 2 in .

[0280] The camera of the present invention is used to collect images of the end faces of logs during the posture determination or actual measurement process, i.e. Figure 25 The industrial camera shown in Figure 1 is constructed using the camera's optical center Oc as its origin, the shooting direction (i.e., the camera's optical axis), and two mutually perpendicular directions on a plane perpendicular to the vertical direction as its axes to construct the camera coordinate system Oc-XcYcZc. The pose determination method of the present invention determines the representation or expression parameters of the log end face in the camera coordinate system.

[0281] The posture determination method of the present invention includes:

[0282] Step S401, when the target object is projected by the laser beam of the laser, the image of the target object is captured by the camera; wherein the image includes a laser light pattern, and the laser light pattern is an image area of the laser projection area projected by the laser on the target object.

[0283] First, a processor controls a laser to project a laser beam onto the target log end. In some embodiments, the processor receives a user-triggered command to control the laser to project the beam onto the log end. In some embodiments, the command to project the beam can also be automatically triggered and controlled by the laser when the camera detects the log end. Similarly, an image of the log end can be captured based on a user-triggered image capture command, or when the camera detects the log end and the log end remains stationary for a predetermined period of time.

[0284] The collected log image includes the laser light pattern, that is, the image area of the projection area L1 to L4 projected by the laser on the end surface of the log in the image, such as Figure 25The linear area ab and the linear area cd in the figure correspond to the laser projection area L1 and the laser projection area L2 respectively. Πc is the image plane, on which the image plane coordinate system o-xy can be constructed with the image plane principal point o as the coordinate origin. Πw is the end face of the log, and the world coordinate system Ow-XwYwZw is constructed based on the end face of the log and its normal direction. The laser 1 emission point O1 emits a "cross" laser ray that intersects with the log end face Πw, and the intersection areas AB (L1) and CD (L2) are the laser projection areas, which are represented by lines for the convenience of diagramming. The laser emission point O1 and the intersection line L1 form the light plane Π1, and form Π2 with L2. The laser emission point O2 of the laser 2 emits a "cross" laser ray that intersects with the log end face Πw, and the intersection areas L3 and L4 are the laser projection areas, which are represented by lines for the convenience of diagramming. During the calculation process based on the linear area, the coordinates of the reference line segments at the terminal of the linear area can be used for calculation, such as the contour edge, median line, center line extracted from the centroid, etc.

[0285] Step S402 : Calibrate the light plane calibration equation of the laser light plane in the camera coordinate system based on the structured light light plane calibration algorithm.

[0286] like Figure 25 As shown, the light plane calibration equations of light plane Π1 and light plane Π2 in the camera coordinate system Oc-XcYcZc can be calibrated based on the structured light light plane calibration algorithm as follows:

[0287] a1X c +b1Y c +c1Z c +d1=0(1)

[0288] a2X c +b2Y c +c2Z c +d2=0(2)

[0289] In formula (1), Xc, Yc, and Zc are the three-dimensional coordinates of the point on light plane Π1 in the camera coordinate system; a1, b1, and c1 are the calibration constants in the calibration equation for light plane Π1. In formula (2), Xc, Yc, and Zc are the three-dimensional coordinates of the point on light plane Π2 in the camera coordinate system; a2, b2, and c2 are the calibration constants in the calibration equation for light plane Π2.

[0290] Step S403 : determining the transformation relationship between the image coordinates of the laser light pattern and the camera coordinates based on a camera perspective imaging model.

[0291] As mentioned above and Figure 25As shown in the figure, the laser pattern ab is obtained by capturing the laser projection area AB with the camera, and the laser pattern cd is obtained by capturing the laser projection area CD with the camera. The image coordinates of the laser patterns ab and cd are obtained from the image plane coordinate system o-xy. Based on the camera perspective imaging model, the transformation relationship from the image coordinates of the laser pattern to the camera coordinates in the camera coordinate system Oc-XcYcZc can be obtained as (4):

[0292]

[0293] Wherein, x and y are the image coordinates of the center line of the laser pattern / laser pattern, f is the effective focal length (which can be obtained through camera calibration), and Xc, Yc, and Zc are the coordinates of the center line of the laser pattern / laser pattern in the camera coordinate system.

[0294] Step S404 : calculating a plane equation of the target object in the camera coordinate system based on the transformation relationship and the light plane calibration equation.

[0295] As shown above, the laser light pattern plane calibration equations are formulas (1) and (2). By combining formulas (1) and (4) for calculation, we can obtain the three-dimensional coordinate equation of the intersection line L1 in the camera coordinate system Oc-XcYcZc. Similarly, the three-dimensional coordinate equations of L2, L3, and L4 can be obtained. Based on the three-dimensional coordinate equations of the line segment, a series of point coordinates of the log end surface can be obtained. Based on the obtained point coordinates and the plane fitting algorithm, the plane equation of the log end surface in the camera coordinate system can be obtained.

[0296] Step S405 : calculating the distance between the target object and the camera imaging plane based on the plane equation as the working distance.

[0297] In the present invention, the plane equation of the target object log end face in the camera coordinate system is the expression of the log end face in the camera coordinate system, which includes comprehensive posture information, but is relatively unintuitive. In some embodiments, the posture information can be expressed by intuitive posture parameters, such as the distance between the target object log end face and the camera imaging plane, that is, the working distance. Specifically, the projection distance of the coordinate origin Oc on the log end face can be used as the working distance, that is, the camera optical center, that is, the projection point of the coordinate origin Oc of the camera coordinate system on the log end face is determined based on the plane equation, and the distance from the origin Oc is calculated based on the coordinates of the projection point in the camera coordinate system as the working distance. Alternatively, the distance between the log end face point corresponding to the principal point o of the image plane and Oc is directly defined as the working distance and calculated.

[0298] After determining the working distance, the working distance can be used as part of the pose information, thereby representing the pose information relatively intuitively.

[0299] Step S406 : Calculate the angle between the normal line of the target object and the optical axis of the camera as a working tilt angle.

[0300] In some embodiments, the posture information can be expressed by intuitive posture parameters, such as the angle between the end face of the target log and the optical axis, which is defined as the working inclination angle. Specifically, the normal line equation of the normal line of the log end face can be determined based on the plane equation, and then the angle between it and the coordinate axis Zc can be calculated based on the normal line equation, that is, Figure 25 The angle θ is shown.

[0301] In the above-mentioned posture determination method, the image of the target object under the projection of the laser ray is collected by the camera, and then the light plane calibration equation of the laser light plane in the camera coordinate system is calibrated based on the laser light pattern and structured light light plane calibration algorithm. The transformation relationship between the image coordinates of the laser light pattern and the camera coordinates is determined according to the camera transmission model. Then, the plane equation of the target object in the camera coordinate system can be calculated based on the transformation relationship and the calibration equation, and the working distance and working inclination angle of the target object can be further calculated. Based on the working distance and working inclination angle, the posture can be expressed accurately, comprehensively and intuitively.

[0302] Step S403 includes:

[0303] Step S4031: extracting the center line of the laser light pattern based on the grayscale centroid method.

[0304] Based on the above pose determination method, the laser pattern is a strip-shaped image region, not a strict line segment. To facilitate coordinate calculation, it is necessary to extract a regional reference line from the laser pattern to replace the laser pattern for coordinate extraction. In some embodiments, the centerline of the laser pattern can be extracted using the grayscale centroid method and used in place of the laser pattern for calculation.

[0305] Specifically, the image area corresponding to the laser streak is first divided into sections, and the grayscale value is treated as the mass using the mathematical definition of the center of mass. The grayscale center of gravity along the coordinate axis is calculated to represent the center point position of the laser stripe in the section. The image is traversed in rows or columns, and the fitted point is used as the center line of the laser stripe. Since the laser streak is relatively coarse, an image processing algorithm is used to refine the laser streak and extract the center line of the structured light streak at the pixel or sub-pixel level. Assume that the coordinates of a point on a certain section of the streak are (xi, yi), and the corresponding grayscale value is g(xi, yi), where i = 1,..., N, and N is the number of pixels in the section. Then the coordinates of the center of the streak on the section are:

[0306]

[0307] Step S4032 : determining a transformation relationship between the image coordinates of the laser light pattern and the camera coordinates based on the image coordinates of the center line and a camera perspective imaging model.

[0308] After obtaining the center line, the image coordinates of the points on the center line are obtained. After obtaining the image coordinates of the center lines ab and cd of the laser pattern, the transformation relationship from the image coordinates of the center line of the laser pattern to the camera coordinates can be obtained by the camera perspective imaging model:

[0309]

[0310] In the above-described pose determination method, after determining the centerline using the grayscale centroid method, determining the transformation relationship based on the centerline can reduce extraction errors and improve calculation accuracy. It will be appreciated that in some embodiments, the centerline can also be extracted using the extreme value method. The present invention is not limited to centerline extraction using the grayscale centroid method. It will be appreciated that other methods, such as the extreme value method, can also be used to extract the centerline or calculate the reference line.

[0311] Step S4031 includes:

[0312] Step S40311a: determining the area of the cross section based on the distance between the laser light pattern area and the image center, wherein the area of the cross section decreases as the distance increases.

[0313] It can be understood that in the image captured by the camera, the closer the laser light pattern is to the center of the image, the larger the distance between the contours on both sides of the laser light pattern, that is, the wider the area; the farther away from the center of the image, the smaller the distance between the contours on both sides of the laser light pattern, that is, the narrower the area.

[0314] like Figure 26 As shown, 6.1 is a schematic diagram of an image captured by a camera and projected by laser light onto the end face of a log; 6.2 is a schematic diagram of a magnified laser light pattern dividing a cross section, where g1 and g2 are the contours of the laser light pattern, respectively; 6.3 is a schematic diagram of the cross-sectional area and the distance from the image origin. In some embodiments, the cross section can be divided into rectangular shapes. Specifically, the width k of the rectangle is a fixed value, and the length m of the rectangle is a positively correlated function of the distance d between the cross-sectional area and the center of the image. This function can be determined based on experiments so that the length of the cross-sectional area is substantially equal to the distance between the contours of the laser light pattern in the cross-sectional area. It can be seen that as the distance d1 gradually increases to the distance dn, the cross-sectional length m gradually decreases, and the cross-sectional area gradually decreases.

[0315] Specifically, in some embodiments, step S40311a may include:

[0316] The laser pattern is partitioned based on a preset width.

[0317] Get the distance between each partition and the center of the image.

[0318] The divided area of the cross section corresponding to each partition is determined based on the distance between each partition and the center of the image, and a preset relationship between the distance and the cross section area.

[0319] Specifically, the laser streak is first divided into regions based on a preset width k to obtain multiple partitioned regions. The distance between each partition and the center of the image is then obtained, where the dividing line is perpendicular to the extension direction of the laser streak. In some embodiments, the distance between each partition and the center of the image can be obtained by calculating the distance between the intersection of the bottom dividing line of each partition and the laser streak profile and the center of the image. The partitioned area corresponding to each partition is then determined based on a preset relationship between distance and cross-sectional area. The preset relationship between distance and cross-sectional area can be a calculation formula for calculating cross-sectional area based on distance, which is pre-determined based on experimental data. This calculation formula ensures that the calculated cross-sectional area is close to the actual area of the laser streak partition at the corresponding distance.

[0320] Step S40312a: divide the laser pattern into sections based on the determined division area.

[0321] Based on step S40311a, after the division area is determined, other cross-sectional parameters are determined based on the division area and the preset width k, and cross-sectional division is performed based on the division area and all cross-sectional parameters.

[0322] Step S40312a includes:

[0323] Determining the length of each cross section based on the divided area of each cross section and the preset width;

[0324] The sections are divided into rectangular shapes based on the length of each section and the preset width.

[0325] In some embodiments, a rectangular shape can be used as the cross-sectional shape. When obtaining the area of each cross-sectional area, the length of each rectangular cross-section can be calculated based on the area and a preset width. The laser pattern is then segmented based on the length and width of each rectangular cross-section. This method, using rectangles that approximate the laser pattern shape as the cross-sectional shape elements for segmentation, improves the efficiency and accuracy of segmentation and reduces errors.

[0326] Step S40313a, determining the center line based on the line connecting the grayscale centroids of each cross section.

[0327] After dividing the cross sections based on the above method, the grayscale center of each cross section is determined based on the following formula.

[0328]

[0329] Then, the grayscale centers of each cross section are connected to obtain the center line. The equation of the center line can be obtained by fitting based on the coordinates of each grayscale center point.

[0330] In the above-mentioned posture determination method, by dividing the cross section using a division method that matches the outer contour or size change of the laser pattern, the calculation accuracy of the grayscale centroid can be improved, the center line can be determined more accurately, and the reliability of the calculation result can be improved.

[0331] Specifically, in some embodiments, step S4031 includes:

[0332] Step S40311b, obtaining the maximum contour distance between the contours on both sides of the laser pattern;

[0333] Step S40312b, calculating the target partition area based on the maximum contour distance and a preset relationship between the maximum contour distance and the partition area;

[0334] Step S40313b: performing equal-area cross-section division in a rectangular shape based on the target division area.

[0335] Based on the embodiment of the above-mentioned posture determination method, each dividing line has two intersection points with the contours on both sides of the laser light pattern. The distance between the two intersection points can be used as the contour distance, and the maximum value of the contour distance can be used as the maximum contour distance.

[0336] In some embodiments, a calculation formula between the partition area and the maximum contour distance can be predetermined based on experimental data as a preset relationship, such that when the rectangle width is a preset width, the long side of the rectangle corresponding to the target partition area calculated based on the preset relationship is greater than the maximum contour distance, so that the rectangle corresponding to the target partition area can cover the largest laser light pattern partition area. To simplify cross-section processing, the preset relationship can be determined based on the target partition area to meet the minimum value required for the corresponding rectangle to cover the largest laser light pattern partition area.

[0337] In the specific implementation process, the maximum contour distance is obtained, and then the target segmentation area is calculated according to the preset calculation formula of the maximum contour distance, the maximum contour distance and the segmentation area. The segmentation length is determined based on the target segmentation area and the preset width. Then, a rectangular laser pattern with a fixed area using this segmentation length and the preset width is unified to obtain multiple sections of equal area.

[0338] In some embodiments, in addition to the grayscale centroid method for extracting the center line, the center line may also be extracted using an extreme value method. Specifically, step S403 includes:

[0339] Step S4033, extracting the center line of the laser pattern based on the extreme value method;

[0340] The extreme value method is used to perform gradient calculation on the grayscale distribution function of the light streak cross section, and the pixel point where the gradient value is zero is taken as the center point of the light streak.

[0341] Step S4034 : determining a transformation relationship between the image coordinates of the laser light pattern and the camera coordinates based on the image coordinates of the center line and a camera perspective imaging model.

[0342] The specific method of extracting the center line using the extreme value method and determining the transformation relationship based on the center line extracted by the extreme value method can refer to the existing extreme value method extraction method and the above embodiments, and will not be repeated here.

[0343] like Figure 25 In some embodiments, the image includes at least two intersecting laser light patterns, which respectively correspond to at least two intersecting laser projection areas projected by the laser on the target object.

[0344] Based on the above-mentioned pose determination method, the laser pattern is an image of the laser projection area captured by a camera. In the implementation of this invention, one or more lasers can project intersecting laser projection areas onto the target log end face, such as AB and CD shown in the figure. Projecting intersecting laser projection areas facilitates identification, acquisition, and extraction calculations.

[0345] Step S404 includes:

[0346] Step S4041: Calculate the laser projection equation of the laser projection area in the camera coordinate system based on the transformation relationship and the light plane calibration equation.

[0347] The laser projection equation is the expression equation of the laser projection area on the log end face in the camera coordinate system. When there are multiple intersecting laser projection areas, the expression equation of each laser projection area is calculated separately. Specifically, the laser light pattern light plane calibration equation is formula (1) and (2). By combining formulas (1) and (4) for calculation, the three-dimensional coordinate equation of the intersection line L1 in the camera coordinate system Oc-XcYcZc can be obtained. Similarly, the three-dimensional coordinate equations of L2, L3, and L4 can be obtained.

[0348] Step S4042, calculating the plane equation based on the least squares surface fitting method and the point coordinates of different laser projection equations.

[0349] After obtaining the 3D coordinate equations of multiple laser projection areas, the coordinates of a series of points on the log's end face can be obtained based on the 3D coordinate equations of several line segments. Using these point coordinates and a plane fitting algorithm, the plane equation of the log's end face in the camera coordinate system can be obtained.

[0350] In the above-mentioned posture determination method, identification and extraction are facilitated by projecting two or more intersecting laser projection areas, and the plane equation of the log end face in the camera coordinate system can be accurately calculated based on the least squares surface fitting method.

[0351] It can be understood that in some embodiments, the posture can also be determined by projecting a parallel laser projection area. The determination method can refer to the above description and will not be repeated here.

[0352] In summary, although the present invention has been disclosed above with reference to preferred embodiments, the above preferred embodiments are not intended to limit the present invention. A person skilled in the art may make various changes and modifications without departing from the spirit and scope of the present invention. Therefore, the scope of protection of the present invention shall be based on the scope defined in the claims.

Claims

1. A log image acquisition method for assisting in obtaining log outlines, characterized in that: The steps include: S110, an LED light source projects light onto the end face of the log, a camera captures an image of the log based on the projected light source, and generates a target image based on the log image; an area of a low-grayscale region is acquired based on the target image, and an average grayscale value of the low-grayscale region is calculated based on the area of the low-grayscale region; S111, obtaining a first lower limit value; when the average grayscale value of the low grayscale area is less than the first lower limit value, increasing the output energy of the LED light source, thereby increasing the grayscale value of the target image, and returning to step S110; until the average grayscale value of the low grayscale area is greater than the first lower limit value; S112, obtaining a first upper limit value; when the average grayscale value of the low grayscale area is greater than the second upper limit value, reducing the output energy of the LED light source, thereby reducing the grayscale value of the target image, and returning to step S110; until the average grayscale value of the low grayscale area is less than the first upper limit value; S120, the LED light source and the laser emitter simultaneously project light toward the end face of the log based on the adjusted output energy of the LED light source; The camera acquires a log image based on a projected light source, generates a target image based on the log image, and acquires an area of the target image, wherein the target image includes all high grayscale points; Acquire the area of the high grayscale region based on all the high grayscale points, and calculate the area ratio of the high grayscale region based on the area of the high grayscale region and the area of the target image; S121, obtaining a second lower limit value. When the area ratio of the high grayscale region is less than the second lower limit value, increasing the output energy of the laser emitter, thereby increasing the number of the high grayscale points, and returning to step S120; until the area ratio of the high grayscale region is greater than the second lower limit value; S122, obtaining a second upper limit value, and when the area ratio of the high grayscale region is greater than the second upper limit value, reducing the output energy of the laser emitter, thereby reducing the number of the high grayscale points, and returning to step S120; until the area ratio of the high grayscale region is less than the second upper limit value; and S130, the camera acquires the log image based on the adjusted output energy of the LED light source and the laser emitter.

2. The method for obtaining a log image according to claim 1, wherein: The step of increasing the output energy of the LED light source in step S111 includes: Obtaining a current light source pulse width of the LED light source, increasing the current light source pulse width using a preset light source pulse width single adjustment amount, and generating an adjusted light source pulse width; Setting the adjusted light source pulse width as the current light source pulse width and returning to step S110; until the average grayscale value of the low grayscale area is greater than the first lower limit; and The step of reducing the output energy of the LED light source in step S112 includes: Obtaining a current light source pulse width of the LED light source, reducing the current light source pulse width using a preset light source pulse width single adjustment amount, and generating an adjusted light source pulse width; The adjusted light source pulse width is set as the current light source pulse width, and the process returns to step S110 ; until the average grayscale value of the low grayscale area is less than the first upper limit value.

3. The method for obtaining a log image according to claim 2, wherein: The step of increasing the output energy of the LED light source in step S111 further includes: Obtaining a current light source pulse width of the LED light source, and when the current light source pulse width is greater than a preset maximum pulse width of the LED light source, obtaining a current exposure time of the camera; Using a preset exposure time single time adjustment amount to increase the current exposure time and generate an adjusted exposure time; Setting the adjusted exposure time as the current exposure time and returning to step S110; until the average grayscale value of the low grayscale area is greater than the first lower limit; and The step of reducing the output energy of the LED light source in step S112 further includes: Obtaining a current light source pulse width of the LED light source, and when the current light source pulse width is less than a preset minimum light source pulse width of the LED light source, obtaining a current exposure time of the camera; Using a preset exposure time single time adjustment amount to reduce the current exposure time and generate an adjusted exposure time; The adjusted exposure time is set as the current exposure time, and the process returns to step S110 ; until the average grayscale value of the low grayscale area is less than the first upper limit value.

4. The method for obtaining a log image according to claim 1, wherein: The step of increasing the output energy of the laser transmitter in step S121 includes: Obtaining a current laser pulse width of the laser transmitter, increasing the current laser pulse width using a preset laser pulse width single adjustment amount, and generating an adjusted laser pulse width; The adjusted laser pulse width is set as the current laser pulse width, and the process returns to step S120; until the high grayscale area ratio is greater than the second lower limit; and The step of reducing the output energy of the laser transmitter in step S122 includes: Obtaining a current laser pulse width of the laser transmitter, adjusting the current laser pulse width using a preset laser pulse width single adjustment amount, and generating an adjusted laser pulse width; The adjusted laser pulse width is set as the current laser pulse width, and the process returns to step S120 ; until the area ratio of the high grayscale region is less than the second upper limit value.

5. The method for obtaining a log image according to claim 4, wherein: The step of increasing the output energy of the laser transmitter in step S121 further includes: Acquire a current laser pulse width of the laser emitter, and when the current laser pulse width is greater than a preset maximum pulse width of the laser emitter, acquire a current exposure time of the camera; Using a preset exposure time single time adjustment amount to increase the current exposure time and generate an adjusted exposure time; Setting the adjusted exposure time as the current exposure time and returning to step S120; until the high grayscale area ratio is greater than the second lower limit; and The step of reducing the output energy of the laser transmitter in step S122 further includes: Acquire a current laser pulse width of the laser emitter, and when the current laser pulse width is less than a preset minimum laser pulse width of the laser emitter, acquire a current exposure time of the camera; Using a preset exposure time single time adjustment amount to reduce the current exposure time and generate an adjusted exposure time; The adjusted exposure time is set as the current exposure time, and the process returns to step S120 ; until the area ratio of the high grayscale region is less than the second upper limit value.

6. The method for obtaining a log image according to claim 1, wherein: Before performing the step S110, the following steps are also included: S100, the laser emitter and the LED light source simultaneously project light onto the end face of the log, the camera captures an image of the log based on the projected light source, generates a target image based on the log image, and acquires the area of the target image, wherein the target image includes all high-grayscale points; based on the areas of the high-grayscale regions of all the high-grayscale points, the high-grayscale region area ratio is calculated based on the areas of the high-grayscale regions and the area of the target image; S101, obtaining a third lower limit value, the third lower limit value being less than the second lower limit value; when the area ratio of the high grayscale region is less than the third lower limit value, increasing the output energy of the laser emitter, thereby increasing the number of the high grayscale points, and returning to step S100; until the area ratio of the high grayscale region is greater than the third lower limit value; S102, obtaining a third upper limit value, the third upper limit value being greater than the second upper limit value; when the proportion of the high grayscale area is greater than the third upper limit value, reducing the output energy of the laser emitter, thereby reducing the number of the high grayscale points, and returning to step S100; until the proportion of the high grayscale area is less than the third upper limit value; and S103, the camera acquires a preliminary log image based on the adjusted output energy of the laser emitter and the output energy of the LED light source.

7. The method for obtaining a log image according to claim 6, wherein: The step S101 further includes setting the third lower limit value to half of the second lower limit value; The step S102 further includes setting the third upper limit value to twice the second upper limit value.

8. The method for acquiring a log image according to claim 1, wherein: The laser emitter is configured as a cross laser emitter to project line structured light, and two groups of laser emitters are provided; the multiple high grayscale points formed on the log image by the ray structured light projected by the two groups of laser emitters constitute four straight lines, and each straight line intersects with two of the straight lines.

Citation Information

Patent Citations

  • Log scanning system

    CN107111602A

  • Image processing method for log end face measurement

    CN112750127A