Endoscope image reading method and device, electronic equipment and storage medium

By allocating preset memory space for the endoscope and calculating the storage address, the problem of screen freeze when the endoscope image sensor is switched is solved, achieving smoother image display and higher operating efficiency.

CN120676232APending Publication Date: 2025-09-19SCIVITA MEDICAL TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510856787.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-25
Publication Date
2025-09-19

AI Technical Summary

Technical Problem

In the prior art, when switching endoscopic image sensors, it is necessary to reconfigure internal registers, resulting in image freeze or black screen, affecting user experience and operational efficiency.

Method used

Allocate pre-allocated memory space of N times the preset size for the endoscope, calculate the preset row space size, and automatically calculate the storage address of each row and each frame of the image sensor to avoid reconfiguring internal register parameters.

Benefits of technology

When switching image sensors, the endoscopic image displayed on the monitor is smoother, avoiding screen freezes and black screen phenomena, and improving operational efficiency and user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120676232A_ABST
    Figure CN120676232A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides an endoscope image reading method and device, electronic equipment and a storage medium, and relates to the technical field of endoscope image processing. The method comprises the following steps: allocating a pre-allocated memory space which is N times of a preset size for an endoscope, calculating a preset row space size, initializing a first initial storage address and a second initial storage address as first addresses, and storing a current image acquired by a target image sensor into the pre-allocated memory space row by row, and updating the second initial storage address and the first initial storage address into a second address for writing a next frame of image acquired by the target image sensor, the second address being the second initial storage address plus a preset size. Therefore, when the image sensor is switched, parameters of an internal register do not need to be reconfigured, and endoscopic images displayed by the monitor can be smoother.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of endoscopic image processing, and in particular to an endoscopic image reading method, device, electronic device and storage medium. Background Art

[0002] Different types of medical endoscopes are typically equipped with CMOS image sensors of varying resolutions, resulting in a variety of endoscope modes. The same endoscope image processing device can simultaneously support medical endoscopes with different CMOS resolutions. When switching between image sensors, the endoscope image processing device must adjust its internal parameter configuration to correctly process video data of the corresponding resolution and format and display clear endoscopic images on the monitor.

[0003] Current technology generally implements this function using the officially provided video processing read / write module (VDMA). This module reconfigures internal registers via its built-in AXI lite configuration interface to adapt to video inputs of varying resolutions and formats. However, when switching image sensors, register reconfiguration can cause brief freezes or black screens. This interruption in user experience not only impacts physicians' operational efficiency but also reduces overall product performance. Summary of the Invention

[0004] In view of this, an object of embodiments of the present invention is to provide an endoscopic image reading method, apparatus, electronic device, and storage medium to at least partially improve the above-mentioned problem.

[0005] In order to achieve the above objectives, the technical solutions adopted in the embodiments of the present invention are as follows: In a first aspect, an embodiment of the present invention provides an endoscopic image reading method, comprising: Allocate a pre-allocated memory space of N times a preset size to the endoscope, calculate a preset row space size, and initialize a first starting storage address and a second starting storage address to the first address; wherein N is an integer greater than 1, the endoscope is equipped with multiple image sensors of different resolutions, and the size of the pre-allocated memory space is calculated based on the image sensor with the largest resolution; the first starting storage address represents the starting address for storing row data, and the second starting storage address represents the starting address for storing frame data; the row data and the frame data are a row of data and a frame of data for a frame of image acquired by the image sensor; the preset row space size is the maximum storage space for a row of the row data; storing row data of a current image acquired by a target image sensor into the pre-allocated memory space row by row from a first starting storage address, and adding the preset row space size to the first starting storage address until all row data of the current image are stored in the pre-allocated memory space; the target image sensor is the image sensor currently in use; The second starting storage address and the first starting storage address are updated to a second address in preparation for writing the next frame of image acquired by the target image sensor; wherein the second address is the second starting storage address plus the preset size.

[0006] Optionally, allocating a pre-allocated memory space of N times a preset size for the endoscope and calculating a preset row space size includes: Obtaining a first lens resolution and a first pixel bit depth of each of the image sensors; Calculating a storage space for a single-frame image acquired by each of the image sensors according to each of the first lens resolutions and each of the first pixel bit depths; Aligning the largest storage space according to the page size of the memory to obtain an aligned pre-allocated space; Allocate a continuous space for the endoscope in the memory; wherein the size of the continuous space is the alignment pre-allocated space multiplied by N; Obtaining a second lens resolution and a second pixel bit depth of the image sensor corresponding to the largest storage space; The preset line space size is obtained by multiplying the width of the second lens resolution by the second pixel bit depth and dividing by 8.

[0007] Optionally, aligning the largest storage space according to a page size of a memory to obtain an aligned pre-allocated space includes: Obtaining a page size of the memory and a maximum target storage space among the storage spaces; Based on an alignment formula, the target storage space is rounded up to an integer multiple of the page size; the alignment formula is:

[0008] Wherein, base is the page size, x is the target storage space, Represents the integer division operator.

[0009] Optionally, the method further includes: After storing the images of multiple N-th frames into the pre-allocated memory space, the first starting storage address and the second starting storage address are reset to the first address.

[0010] Optionally, the method further includes: After updating the first starting storage address and before writing the row data, determining whether a size of the updated first starting storage address plus the row data is greater than a size of the pre-allocated memory space; If so, issue a warning; After updating the second starting storage address and before writing the row data, determining whether the updated second starting storage address plus the preset size is greater than the size of the pre-allocated memory space; If so, issue a warning.

[0011] Optionally, storing row data of the current image acquired by the target image sensor into the pre-allocated memory space row by row from a first starting storage address, and adding the preset row space size to the first starting storage address until all row data of the current image are stored in the pre-allocated memory space, includes: Acquire a target lens resolution of the target image sensor; Storing the first row of data of the current image into the pre-allocated memory space; wherein the starting point of the storage address of the first row of data is the first starting storage address; Updating the first starting storage address to make it equal to the original address plus the preset row space size; The remaining rows of data of the current image are cyclically stored in the pre-allocated memory space until the number of rows storing the current image reaches the height of the target lens resolution.

[0012] Optionally, the method further includes: When the current image is completely stored in the pre-allocated memory space, the current image is read from the pre-allocated memory space to a monitor, so as to display the current image on the monitor.

[0013] In a second aspect, an embodiment of the present invention provides an endoscopic image reading device, comprising: an initialization unit, configured to allocate a pre-allocated memory space of N times a preset size to the endoscope, calculate a preset row space size, and initialize a first starting storage address and a second starting storage address to a first address; wherein N is an integer greater than 1, the endoscope is equipped with a plurality of image sensors of different resolutions, and the size of the pre-allocated memory space is calculated based on the image sensor with the largest resolution; the first starting storage address represents a starting address for storing row data, and the second starting storage address represents a starting address for storing frame data; the row data and the frame data are a row of data and a frame of data of a frame of image acquired by the image sensor; and the preset row space size is a maximum storage space for a row of the row data; a data storage unit, configured to store row data of a current image acquired by a target image sensor into the pre-allocated memory space row by row, starting from a first starting storage address, and adding the preset row space size to the first starting storage address until all row data of the current image are stored in the pre-allocated memory space; the target image sensor being the image sensor currently in use; A storage address modification unit is used to update the second starting storage address and the first starting storage address to a second address in preparation for writing the next frame of image acquired by the target image sensor; wherein the second address is the second starting storage address plus the preset size.

[0014] In a third aspect, an embodiment of the present invention provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and running on the processor, wherein the processor implements any of the above-described methods when executing the program.

[0015] In a fourth aspect, an embodiment of the present invention provides a storage medium having a computer program stored thereon, wherein the computer program implements any of the above-described methods when executed by a processor.

[0016] An embodiment of the present invention provides an endoscopic image reading method, device, electronic device and storage medium. By allocating a pre-allocated memory space of N times a preset size to the endoscope and calculating a preset row space size, the storage address of each row and each frame of the image acquired by the target image sensor is automatically calculated according to the preset row space size and the preset size, and data is stored. Therefore, when switching image sensors, there is no need to reconfigure internal register parameters, thereby making the endoscopic image displayed on the monitor smoother.

[0017] In order to make the above-mentioned objects, features and advantages of the present application more obvious and easy to understand, preferred embodiments are given below and described in detail with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for use in the embodiments. It should be understood that the following drawings only illustrate certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other relevant drawings can be obtained based on these drawings without paying any creative work.

[0019] Figure 1 A schematic structural block diagram of an endoscope system provided in an embodiment of the present invention; Figure 2 A schematic structural block diagram of an electronic device provided by an embodiment of the present invention; Figure 3A schematic flow chart of an endoscopic image reading method provided by an embodiment of the present invention; Figure 4 Another schematic flow chart of an endoscopic image reading method provided by an embodiment of the present invention; Figure 5 Another schematic flow chart of an endoscopic image reading method provided by an embodiment of the present invention; Figure 6 This is a schematic structural block diagram of an endoscopic image reading device provided by an embodiment of the present invention.

[0020] Icons: 100 - electronic device; 101 - memory; 102 - communication interface; 103 - processor; 104 - communication bus; 300 - endoscope image reading device; 310 - initialization unit; 320 - data storage unit; 330 - storage address modification unit. DETAILED DESCRIPTION

[0021] To make the objectives, technical solutions, and advantages of the embodiments of the present invention more clear, the technical solutions of the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Generally, the components of the embodiments of the present invention described and shown in the drawings herein can be arranged and designed in various different configurations.

[0022] Therefore, the following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the invention as claimed, but rather merely represents selected embodiments of the present invention. All other embodiments derived by persons of ordinary skill in the art based on the embodiments of the present invention without creative effort shall fall within the scope of protection of the present invention.

[0023] It should be noted that similar reference numerals and letters represent similar items in the following drawings. Therefore, once an item is defined in one drawing, it does not need to be further defined or explained in subsequent drawings. At the same time, in the description of the present invention, the terms "first", "second", etc. are used only to distinguish the description and should not be understood as indicating or implying relative importance.

[0024] It should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply the existence of any such actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or device comprising the element.

[0025] As described in the background art, see Figure 1 Different types of medical endoscopes are usually equipped with CMOS image sensors of different resolutions. For example, during a multi-stage operation, at the beginning of the operation, the doctor may need a medium-resolution image sensor to quickly locate the lesion area or perform a preliminary examination. This sensor can provide sufficient field of view and clarity to help doctors understand the overall situation. When entering the critical stage of the operation, such as removing a tumor, repairing tissue, or suturing blood vessels, the doctor may need to switch to a high-resolution image sensor to observe subtle structures more clearly and ensure the accuracy of the operation. However, the current technical solution requires reconfiguring the internal registers through its own AXIlite configuration interface when switching image sensors of different resolutions, resulting in a brief freeze or black screen on the monitor.

[0026] Based on the above situation, an embodiment of the present invention provides an endoscopic image reading method, device, electronic device and storage medium, which allocates a pre-allocated memory space of N times the preset size to the endoscope and calculates the preset row space size. The storage address of each row and each frame of the image acquired by the target image sensor is automatically calculated according to the preset row space size and the preset size, and the data is stored. In this way, when switching the image sensor, there is no need to reconfigure the internal register parameters, and the endoscopic image displayed on the monitor can be smoother.

[0027] To implement the process steps and functions of each example of the present invention, please refer to Figure 2 , Figure 2This is a schematic block diagram of an electronic device provided in an embodiment of the present invention. The electronic device 100 includes a memory 101 and a processor 103. The memory 101 and processor 103 are electrically connected to each other, directly or indirectly, to enable data transmission or interaction. For example, these components can be electrically connected to each other via one or more communication buses 104 or signal lines. The memory 101 can be used to store software programs and modules, and the processor 103 executes the software programs and modules stored in the memory 101, thereby performing various functional applications and data processing.

[0028] The electronic device 100 can employ an embedded architecture, such as a field-programmable gate array (FPGA) or an application-specific integrated circuit (ASIC), to enable high-speed image data processing and real-time memory address calculation. The memory 101 is preferably high-speed DDR memory, supporting the FPGA's data read and write via a direct memory access (DMA) interface, ensuring time consistency of row-by-row storage. The electronic device 100 can also be, but is not limited to, a personal computer (PC), a server, a distributed computer, and the like. It is understood that the electronic device 100 is not limited to a physical server and can also be a virtual machine on a physical server, a virtual machine built on a cloud platform, or other computer that provides the same functionality as a server or virtual machine. The operating system of the electronic device 100 can be, but is not limited to, Windows, Linux, or the like.

[0029] The memory 101 may be, but is not limited to, a random access memory (RAM), a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), etc.

[0030] The communication connection between the electronic device 100 and an external device is achieved through at least one communication interface 102 (which can be wired or wireless).

[0031] Processor 103 may be an integrated circuit chip with signal processing capabilities. During implementation, each step of the embodiments of the present invention may be completed by hardware integrated logic circuits within processor 103 or by software instructions. Processor 103 may be a general-purpose processor, including a central processing unit (CPU) or a network processor (NP); it may also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. If processor 103 utilizes an FPGA architecture, its internal logic may include a timing control module that implements real-time configuration of sensor clocks and synchronization signals using a hardware description language (such as Verilog / VHDL) to ensure consistency between data transmission timing and memory write timing. Processor 103 may also include a timing control unit that generates matching hardware timing signals (such as pixel clock, VSYNC / HSYNC) based on the sensor clock frequency and synchronization signal parameters to control the pace of data acquisition and memory writes.

[0032] I understand. Figure 2 The structure shown is for illustration only. The electronic device 100 may further include Figure 2 More or fewer components than shown, or with Figure 2 Different configurations shown. Figure 2 Each component shown in the figure can be implemented by hardware, software or a combination thereof.

[0033] The following is an exemplary description of the endoscopic image reading method provided by the present invention. Figure 3 For, see Figure 3 , the execution subject of this method can be the above Figure 2 The electronic device 100 shown in FIG. 1 includes the following steps: Figure 3 The following steps are described: S210: Allocate a pre-allocated memory space of N times the preset size for the endoscope, calculate a preset row space size, and initialize a first starting storage address and a second starting storage address to a first address.

[0034] Wherein, N is an integer greater than 1, the endoscope is equipped with multiple image sensors with different resolutions, and the size of the pre-allocated memory space is calculated based on the image sensor with the largest resolution; the first starting storage address represents the starting address for storing row data, and the second starting storage address represents the starting address for storing frame data; the row data and frame data are a row of data and a frame of data for a frame of image acquired by the image sensor; the preset row space size is the maximum storage space for a row of row data.

[0035] S240: storing row data of the current image acquired by the target image sensor into the pre-allocated memory space row by row from the first starting storage address, and adding a preset row space size to the first starting storage address until all row data of the current image are stored in the pre-allocated memory space.

[0036] The target image sensor is the image sensor currently in use.

[0037] S250: Update the second starting storage address and the first starting storage address to a second address for writing the next frame of image acquired by the target image sensor, wherein the second address is the second starting storage address plus a preset size.

[0038] Allocate sufficient memory space in advance for image sensors of all resolutions (such as 1080P, 4K, etc.) to avoid real-time allocation delays. Specifically, if the endoscope is equipped with multiple image sensors of varying resolutions, the size of the pre-allocated memory space is calculated based on the image sensor with the highest resolution. Furthermore, the first and second starting storage addresses are initialized to the same address. As can be understood, this initialization operation defines two address pointers: current_row_addr: the starting storage address for the current row of data; current_frame_addr: the starting storage address for the current frame. During initialization, the first data point of the current image captured by the image sensor and the first data point of the first row of the current image are identical. Therefore, the first and second starting storage addresses are set to the same address, for example, 0x0000.

[0039] When the target image sensor acquires an image, it reads pixels row by row into the image processor until all rows of data for a frame are output, forming a complete frame of image data. This solution stores each row of data starting with the first starting storage address. After the first row of data is stored, the first starting storage address is updated to prepare for the second row of data. The first starting storage address is updated by adding the preset row space to the original address. This process continues until the current frame of data is stored.

[0040] After storing one frame of image data, it is necessary to update the starting address for storing the next frame of image, and at the same time update the second starting storage address and the first starting storage address to a second address, which is the second starting storage address plus a preset size.

[0041] For example, the preset size is 16588800 bytes, N is 3, then the allocated pre-allocated memory space is 49766400 bytes, the preset row space size is 7680, and the initialized first starting storage address and second starting storage address are 0x0000. The storage process in this case is to store the first row of data of the first frame image starting from 0x0000. After the first row of data is stored, the first starting storage address is modified to 0x0000+7680=0x1E00, and the next row of data is stored starting from this address 0x1E00. After the current frame of image is stored, the second starting storage address and the first starting storage address are updated to 0x0000+16588800=0xFD2000, and the next frame of image is stored starting from this address. When switching to another image sensor for inspection, the first starting storage address and the second starting storage address are reset to 0x0000, and the image obtained by the image sensor is stored. For the image of the image sensor, when a row of data is completely stored, the first starting storage address is still plus the preset row space size of 7680. When a frame of image data is completely stored, the starting address of the next frame storage is still plus the preset size of 16588800.

[0042] This method pre-allocates memory space and presets the row space size for the endoscope, and adaptively stores data based on signals such as row field synchronization input by the current actual image sensor. This eliminates the need to reconfigure internal register parameters when switching image sensors, thereby making the endoscopic image displayed on the monitor smoother.

[0043] Steps S220 and S230 may also be included between S210 and S240: S220: Acquire the clock frequency, synchronization signal parameters, and data interface protocol parameters of the target sensor, wherein the target image sensor is the image sensor currently in use.

[0044] S230: Configure the hardware interface timing register according to the clock frequency and synchronization signal of the target sensor to ensure that the data acquisition and memory write rates are consistent.

[0045] Synchronous signal parameters can be VSYNC polarity, HSYNC width, etc., and data interface protocol parameters can be MIPILane number, etc. The clock frequency of the target sensor can be obtained by reading its register 0x10, and the synchronous signal polarity is stored in bits [3:2] of register 0x12.

[0046] The core function of S220 and S230 is to implement hardware-level timing synchronization control, with the following technical effects: clock frequency matching. According to the clock frequency of the target sensor (such as sampling rate and data output rate), the timing registers of the hardware interface (such as GPIO, SPI, I2C, etc.) are configured to align the read and write rates of the controller (such as MCU, FPGA) with the output rate of the sensor, avoiding data loss or misalignment due to frequency mismatch; synchronous signal processing. Synchronous signals (such as clock signals and frame synchronization signals) are used to identify the start and rhythm of data. Register configuration is used to align the synchronization signals of the hardware interface and the sensor to ensure the timing correctness of data acquisition (for example, reading data on the correct clock edge); rate consistency is guaranteed. Inconsistent rates between data acquisition and memory writes may cause buffer overflow or idleness. Timing register configuration (such as setting read and write delays and clock division coefficients) can balance the sensor output rate and memory write rate, avoiding system anomalies caused by timing deviations (such as data frame misalignment and frame loss).

[0047] In order to make the pre-allocated memory space adaptable to image sensors of various resolutions and to display images more smoothly on the monitor. In a possible implementation, see Figure 4 The steps of allocating N times of the preset size of pre-allocated memory space for the endoscope and calculating the preset row space size may include: S211: Acquire a first lens resolution and a first pixel bit depth of each image sensor.

[0048] S212: Calculating the storage space of the single-frame image acquired by each image sensor according to each first lens resolution and each first pixel bit depth.

[0049] S213: Align the largest storage space according to the page size of the memory to obtain aligned pre-allocated space.

[0050] S214: Allocate a continuous space for the endoscope in the memory; wherein the size of the continuous space is the alignment pre-allocated space multiplied by N.

[0051] S215: Obtain the second lens resolution and the second pixel bit depth of the image sensor corresponding to the largest storage space.

[0052] S216: Multiply the width of the second lens resolution by the second pixel bit depth and divide by 8 to obtain a preset line space size.

[0053] Obtain the lens resolution and pixel bit depth of all configured image sensors, for example, 1920×1080, 2560×1440, and 3840×2160, all with a 16-bit pixel bit depth. Calculate the storage space required for a single frame of image captured by each image sensor using the formula W×H×B÷8, where W is the width of the resolution, H is the height of the resolution, and B is the pixel bit depth. The maximum storage space is 3840×2160×16÷2 = 16,588,800 bytes. Align this storage space to the memory page size, meaning the storage space should be a multiple of the page size. Finally, allocate a contiguous portion of memory for the endoscope. The size of this contiguous space is the pre-allocated space multiplied by N. For example, if N is 3, the final pre-allocated space allocated is 16,588,800×3 = 49,766,400 bytes. The purpose of allocating space for several frames is to ensure that after one frame is stored in memory, the next frame is stored at a new address when the monitor reads it, ensuring that display and capture do not interfere with each other. The maximum storage space corresponds to an image sensor lens resolution of 3840×2160. The preset row space size is calculated by multiplying the width of this resolution by its pixel depth and dividing it by 8. This preset row space size is used to calculate the starting address for storing the next row of data. In step S212, the single-frame storage space can also be calculated based on the lens resolution (width W, height H), pixel depth B, and pixel format (e.g., RGB, YUV): Storage space = W × H × B × F ÷ 8, where F is the pixel format coefficient (RGB = 3, YUV = 2, RAW = 1). If the sensor resolution is not fixed (e.g., a variable focus lens), the pre-allocated space is calculated as "maximum width × maximum height × highest bit depth × pixel format coefficient × N" to avoid resource waste caused by a fixed maximum resolution.

[0054] Step S213 may include: Get the memory page size and the maximum target storage space among all storage spaces.

[0055] Based on the alignment formula, the target storage space is rounded up to an integer multiple of the page size; the alignment formula is:

[0056] Among them, base is the page size, x is the target storage space, Represents the integer division operator.

[0057] First, obtain the memory page size and the largest target storage space among the storage spaces. For example, in the above example, the target storage space is 16588800 and the page size is 4096. Using the alignment formula, 16588800 is rounded up to an integer multiple of 4096, which is 16588800. Since 16588800 is a multiple of 4096, it remains 16588800 after alignment. For example, if the target storage space is 1920 × 1080 × 16 ÷ 8 = 4147200, 4147200 is rounded up to an integer multiple of 4096, which is 4149248.

[0058] In order to implement a multi-frame buffer mechanism for various image sensors, in a possible implementation, the method may further include: After storing the images of the multiple N-th frames into the pre-allocated memory space, the first starting storage address and the second starting storage address are reset to the first address.

[0059] For example, if N is 3, when storing an image in the pre-allocated memory space, the first frame is stored starting at the first address, and storage continues until the third frame is complete. At this point, three frames of images are stored in the pre-allocated memory space. When storing the fourth frame, the preset size is no longer added directly to the second starting storage address. Instead, storage of the fourth frame begins again at the first address. After storing the sixth frame, the seventh frame is stored in the same manner. This approach ensures that various image sensors can easily implement multi-frame buffering without affecting image reading on the monitor.

[0060] Although theoretically, through the above storage logic, the data written each time will not exceed the size of the pre-allocated memory space, in order to ensure that data storage does not overflow the pre-allocated space, the method may further include: After updating the first starting storage address and before writing the row data, it is determined whether the size of the updated first starting storage address plus the row data is greater than the size of the pre-allocated memory space; if so, a warning is issued.

[0061] After the second starting storage address is updated and before the row data is written, it is determined whether the updated second starting storage address plus the preset size is greater than the size of the pre-allocated memory space; if so, a warning is issued.

[0062] After updating the first starting storage address, the next row of data needs to be written. At this time, the next row of data is first added to the updated first starting storage address to determine whether it exceeds the pre-allocated memory space. If it does, it indicates that there is a problem with the address allocation, so a warning needs to be issued. Similarly, after updating the second starting storage address, the next frame of data needs to be written. At this time, the next frame of data is first added to the updated second starting storage address to determine whether it exceeds the pre-allocated memory space. If it does, it indicates that there is a problem with the address allocation, so a warning needs to be issued.

[0063] See also Figure 5 In one possible implementation, the step of storing the current image line by line into the pre-allocated memory space may include: S241: Acquire a target lens resolution of a target image sensor.

[0064] S242: Store the first row of data of the current image into the pre-allocated memory space.

[0065] The starting point of the first row of data storage addresses is the first starting storage address.

[0066] S243: Update the first starting storage address to be equal to the original address plus the preset row space size.

[0067] S244: cyclically storing the remaining rows of data of the current image into the pre-allocated memory space until the number of rows storing the current image reaches the height of the target lens resolution.

[0068] The first row of data for the current image is stored in the preallocated memory space, starting at the first starting storage address. After storing this row of data, the first starting storage address needs to be updated to equal the original address plus the preset row space size. After updating the first starting storage address, the next row of data is stored until the entire current image is stored in the preallocated memory space. The logic for storing all rows is that the number of rows of the current image reaches the target lens resolution. For example, for a 1920×1080 resolution image sensor, the logic for storing a frame of image is that 1080 rows of data have been stored, indicating that the entire frame of image has been stored in the preallocated memory space.

[0069] In order to quickly display the acquired image on the monitor, in a possible implementation, the method may further include: When the current image is completely stored in the pre-allocated memory space, the current image is read from the pre-allocated memory space to the monitor to display the current image on the monitor.

[0070] When a frame of image is completely stored in the pre-allocated memory space, the image can be read to the monitor, and the monitor can display the frame of image.

[0071] Furthermore, an embodiment of the present invention also provides an endoscopic image reading device, see Figure 6 , the endoscopic image reading device 300 includes: The initialization unit 310 is used to allocate a pre-allocated memory space of N times the preset size for the endoscope and calculate the preset row space size, and initialize the first starting storage address and the second starting storage address to the first address; wherein N is an integer greater than 1, the endoscope is equipped with multiple image sensors with different resolutions, and the size of the pre-allocated memory space is calculated by the image sensor with the maximum resolution; the first starting storage address represents the starting address for storing row data, and the second starting storage address represents the starting address for storing frame data; the row data and the frame data are a row of data and a frame of data of a frame of image acquired by the image sensor; the preset row space size is the maximum storage space for a row of row data.

[0072] The data storage unit 320 is used to store the row data of the current image acquired by the target image sensor into the pre-allocated memory space row by row from a first starting storage address, and add a preset row space size to the first starting storage address until all the row data of the current image are stored in the pre-allocated memory space; wherein the target image sensor is the image sensor currently in use.

[0073] The storage address modifying unit 330 is used to update the second starting storage address and the first starting storage address to a second address for writing the next frame of image acquired by the target image sensor; wherein the second address is the second starting storage address plus a preset size.

[0074] The endoscopic image reading device 300 may further include a parameter acquisition unit configured to acquire the clock frequency, synchronization signal polarity, and data interface protocol parameters of the target sensor. The aforementioned parameters may be acquired by reading the sensor register via the I2C / SPI interface.

[0075] The endoscopic image reading device 300 may further include a sensor control unit, which is used to reconfigure the hardware timing according to the clock frequency and data interface protocol (such as LVDS, MIPI CSI) of the target sensor to ensure stable acquisition and transmission of image data.

[0076] The sensor control unit is specifically responsible for hardware initialization during switching: resetting the sensor clock divider to match the current sensor's pixel clock (for example, switching from 74.25MHz for 1080P to 297MHz for 4K); and reconfiguring the data interface protocol (such as the number of lanes in MIPI CSI-2) to ensure that the data transmission rate matches the sensor output.

[0077] In one embodiment, when the target sensor is a 4K (3840×2160) model, its clock frequency is 297MHz, VSYNC is rising-edge triggered, and the MIPI CSI-2 configuration is 4-Lane. The timing control unit needs to set the hardware interface's clock divider register to 0x00 (no divider), the VSYNC polarity register to 0x01, and the MIPI lane number register to 0x04 to ensure that the data acquisition rate is consistent with the sensor output.

[0078] In summary, the embodiments of the present invention provide an endoscopic image reading method, device, electronic device, and storage medium. By allocating a pre-allocated memory space of N times a preset size to the endoscope and calculating a preset row space size, the storage address of each row and each frame of the image acquired by the target image sensor is automatically calculated according to the preset row space size and the preset size, and data is stored. Therefore, when switching the image sensor, there is no need to reconfigure the internal register parameters, thereby making the endoscopic image displayed on the monitor smoother.

[0079] In the embodiments provided by the present invention, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely illustrative. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architectures, functions, and operations of the devices, methods, and computer program products according to multiple embodiments of the present invention. In this regard, each box in the flowchart or block diagram can represent a module, program segment, or part of the code, which contains one or more executable instructions for implementing the specified logical functions. It should also be noted that in some alternative implementations, the functions marked in the boxes can also occur in an order different from that marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, as well as the combination of boxes in the block diagram and / or flowchart, can be implemented using a dedicated hardware-based system that performs the specified functions or actions, or can be implemented using a combination of dedicated hardware and computer instructions.

[0080] In addition, the functional modules in the various embodiments of the present invention may be integrated together to form an independent part, or each module may exist independently, or two or more modules may be integrated to form an independent part.

[0081] If a function is implemented as a software module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the portion that contributes to the prior art, or the portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a computer-readable storage medium and includes several instructions for causing a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the various embodiments of the method of the present invention. The aforementioned storage medium includes various media that can store program code, such as USB flash drives, mobile hard drives, read-only memories (ROMs), random access memories (RAMs), magnetic disks, or optical disks.

[0082] The above are merely preferred embodiments of the present invention and are not intended to limit the present invention. Those skilled in the art will readily appreciate that various modifications and variations of the present invention are possible. Any modifications, equivalent substitutions, or improvements made within the spirit and principles of the present invention shall be included within the scope of protection of the present invention.

[0083] It will be apparent to those skilled in the art that the present invention is not limited to the details of the exemplary embodiments described above and that the invention can be embodied in other specific forms without departing from the spirit or essential characteristics of the invention. Therefore, the embodiments should be considered in all respects as illustrative and non-restrictive, and the scope of the invention is defined by the appended claims, not the foregoing description, and all variations within the meaning and range of equivalents of the claims are intended to be included therein. Any reference sign in a claim should not be construed as limiting the claim to which it relates.

Claims

1. A method for reading an endoscope image, characterized in that: include: Allocate a pre-allocated memory space of N times a preset size to the endoscope, calculate a preset row space size, and initialize a first starting storage address and a second starting storage address to the first address; wherein N is an integer greater than 1, the endoscope is equipped with multiple image sensors of different resolutions, and the size of the pre-allocated memory space is calculated based on the image sensor with the largest resolution; the first starting storage address represents the starting address for storing row data, and the second starting storage address represents the starting address for storing frame data; the row data and the frame data are a row of data and a frame of data for a frame of image acquired by the image sensor; the preset row space size is the maximum storage space for a row of the row data; storing row data of a current image acquired by a target image sensor into the pre-allocated memory space row by row from a first starting storage address, and adding the preset row space size to the first starting storage address until all row data of the current image are stored in the pre-allocated memory space; the target image sensor is the image sensor currently in use; The second starting storage address and the first starting storage address are updated to a second address in preparation for writing the next frame of image acquired by the target image sensor; wherein the second address is the second starting storage address plus the preset size.

2. The method according to claim 1, characterized in that The method of allocating N times of the preset size of pre-allocated memory space for the endoscope and calculating the preset row space size includes: Obtaining a first lens resolution and a first pixel bit depth of each of the image sensors; Calculating a storage space for a single-frame image acquired by each of the image sensors according to each of the first lens resolutions and each of the first pixel bit depths; Aligning the largest storage space according to the page size of the memory to obtain an aligned pre-allocated space; Allocate a continuous space for the endoscope in the memory; wherein the size of the continuous space is the alignment pre-allocated space multiplied by N; Obtaining a second lens resolution and a second pixel bit depth of the image sensor corresponding to the largest storage space; The preset line space size is obtained by multiplying the width of the second lens resolution by the second pixel bit depth and dividing by 8.

3. The method according to claim 2, characterized in that The step of aligning the largest storage space according to the page size of the memory to obtain the aligned pre-allocated space includes: Obtaining a page size of the memory and a maximum target storage space among the storage spaces; Based on an alignment formula, the target storage space is rounded up to an integer multiple of the page size; the alignment formula is: Wherein, base is the page size, x is the target storage space, Represents the integer division operator.

4. The method according to claim 1, wherein The method further comprises: After storing the images of multiple N-th frames into the pre-allocated memory space, the first starting storage address and the second starting storage address are reset to the first address.

5. The method according to claim 1, wherein The method further comprises: After updating the first starting storage address and before writing the row data, determining whether a size of the updated first starting storage address plus the row data is greater than a size of the pre-allocated memory space; If so, issue a warning; After updating the second starting storage address and before writing the row data, determining whether the updated second starting storage address plus the preset size is greater than the size of the pre-allocated memory space; If so, issue a warning.

6. The method according to claim 2, characterized in that The step of storing row data of a current image acquired by a target image sensor into the pre-allocated memory space row by row from a first starting storage address, and adding the preset row space size to the first starting storage address until all row data of the current image are stored in the pre-allocated memory space includes: Acquire a target lens resolution of the target image sensor; Storing the first row of data of the current image into the pre-allocated memory space; wherein the starting point of the storage address of the first row of data is the first starting storage address; Updating the first starting storage address to make it equal to the original address plus the preset row space size; The remaining rows of data of the current image are cyclically stored in the pre-allocated memory space until the number of rows storing the current image reaches the height of the target lens resolution.

7. The method according to claim 1, characterized in that The method further comprises: When the current image is completely stored in the pre-allocated memory space, the current image is read from the pre-allocated memory space to a monitor, so as to display the current image on the monitor.

8. An endoscopic image reading device, characterized in that: include: an initialization unit, configured to allocate a pre-allocated memory space of N times a preset size to the endoscope, calculate a preset row space size, and initialize a first starting storage address and a second starting storage address to a first address; wherein N is an integer greater than 1, the endoscope is equipped with a plurality of image sensors of different resolutions, and the size of the pre-allocated memory space is calculated based on the image sensor with the largest resolution; the first starting storage address represents a starting address for storing row data, and the second starting storage address represents a starting address for storing frame data; the row data and the frame data are a row of data and a frame of data of a frame of image acquired by the image sensor; and the preset row space size is a maximum storage space for a row of the row data; a data storage unit, configured to store row data of a current image acquired by a target image sensor into the pre-allocated memory space row by row, starting from a first starting storage address, and adding the preset row space size to the first starting storage address until all row data of the current image are stored in the pre-allocated memory space; the target image sensor being the image sensor currently in use; A storage address modification unit is used to update the second starting storage address and the first starting storage address to a second address in preparation for writing the next frame of image acquired by the target image sensor; wherein the second address is the second starting storage address plus the preset size.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that: When the processor executes the program, the method according to any one of claims 1 to 7 is implemented.

10. A storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.