Data acquisition method and equipment of endoscope and storage medium
By installing a distance measuring scale on the endoscope and combining the YOLO algorithm and OpenCV library to process images, the measurement size deviation problem caused by excessive fitting parameters of the endoscope software is solved, and a higher precision size measurement is achieved.
Patent Information
- Application Number
- CN202510680611.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-23
- Publication Date
- 2025-08-26
AI Technical Summary
In the prior art, too many software fit parameters of the endoscope lead to a large deviation in the measurement size of the captured image, affecting the measurement accuracy.
Install a range measuring scale on the endoscope, and accurately measure the distance between the endoscope and the captured object through the hardware range measuring scale. Combined with the YOLO algorithm and the OpenCV library for image processing, and calculate the acquisition size of the target object.
The cost of the endoscope in collecting the size of the subject is reduced, measurement errors caused by overfitting software parameters and improving measurement accuracy.
Smart Images

Figure CN120538409A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data acquisition, and in particular to a data acquisition method, device and storage medium for an endoscope. Background Art
[0002] An industrial endoscope is an instrument used for industrial inspection that can perform visual inspections inside equipment without disassembling the equipment. The optical imaging system of an industrial endoscope is one of its core components. It focuses the light reflected from the object through multiple optical elements (such as lenses, prisms, etc.) and transmits it to the image sensor at the front end of the probe. The design and quality of the optical system directly affect the image clarity, color reproduction, depth of field and other imaging effects. For example, some high-end industrial endoscopes use high-quality optical glass and advanced optical coating technology to provide high-resolution, low-distortion images, allowing clear observation of details inside the equipment even in complex industrial environments.
[0003] Industrial endoscopes are able to record and store large amounts of image and video data in real time. These data can be further analyzed and processed in conjunction with computers and specialized software. For example, by utilizing image recognition algorithms and artificial intelligence technology, defects, cracks, corrosion, and other abnormalities in images can be automatically identified and marked, generating inspection reports that provide a scientific basis for equipment maintenance and repair. At the same time, inspection data can be compared and analyzed with historical equipment data to enable long-term monitoring and assessment of equipment health. Because the size of captured images is crucial for maintenance and repair, existing technologies use software to calibrate and measure images captured by endoscopes. However, due to the excessive number of parameters fitted by the software, the dimensional deviations of the images captured by the endoscope are large. A new technology is needed to address this problem, which is caused by the excessive number of parameters fitted by the software and results in large dimensional deviations in the images captured by the endoscope. Summary of the Invention
[0004] The main purpose of the present invention is to solve the technical problem that too many parameters fitted by the software lead to large deviations in the size measurement of the images taken by the endoscope.
[0005] A first aspect of the present invention provides an endoscope data acquisition method, the endoscope data acquisition method being applied to an endoscope, wherein a distance measuring scale is fixed to the imaging direction of the endoscope, the endoscope data acquisition method comprising:
[0006] Opening the endoscope and advancing the endoscope until the distance measuring scale abuts against the target object;
[0007] Invoking the endoscope to photograph the target object to obtain a photographed image;
[0008] The object size of the captured image is measured according to the distance value set by the distance measuring scale to obtain the acquisition size of the target shooting object.
[0009] Optionally, in a first implementation of the first aspect of the present invention, calling the endoscope to photograph the target object to obtain a photographed image includes:
[0010] Invoking the endoscope to focus the target object to obtain a focus focal length;
[0011] The endoscope is used to capture the target object and generate a captured image.
[0012] Optionally, in a second implementation of the first aspect of the present invention, measuring the object size of the captured image according to the distance value set by the ranging scale to obtain the acquisition size of the target object includes:
[0013] Identifying the number of vertical pixels of a target object in the captured image to obtain a pixel value of the object;
[0014] The unit pixel size of the captured image is read, and according to a preset size calculation formula, the object pixel value, the unit pixel size, the focus focal length, and the distance value are numerically calculated to obtain the acquisition size of the target captured object.
[0015] Optionally, in a third implementation of the first aspect of the present invention, the size calculation formula includes:
[0016] H = (n*s*D) / f, where H is the acquisition size of the target object, n is the object pixel value, s is the unit pixel size, and f is the focus focal length.
[0017] Optionally, in a fourth implementation of the first aspect of the present invention, identifying the number of vertical pixels of the target object in the captured image to obtain the object pixel value includes:
[0018] Based on a preset YOLO algorithm, the captured image is classified into categories to obtain a classification graph of the target object;
[0019] According to the preset OpenCV library, the pixels of the horizontal and vertical axes of the divided graphics are calculated and processed to obtain the horizontal axis pixel value and the vertical axis pixel value of the object.
[0020] Optionally, in a fifth implementation of the first aspect of the present invention, the calculating and processing of the pixels along the horizontal and vertical axes of the divided graph according to the preset OpenCV library to obtain the horizontal axis pixel value and the vertical axis pixel value of the object includes:
[0021] performing mask generation processing on the captured image to generate a capture mask;
[0022] performing pixel filling processing on the shooting mask according to the division pattern to generate a filling mask;
[0023] Performing pixel statistics processing on the horizontal and vertical axes of the filling mask to obtain the horizontal axis pixel value and the vertical axis pixel value of the object.
[0024] Optionally, in a sixth implementation of the first aspect of the present invention, performing pixel filling processing on the shooting mask according to the division pattern to generate a filling mask includes:
[0025] According to the fillPoly() function, the divided graphics of the shooting mask are filled with pixels to generate a filling mask.
[0026] Optionally, in a seventh implementation manner of the first aspect of the present invention, after measuring the object size of the captured image according to the distance value set by the ranging scale to obtain the captured size of the target object, the method further includes:
[0027] The collected size is pushed to a preset cloud server.
[0028] A second aspect of the present invention provides an endoscope data acquisition device, comprising: a memory and at least one processor, wherein instructions are stored in the memory, and the memory and the at least one processor are interconnected via lines; the at least one processor calls the instructions in the memory so that the endoscope data acquisition device executes the above-mentioned endoscope data acquisition method.
[0029] A third aspect of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores instructions, which, when executed on a computer, enable the computer to execute the above-mentioned endoscopic data acquisition method.
[0030] In an embodiment of the present invention, by installing a distance measuring scale on the endoscope, it is not necessary to use infrared probes, image analysis probes, etc. when using the industrial endoscope, thereby reducing the cost of the endoscope in collecting the size of the photographed object and avoiding the large error in the actual measurement size caused by overfitting of software process parameters. The endoscope does not need to pay too much attention to distance measurement but can focus on solving the problem of distortion correction of the captured image. The hardware distance measuring scale is used to accurately measure the distance between the endoscope and the photographed object, reducing the error in the size measurement of the industrial endoscope and solving the technical problem that too many parameters fitted by the endoscope software lead to large deviations in the size measurement of the captured image of the endoscope. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] Figure 1A schematic diagram of an embodiment of a method for collecting data through an endoscope according to an embodiment of the present invention;
[0032] Figure 2 Schematic diagram of the installation of the distance measuring scale of the endoscope in an embodiment of the present invention;
[0033] Figure 3 FIG1 is a schematic diagram of a specific embodiment of step 102 of the endoscope data acquisition method according to an embodiment of the present invention;
[0034] Figure 4 FIG1 is a schematic diagram of a specific embodiment of step 103 of the endoscope data acquisition method according to an embodiment of the present invention;
[0035] Figure 5 Schematic diagram of an embodiment of a data acquisition device for an endoscope in an embodiment of the present invention. DETAILED DESCRIPTION
[0036] The embodiments of the present invention provide a data acquisition method, device and storage medium for an endoscope.
[0037] The following describes embodiments of the present disclosure in more detail with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as limited to the embodiments described herein. Rather, these embodiments are provided to provide a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are for illustrative purposes only and are not intended to limit the scope of protection of the present disclosure.
[0038] In the description of the embodiments disclosed herein, the term "including" and similar terms should be understood as open inclusion, i.e., "including but not limited to." The term "based on" should be understood as "based, at least in part, on." The term "one embodiment" or "the embodiment" should be understood as "at least one embodiment." The terms "first," "second," etc. may refer to different or the same objects. Other explicit and implicit definitions may also be included below.
[0039] For ease of understanding, the specific process of the embodiment of the present invention is described below. Figure 1 In one embodiment of the data acquisition method for an endoscope according to an embodiment of the present invention, the data acquisition method for an endoscope is applied to an endoscope, wherein a distance measuring scale is fixed in the imaging direction of the endoscope, and the data acquisition method for an endoscope comprises:
[0040] 101. Turn on the endoscope and push it forward until the distance measuring scale abuts against the target object;
[0041] In this embodiment, please refer to Figure 2 , Figure 2 This is a schematic diagram of the installation of the distance measuring scale of the endoscope in an embodiment of the present invention. Figure 2 The optical lens 20 of the endoscope and a distance scale 30 are vertically arranged starting from the center point of the lens of the optical lens 20. The distance scale 30 is a fixed length from the outer extension direction of the optical lens 20. When the endoscope is measuring and photographing an object, the shooting state of the endoscope is turned on, and the user pushes the endoscope until the distance scale abuts the target object. Since the endoscope is used in industrial applications and the object is a rigid object, the distance of the distance scale is the actual distance from the optical lens 20 of the endoscope to the target object.
[0042] 102. Invoke the endoscope to photograph the target object to obtain a photographed image;
[0043] In this embodiment, the endoscope is called to shoot the target object, and the image size of the target object is locked to obtain a shot image.
[0044] For further information, please refer to Figure 3 , Figure 3 FIG. 1 is a schematic diagram of a specific embodiment of step 102 of the endoscope data acquisition method in an example of the present invention, wherein step 102 includes the following specific implementation methods:
[0045] 1021. Invoke the endoscope to focus the target object to obtain a focus distance;
[0046] 1022. Perform photographing processing on the target object using the endoscope with the focusing focal length to generate a photographed image.
[0047] In steps 1021-1022, the internal optical accessories of the endoscope are called to focus the target object, and the focus focal length set by the optical accessories is obtained.
[0048] The endoscope is used to capture the target object and generate a captured image. The captured image includes the target object.
[0049] 103. Measure the object size of the captured image according to the distance value set on the distance measuring scale to obtain the acquisition size of the target object.
[0050] In this embodiment, in addition to optical calculation, neural network classification AI is also used to divide the target object in the image. Then, the size of the divided target object is calculated using the distance value set by the ranging scale, and finally the acquisition size of the target object is obtained.
[0051] For details, please refer to Figure 4 , Figure 4This is a schematic diagram of a specific embodiment of step 103 of the endoscope data acquisition method in the present invention, which includes the following specific implementation methods:
[0052] 1031. Identify the number of vertical pixels of the target object in the captured image and obtain the object pixel value;
[0053] 1032. Read the unit pixel size of the captured image, and perform numerical calculation on the object pixel value, the unit pixel size, the focus focal length, and the distance value according to a preset size calculation formula to obtain the acquisition size of the target captured object.
[0054] In steps 1031-1032, the vertical pixel count of the target object in the captured image is first identified. The vertical pixel count includes the pixel count value along the X-axis and the pixel count value along the Y-axis.
[0055] After obtaining the vertical pixel count of the target object, the unit pixel size (s) displayed in the captured image is read. The captured image is then calculated using the X-axis and Y-axis pixel counts, the unit pixel size, the focal length, and the distance value prepared in the previous steps to ultimately determine the target object's acquisition size. Because the acquired distance value is not calculated using infrared detection and image transformation, the distance value is more accurate. Other parameter errors are essentially negligible due to the system's internal parameters, resulting in a more accurate output acquisition size than purely software-based calculations.
[0056] It should be noted that the size calculation formula includes:
[0057] H = (n*s*D) / f, where H is the acquisition size of the target object, n is the object pixel value, s is the unit pixel size, f is the focus distance, and D is the distance value set by the rangefinder.
[0058] Specifically, step 1031 includes the following specific implementation methods:
[0059] 10311. Based on a preset YOLO algorithm, the captured image is classified into categories to obtain a classification diagram of the target object.
[0060] 10312. Calculate and process the horizontal and vertical axis pixels of the divided graph according to the preset OpenCV library to obtain the horizontal axis pixel value and the vertical axis pixel value of the object.
[0061] In steps 10311 and 10312, the YOLO algorithm model parameters are pre-trained using the TensorFlow or PyTorch framework and integrated into the endoscope's electronic system. The YOLO algorithm is used to classify the captured image into different categories, generating a segmented image of the target object.
[0062] Then, the OpenCV library of the C++ standard library calculates and processes the pixels of the horizontal and vertical axes of the divided graphics to obtain the horizontal axis pixel value and the vertical axis pixel value of the object.
[0063] Specifically, step 10312 includes the following specific implementation methods:
[0064] 103121. Perform mask generation processing on the captured image to generate a capture mask;
[0065] 103122. Perform pixel filling processing on the shooting mask according to the division pattern to generate a filling mask;
[0066] 103123. Perform horizontal and vertical axis pixel statistics processing on the filling mask to obtain the object horizontal axis pixel value and the object vertical axis pixel value.
[0067] In steps 103121-103123, the mask generation process of the captured image in step 103121 to generate the capture mask can be implemented using C++ code in the following manner:
[0068]
[0069]
[0070] Finally, output an int main(){} function to import cv::imread and import the divided area image processed by the YOLO algorithm. After the above processing, the horizontal axis pixel value and the vertical axis pixel value of the object can be obtained.
[0071] It should be noted that step 103122 includes the following specific implementation methods:
[0072] 103122X. Fill the divided graphics of the shooting mask with pixels according to the fillPoly() function to generate a filling mask.
[0073] In step 103122X, the polygonal area of the divided figure is filled using the fillPoly() function in the OpenCV library to generate a fill mask.
[0074] Furthermore, after step 103, the following specific implementation methods are also included:
[0075] 104. Push the collected size to a preset cloud server.
[0076] In step 104, the collected dimensions can be transmitted to a computer via a data cable after being collected, or pushed to a cloud server after being transmitted to a computer, and forwarded by the cloud server to the user APP, so that the user can view the data directly on the mobile phone, and can view the data across platforms and devices.
[0077] In an embodiment of the present invention, by installing a distance measuring scale on the endoscope, it is not necessary to use infrared probes, image analysis probes, etc. when using the industrial endoscope, thereby reducing the cost of the endoscope in collecting the size of the photographed object and avoiding the large error in the actual measurement size caused by overfitting of software process parameters. The endoscope does not need to pay too much attention to distance measurement but can focus on solving the problem of distortion correction of the captured image. The hardware distance measuring scale is used to accurately measure the distance between the endoscope and the photographed object, reducing the error in the size measurement of the industrial endoscope and solving the technical problem that too many parameters fitted by the endoscope software lead to large deviations in the size measurement of the captured image of the endoscope.
[0078] Figure 5 : is a structural diagram of an endoscope data acquisition device provided by an embodiment of the present invention. The endoscope data acquisition device 500 may have relatively large differences due to different configurations or performances, and may include one or more processors (central processing units, CPU) 510 (for example, one or more processors) and a memory 520, and one or more storage media 530 (for example, one or more mass storage devices) storing application programs 533 or data 532. Among them, the memory 520 and the storage medium 530 can be temporary storage or permanent storage. The program stored in the storage medium 530 may include one or more modules (not shown in the figure), each module may include a series of instruction operations in the endoscope data acquisition device 500. Furthermore, the processor 510 can be configured to communicate with the storage medium 530 to execute a series of instruction operations in the storage medium 530 on the endoscope data acquisition device 500.
[0079] The endoscope-based data acquisition device 500 may further include one or more power supplies 540, one or more wired or wireless network interfaces 550, one or more input and output interfaces 560, and / or one or more operating systems 531, such as Windows Server, Mac OS X, Unix, Linux, FreeBSD, etc. It will be understood by those skilled in the art that Figure 5 The structure of the endoscope data acquisition device shown does not constitute a limitation on the endoscope-based data acquisition device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.
[0080] The present invention also provides a computer-readable storage medium, which may be a non-volatile computer-readable storage medium or a volatile computer-readable storage medium. The computer-readable storage medium stores instructions, which, when executed on a computer, enable the computer to execute the steps of the endoscope data acquisition method.
[0081] In the context of the present disclosure, a machine-readable medium can be a tangible medium that can contain or store a program for use by or in conjunction with an instruction execution system, device or equipment. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium can include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0082] In addition, although adopting specific order to describe each operation, this should be understood as requiring such operation to be carried out in the specific order shown or in sequential order, or requiring that all illustrated operations should be carried out to obtain desired results. Under certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although comprising some specific implementation details in the above discussion, these should not be interpreted as limiting the scope of the present disclosure. Some features described in the context of separate embodiment can also be implemented in a single implementation in combination. On the contrary, the various features described in the context of a single implementation also can be implemented in a plurality of implementations individually or in the mode of any suitable subcombination.
[0083] Although the subject matter has been described in language specific to structural features and / or methodological logical acts, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are merely example forms of implementing the claims.
Claims
1. A data acquisition method for an endoscope, characterized in that: The data acquisition method for an endoscope is applied to an endoscope, wherein a distance measuring scale is fixed to the imaging direction of the endoscope, and the data acquisition method for an endoscope comprises: Opening the endoscope and advancing the endoscope until the distance measuring scale abuts against the target object; Invoking the endoscope to photograph the target object to obtain a photographed image; The object size of the captured image is measured according to the distance value set by the distance measuring scale to obtain the acquisition size of the target shooting object.
2. The method for collecting data from an endoscope according to claim 1, wherein: The calling of the endoscope to photograph the target object to obtain a photographed image includes: Invoking the endoscope to focus the target object to obtain a focus focal length; The endoscope is used to capture the target object and generate a captured image.
3. The method for collecting data from an endoscope according to claim 2, wherein: The measuring the object size of the captured image according to the distance value set by the distance measuring scale to obtain the acquisition size of the target captured object includes: Identifying the number of vertical pixels of a target object in the captured image to obtain a pixel value of the object; The unit pixel size of the captured image is read, and according to a preset size calculation formula, the object pixel value, the unit pixel size, the focus focal length, and the distance value are numerically calculated to obtain the acquisition size of the target captured object.
4. The method for collecting data from an endoscope according to claim 3, wherein: The size calculation formula includes: H = (n*s*D) / f, where H is the acquisition size of the target object, n is the object pixel value, s is the unit pixel size, f is the focus distance, and D is the distance value set by the rangefinder.
5. The method for collecting data from an endoscope according to claim 3, wherein: The identifying the number of vertical pixels of the target object in the captured image to obtain the object pixel value includes: Based on a preset YOLO algorithm, the captured image is classified into categories to obtain a classification graph of the target object; According to the preset OpenCV library, the pixels of the horizontal and vertical axes of the divided graphics are calculated and processed to obtain the horizontal axis pixel value and the vertical axis pixel value of the object.
6. The method for collecting data from an endoscope according to claim 5, wherein: The calculation and processing of the horizontal and vertical axis pixels of the divided graph according to the preset OpenCV library to obtain the horizontal axis pixel value and the vertical axis pixel value of the object includes: performing mask generation processing on the captured image to generate a capture mask; performing pixel filling processing on the shooting mask according to the division pattern to generate a filling mask; Performing pixel statistics processing on the horizontal and vertical axes of the filling mask to obtain the horizontal axis pixel value and the vertical axis pixel value of the object.
7. The method for collecting data from an endoscope according to claim 6, wherein: The step of performing pixel filling processing on the shooting mask according to the division pattern to generate a filling mask includes: According to the fillPoly() function, the divided graphics of the shooting mask are filled with pixels to generate a filling mask.
8. The method for collecting data from an endoscope according to claim 1, wherein: After measuring the object size of the captured image according to the distance value set by the distance measuring scale to obtain the acquisition size of the target object, the method further includes: The collected size is pushed to a preset cloud server.
9. An endoscope data acquisition device, characterized in that: The data acquisition device of the endoscope includes: a memory and at least one processor, wherein the memory stores instructions, and the memory and the at least one processor are interconnected via a line; The at least one processor calls the instructions in the memory to enable the endoscopic data acquisition device to execute the endoscopic data acquisition method according to any one of claims 1 to 8.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the endoscopic data acquisition method according to any one of claims 1 to 8 is implemented.