Preset position offset identification and correction method, system, device, storage medium and program product for a pan-tilt camera
By acquiring standard preset position data and reference images of the PTZ camera, detecting and calculating the offset, and using the offset correction PT value to correct the preset position offset of the PTZ camera, the problem of the inability to automatically and intelligently correct the offset in the existing technology is solved, and a highly efficient and reliable position correction effect is achieved.
Patent Information
- Application Number
- CN202511452851.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-13
- Publication Date
- 2025-12-23
- Estimated Expiration
- 2045-10-13
AI Technical Summary
Existing technologies cannot automatically and intelligently detect and effectively correct the offset of the preset position of the PTZ camera, resulting in a deviation between the image and the expected image when the preset position is invoked. Furthermore, existing solutions are inefficient or have low reliability.
By acquiring the original PTZ data and reference image of the standard preset position of the PTZ camera, the camera is controlled to adjust to the actual position, the image is detected to see if it contains the content of the reference image, the pixel offset is calculated, and the position is corrected by using the offset correction PT value and the original PTZ data.
It enables automatic and intelligent offset detection and correction of PTZ cameras, ensuring that the desired image of the target scene can still be accurately acquired even when the offset is large, thus improving efficiency and reliability.
Smart Images

Figure CN120935449B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of camera calibration technology, and in particular to a method, system, electronic device, computer-readable storage medium, and computer program product for identifying and correcting preset position offset of a pan-tilt camera. Background Technology
[0002] With the increasing level of industrial automation, the use of PTZ cameras to replace manual labor in tasks such as inspections is becoming increasingly common. For example, due to the flexible rotation capability of PTZ cameras, they can be used to inspect instruments or equipment. The PTZ camera can rotate to a preset position based on inspection commands to obtain images of the area of interest. This eliminates the need for personnel to be exposed to dangerous environments such as high temperatures, high pressures, and toxic substances, and also shortens the inspection time and reduces the workload of manual inspections.
[0003] However, during use, due to cumulative errors during pan-tilt rotation, wear and tear on the mechanical structure, loosening or movement of the bracket, the preset position of the pan-tilt camera is easily offset, resulting in a discrepancy between the image seen after calling the preset position and the expected image, making it impossible to accurately align with the target scene.
[0004] To address the aforementioned preset position offset issue, one existing solution is periodic manual inspection and recalibration. This requires manually adjusting the threshold positions and updating parameters one by one, which is time-consuming, labor-intensive, and inefficient. Furthermore, for cameras installed at high locations or in dangerous areas, the maintenance costs are high and the risks are significant. Another solution is to set photoelectric correction points in the target scene to identify and correct the offset. However, when the offset is too large, the correction points may be lost, resulting in lower reliability and higher costs.
[0005] Therefore, there is an urgent need in this field for a method that can automatically and intelligently detect the offset of a preset position and ensure that the offset can still be effectively corrected when the offset is large. Summary of the Invention
[0006] The main objective of this invention is to solve the technical problem in the prior art that it is impossible to automatically, intelligently and effectively detect and correct the offset of the preset position of the PTZ camera.
[0007] The first aspect of this invention provides a method for identifying and correcting preset position offset of a PTZ camera, comprising:
[0008] Acquire raw PTZ data and raw reference image of the standard preset position of the PTZ camera;
[0009] Control the pan-tilt camera to adjust to the actual preset position and capture the first image;
[0010] Detect whether the first image contains all or part of the content of the original reference image;
[0011] If the first image contains all or part of the content of the original reference image, then an offset calculation is performed based on the first image and the original reference image to obtain the first pixel offset.
[0012] If the first image does not contain all or part of the content of the original reference image, then the first PT value data corresponding to the first image is obtained, the first PT value data is used as the adjustment reference, the position of the pan-tilt camera is adjusted by the preset PT value data, and the adjusted image is obtained.
[0013] Calculate the shifted pixel offset between the adjusted image and the first image;
[0014] Based on the image resolution of the original reference image, a motion range threshold is set, and the PT value data adjustment amount is recorded when the motion pixel offset first exceeds the motion range threshold to obtain the camera motion step size.
[0015] Based on the camera's movement step size, the PT-camera is moved in multiple directions around the camera and images are captured to obtain a second image in eight directions around the first PT value data.
[0016] Detect whether each of the second images contains all or part of the content of the original reference image;
[0017] If there exists a second image that contains all or part of the content of the original reference image, then an offset calculation is performed based on the second image containing all or part of the content of the original reference image and the original reference image to obtain the second pixel offset.
[0018] Determine whether the offset of the first pixel or the offset of the second pixel exceeds the offset recognition threshold;
[0019] If the offset recognition threshold is not exceeded, then the actual preset position has not shifted or does not require offset correction.
[0020] If the offset recognition threshold is exceeded, the actual preset position has shifted and offset correction is required. The offset correction PT value is calculated based on the first pixel offset or the second pixel offset, and the offset recognition and correction of the preset position is completed based on the offset correction PT value and the Z value in the original PTZ data.
[0021] Optionally, in a first implementation of the first aspect of the present invention, after detecting whether each of the second images contains all or part of the content of the original reference image, the method further includes:
[0022] If there is no second image containing all or part of the original reference image, then the pan-tilt camera is controlled to zoom and acquire multiple third images around the first image as the center.
[0023] Detect whether each of the third images contains part or all of the content of the original reference image;
[0024] If each of the third images contains part or all of the content of the original reference image, then an offset calculation is performed based on the third image containing all or part of the content of the original reference image and the original reference image to obtain the third pixel offset.
[0025] The method for identifying and correcting the preset position offset of the PTZ camera further includes:
[0026] Determine whether the offset of the third pixel exceeds the offset recognition threshold;
[0027] If the offset recognition threshold is exceeded, the actual preset position has shifted and offset correction is required. The offset correction PT value is calculated based on the third pixel offset, and the offset recognition and correction of the preset position is completed based on the offset correction PT value and the Z value in the original PTZ data.
[0028] Optionally, in a second implementation of the first aspect of the present invention, after calculating the offset correction PT value based on the first pixel offset or the second pixel offset, or after calculating the offset correction PT value based on the first pixel offset or the second pixel offset, the method further includes:
[0029] The fourth image is obtained based on the offset correction PT value and the original Z value, and the fourth pixel offset of the fourth image relative to the original reference image is calculated.
[0030] Determine whether the offset of the fourth pixel exceeds the offset recognition threshold;
[0031] If the offset of the fourth pixel does not exceed the offset recognition threshold, the offset recognition and correction process at the preset position ends.
[0032] If the offset of the fourth pixel exceeds the offset recognition threshold, the fine-tuning algorithm is invoked to perform offset recognition and correction again, and the fourth image is obtained again based on the corrected position.
[0033] Determine whether the fourth pixel offset of the fourth image relative to the original reference image after the fine-tuning algorithm is called again to perform offset recognition and correction exceeds the offset recognition threshold;
[0034] If the offset of the fourth pixel of the fourth image after offset recognition and correction is not exceeded by the offset recognition threshold after the fine-tuning algorithm is called again, the offset recognition and correction process at the preset position ends.
[0035] If the offset of the fourth pixel of the fourth image after offset recognition and correction is executed again by calling the fine-tuning algorithm exceeds the offset recognition threshold, then it is determined whether the current correction time exceeds the preset correction time threshold, or whether the current number of corrections exceeds the preset number of corrections threshold.
[0036] If the current correction time has exceeded the preset correction time threshold, or the current number of corrections has exceeded the preset number of corrections threshold, then the process of offset identification and correction of the preset position ends.
[0037] Optionally, in a third implementation of the first aspect of the present invention, the movement range threshold includes a horizontal movement range threshold and a vertical movement range threshold, expressed as:
[0038] Horizontal movement range threshold = ;
[0039] Vertical movement range threshold = ;
[0040] Where W represents the horizontal resolution of the original reference image, H represents the vertical resolution of the original reference image, and n represents the number of segments.
[0041] When the pan-tilt camera moves in multiple directions around the camera and captures images based on the camera's movement step size, the number of steps moved in each direction ranges from [1, n-1].
[0042] Optionally, in a fourth implementation of the first aspect of the present invention, the step of calculating the second pixel offset based on the second image containing all or part of the original reference image and the original reference image includes:
[0043] Image feature points are extracted from the second image and the original reference image based on the image feature detection algorithm. Point matching is then performed based on the extracted image feature points. The distance between the successfully matched image feature points is calculated to obtain the pixel offset of the second image relative to the original reference image.
[0044] The movement offset is calculated based on the camera's movement step size and the total number of steps the second image moves during acquisition;
[0045] The second pixel offset is obtained by summing the pixel offset and the movement offset.
[0046] Optionally, in a fourth implementation of the first aspect of the present invention, before controlling the PTZ camera to adjust to the actual preset position and acquiring the first image, the horizontal field of view and vertical field of view of the PTZ camera at the standard preset position are acquired.
[0047] The offset correction PT value includes a horizontal offset correction value and a vertical offset correction value;
[0048] When calculating the offset correction PT value based on the first pixel offset or the second pixel offset, the specific expression is as follows:
[0049]
[0050]
[0051] in, This indicates the horizontal offset correction value. This indicates the vertical offset correction value. This indicates the horizontal rotation value of the current gimbal position. This represents the vertical rotation value of the current gimbal position. This represents the calculated pixel offset in the x-direction. This represents the calculated pixel offset in the y-direction. This indicates the horizontal field of view of the pan-tilt camera. The vertical field of view of the PTZ camera is represented by , W represents the horizontal resolution of the PTZ camera, and H represents the vertical resolution of the PTZ camera.
[0052] A second aspect of the present invention provides a preset position offset recognition and correction system for a PTZ camera, comprising:
[0053] The reference acquisition module is used to acquire the raw PTZ data and the raw reference image of the standard preset position of the PTZ camera.
[0054] The image detection module is used to control the PTZ camera to adjust to the actual preset position and acquire a first image; and to detect whether the first image contains all or part of the content of the original reference image.
[0055] The offset calculation module is used to perform offset calculation based on the first image and the original reference image if the first image contains all or part of the content of the original reference image, so as to obtain the first pixel offset.
[0056] The image detection module, if the first image does not contain all or part of the content of the original reference image, is further configured to: acquire the first PT value data corresponding to the first image; use the first PT value data as an adjustment reference; adjust the position of the pan-tilt camera by a preset PT value data unit and acquire the adjusted image; calculate the pixel offset between the adjusted image and the first image; set a movement range threshold based on the image resolution of the original reference image; record the PT value data adjustment amount when the pixel offset first exceeds the movement range threshold to obtain the camera movement step size; and move the pan-tilt camera in multiple directions around the camera movement step size and capture images to obtain a second image in eight directions around the first PT value data.
[0057] The offset calculation module is further configured to detect whether each of the second images contains all or part of the content of the original reference image; if there is a second image containing all or part of the content of the original reference image, then offset calculation is performed based on the second image containing all or part of the content of the original reference image and the original reference image to obtain the second pixel offset;
[0058] The offset recognition and correction module is used to determine whether the first pixel offset or the second pixel offset exceeds the offset recognition threshold; if it does not exceed the offset recognition threshold, the actual preset position has not been offset or does not need to be offset corrected; if it exceeds the offset recognition threshold, the actual preset position has been offset and offset correction is required. The module calculates the offset correction PT value based on the first pixel offset or the second pixel offset, and completes the offset recognition and correction of the preset position based on the offset correction PT value and the Z value in the original PTZ data.
[0059] A third aspect of the present invention provides a preset position offset identification and correction device for a PTZ camera, comprising: a memory and at least one processor, wherein the memory stores instructions; the at least one processor invokes the instructions in the memory to cause the preset position offset identification and correction device of the PTZ camera to perform the steps of the preset position offset identification and correction method of the PTZ camera described above.
[0060] A fourth aspect of the present invention provides a computer-readable storage medium storing instructions that, when executed on a computer, cause the computer to perform the steps of the above-described method for identifying and correcting preset position offsets of a PTZ camera.
[0061] The fifth aspect of the present invention provides a computer program product, including a computer program / instruction that, when executed by a processor, implements the steps of the preset position offset identification and correction method for a PTZ camera as described above.
[0062] The technical solution provided by this invention involves: acquiring the original PTZ data of a standard preset position of a PTZ camera and the original reference image of the standard preset position; controlling the PTZ camera to adjust to the actual preset position and acquiring a first image; detecting whether the first image contains all or part of the content of the original reference image; if the first image contains all or part of the content of the original reference image, then performing offset calculation based on the first image and the original reference image to obtain a first pixel offset; if the first image does not contain all or part of the content of the original reference image, then acquiring a second image around the first image that contains all or part of the content of the original reference image, and performing offset calculation based on the second image and the original reference image to obtain a second pixel offset; determining whether the first pixel offset or the second pixel offset exceeds an offset recognition threshold; if it does not exceed the offset recognition threshold, then the actual preset position has not shifted or does not need offset correction; if it exceeds the offset recognition threshold, then the actual preset position has shifted and needs offset correction, calculating an offset correction PT value based on the first pixel offset or the second pixel offset, and completing the offset recognition and correction of the preset position based on the offset correction PT value and the Z value in the original PTZ data.
[0063] The beneficial effect of the method provided in this invention is that it can effectively identify the offset of the pan-tilt position, automatically and intelligently detect the offset of the preset position of the pan-tilt camera and correct the offset, thereby enabling the pan-tilt camera to accurately obtain the desired image of the target scene when the preset position is invoked.
[0064] Furthermore, the system, electronic device, computer-readable storage medium, and computer program product provided by this invention also solve the corresponding technical problems and achieve the corresponding beneficial effects. Attached Figure Description
[0065] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:
[0066] Figure 1 This is a flowchart illustrating the first embodiment of the method for identifying and correcting the preset position offset of a PTZ camera in this invention.
[0067] Figure 2This is a schematic diagram of the direction of pan-tilt camera stepping movement in the preset position offset identification and correction method of pan-tilt camera in an embodiment of the present invention.
[0068] Figure 3 This is a flowchart illustrating a second embodiment of the method for identifying and correcting the preset position offset of a PTZ camera in this invention.
[0069] Figure 4 This is a schematic diagram of the image range of the PTZ camera when capturing the first image from its usage position in an embodiment of the present invention;
[0070] Figure 5 This is a schematic diagram of the screen range when the pan-tilt camera moves one step for the first time after capturing the first image in an embodiment of the present invention.
[0071] Figure 6 This is another flowchart illustrating a second embodiment of the method for identifying and correcting the preset position offset of a PTZ camera in this invention.
[0072] Figure 7 This is a schematic diagram of an embodiment of the preset position offset recognition and correction system for a PTZ camera in this invention.
[0073] Figure 8 This is a schematic diagram of an embodiment of the preset position offset recognition and correction device for a PTZ camera in this invention.
[0074] Figure 9 This is a schematic diagram illustrating the principle of a computer-readable medium according to an embodiment of the present invention. Detailed Implementation
[0075] Exemplary embodiments of the invention will now be described more fully with reference to the accompanying drawings. However, these exemplary embodiments can be implemented in many forms and should not be construed as limiting the invention to the embodiments set forth herein. Rather, these exemplary embodiments are provided to make the invention more comprehensive and complete, and to facilitate a full communication of the inventive concept to those skilled in the art. The same reference numerals in the drawings denote the same or similar elements, components, or parts, and therefore repeated descriptions of them will be omitted.
[0076] Subject to the technical concept of this invention, the features, structures, characteristics or other details described in a particular embodiment may be combined in one or more other embodiments in a suitable manner.
[0077] In the description of specific embodiments, the features, structures, characteristics, or other details described in this invention are intended to enable those skilled in the art to fully understand the embodiments. However, it is not excluded that those skilled in the art can practice the technical solutions of this invention without one or more of the specific features, structures, characteristics, or other details.
[0078] The flowcharts shown in the accompanying drawings are merely illustrative and do not necessarily include all content and operations / steps, nor do they necessarily have to be performed in the described order. For example, some operations / steps can be broken down, while others can be combined or partially combined; therefore, the actual execution order may change depending on the specific circumstances.
[0079] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities can be implemented in software, in one or more hardware modules or integrated circuits, or in different network and / or processor devices and / or microcontroller devices.
[0080] The terms “and / or” or “and / or” include all combinations of any one or more of the listed items.
[0081] Please see Figure 1 as well as Figure 2 The first embodiment of the preset position offset identification and correction method for a PTZ camera in this invention includes:
[0082] S101. Obtain the raw PTZ data and the raw reference image of the standard preset position of the PTZ camera;
[0083] It is understood that the executing entity of this invention can be a preset position offset recognition and correction device or system for a PTZ camera, or it can be a terminal or a server; the specific implementation is not limited here. This embodiment of the invention will be described using a server as an example.
[0084] Before performing specific position offset identification and correction, the most suitable standard preset position for the PTZ camera during setup or manual adjustment is obtained for inspection or other visual inspection needs. The original PTZ data of the PTZ camera at this standard preset position is recorded. The PTZ data refers to the data on the PTZ's horizontal rotation (Pan), vertical rotation (Tilt), and lens zoom. Simultaneously with recording the original PTZ data of the PTZ camera at its standard preset position, an image of this reference position is acquired as the original reference image. The purpose of this scheme during subsequent offset correction is to ensure that the PTZ camera's viewpoint closely matches this original reference image.
[0085] In one specific implementation, the method further includes acquiring and recording the horizontal field of view α and vertical field of view β data of the standard preset position of the PTZ camera.
[0086] S102, Control the pan-tilt camera to adjust to the actual preset position and acquire the first image;
[0087] In this embodiment, the server can receive offset recognition requests triggered manually or automatically by timers. After receiving the offset recognition request, the server controls the PTZ camera to adjust to the actual preset position and captures the first image at the current position.
[0088] It's important to note that the actual preset position mentioned in this step is actually the position adjusted by the PTZ camera based on the original PTZ data of the standard preset position. However, due to various reasons during the use of the PTZ camera, it may shift. In this case, the actual preset position is actually the position where the PTZ camera currently "mistakenly believes" to have been adjusted to the standard preset position. At this actual preset position, the first image captured by the PTZ camera may have shifted relative to the original reference image.
[0089] S103. Detect whether the first image contains all or part of the content of the original reference image;
[0090] This step determines the degree of offset based on the acquired first image and the original reference image.
[0091] Specifically, a visual recognition algorithm is used to detect whether the first image contains all or part of the content of the original reference image. If the first image contains all or part of the content of the original reference image, it can be known that the first image may not have been offset or the offset is very small, making the content contained in the two images basically the same. However, the specific offset situation needs to be determined by subsequent steps.
[0092] If the detection result output by the visual recognition algorithm is that the first image does not contain all the content of the original reference image, nor does it contain part of the content of the original reference image, it may be that the actual preset position offset of the gimbal is very large, causing the visual information obtained in the first image and the original reference image to come from completely different content, or the offset is so large that the visual recognition algorithm can no longer identify the similarity or sameness between the first image and the original reference image. However, the specific offset situation needs to be determined by subsequent steps.
[0093] In one specific implementation, when using a visual recognition algorithm to detect whether an image acquired by a PTZ camera contains all or part of the content of the original reference image, a target object (or a visual marker such as ArUco or AprilTag) can be pre-set at the location where the original reference image can be acquired in order to improve the recognition effect.
[0094] S104. If the first image contains all or part of the content of the original reference image, then the offset is calculated based on the first image and the original reference image to obtain the first pixel offset.
[0095] Based on the description in step S103 above, if the first image contains all or part of the content of the original reference image, then the offset is calculated based on the first image and the original reference image to obtain the first pixel offset.
[0096] Specifically, image feature points can be extracted from the first image and the original reference image based on an image feature detection algorithm, and matching can be performed based on these image feature points. The distance between the matching points can be calculated to obtain the first pixel offset.
[0097] In one specific implementation, since the image in this embodiment is a two-dimensional image, the first pixel offset can be recorded by the distance between the horizontal and vertical coordinates in the pixel coordinate system of the image.
[0098] S105. If the first image does not contain all or part of the content of the original reference image, then obtain the second image around the first image that contains all or part of the content of the original reference image, and perform offset calculation based on the second image and the original reference image to obtain the second pixel offset.
[0099] Based on the description in step S103 above, if the first image contains neither all nor part of the content of the original reference image, it may indicate a large offset. In this case, it is necessary to control the pan-tilt camera to adjust its angle and check whether the content contained in the original reference image is around the first image.
[0100] In one specific implementation, with the first image as the center, the pan-tilt camera is controlled to acquire multiple second images around the first image; it is detected whether each second image contains all or part of the content of the original reference image; if there is a second image containing all or part of the content of the original reference image, an offset calculation is performed based on the second image containing all or part of the content of the original reference image and the original reference image.
[0101] Specifically, when controlling the PTZ camera to acquire multiple second images around the first image, with the first image as the center, the movement step size of the PTZ camera can be obtained. Based on this movement step size, the PTZ camera is controlled to move in multiple directions around it and capture images, thereby obtaining multiple second images.
[0102] In a specific example, please refer to Figure 2 In a preferred embodiment, with the first image as the center of a 3x3 grid (nine areas distributed in a 3x3 grid pattern), eight second images in eight directions (upper left, upper, upper right, left, right, lower left, lower, and lower right) can cover the surrounding area of the first image. In a preferred embodiment, these second images can overlap with each other and with the first image to improve recognition performance and prevent gaps between images that could lead to poor recognition.
[0103] In this embodiment, after obtaining multiple second images, a visual recognition algorithm is used to detect whether any of the second images contains all or part of the content of the original reference image. If so, the second image whose content is closest to the original reference image is selected, resulting in target second images surrounding the first image that contain all or part of the content of the original reference image. Image feature points are extracted from the target second image and the original reference image using an image feature detection algorithm, and matching is performed based on these image feature points. The distance between the matching points is calculated to obtain the pixel offset of the target second image relative to the original reference image. After obtaining the pixel offset of the target second image relative to the original reference image, the final second pixel offset is calculated based on the movement step size of the PTZ camera when the target second image was acquired.
[0104] Specifically, the second pixel offset is actually the sum of the pixel offset of the target second image relative to the original reference image and the corresponding total number of steps and movement step size.
[0105] S106. Determine whether the offset of the first pixel or the offset of the second pixel exceeds the offset recognition threshold;
[0106] In this step, a preset offset recognition threshold is obtained, and based on the preset offset recognition threshold, it is determined whether the first pixel offset or the second pixel offset obtained based on the first image or the second image exceeds this offset recognition threshold.
[0107] Specifically, if the result obtained during step S103 is that the first image contains all or part of the content of the original reference image, and the first pixel offset is calculated in step S104, then the first pixel offset is used in this step to determine whether the offset recognition threshold is exceeded; if the result obtained during step S103 is that the first image does not contain all or part of the content of the original reference image, and the second pixel offset is calculated in step S105, then the second pixel offset is used in this step to determine whether the offset recognition threshold is exceeded.
[0108] S107. If the offset recognition threshold is exceeded, the actual preset position has been offset and offset correction is required. The offset correction PT value is calculated based on the first pixel offset or the second pixel offset, and the offset recognition and correction of the preset position is completed based on the offset correction PT value and the Z value in the original PTZ data.
[0109] If the offset recognition threshold is exceeded, it is considered that the actual preset position corresponding to the current first image has shifted and offset correction is required. The offset correction PT value is then calculated based on either the first pixel offset or the second pixel offset. In one specific implementation, the image resolution, horizontal field of view α, and vertical field of view β of the PT camera are obtained. The PT value data of the PT camera when capturing the first image or when capturing the second image of the target are also obtained. The offset correction PT value is then calculated using the following expression:
[0110]
[0111]
[0112] in, This indicates the horizontal offset correction value. This indicates the vertical offset correction value. This indicates the horizontal rotation value of the current gimbal position. This represents the vertical rotation value of the current gimbal position. This represents the calculated pixel offset in the x-direction. α represents the calculated pixel offset in the y-direction, β represents the horizontal field of view of the PTZ camera, W represents the horizontal resolution of the PTZ camera, and H represents the vertical resolution of the PTZ camera.
[0113] get and Then, by combining the Z value in the original PTZ data, the offset identification and correction of the preset position is completed.
[0114] S108. If the offset recognition threshold is not exceeded, the actual preset position has not shifted or no offset correction is required.
[0115] If the offset recognition threshold is not exceeded, it is considered that the actual preset position corresponding to the current first image has not been offset or does not need to be offset corrected, and the PTZ camera can continue to be used for inspection and other work.
[0116] The beneficial effects of the method provided in this embodiment of the invention are that it can effectively identify the offset of the pan-tilt position, automatically and intelligently detect the offset of the preset position of the pan-tilt camera and correct the offset, and can still effectively correct the offset when the offset is large; thereby enabling the pan-tilt camera to accurately obtain the desired image of the target scene when calling the preset position.
[0117] Please refer to Figures 2-6 The second embodiment of the preset position offset identification and correction method for PTZ camera in this invention includes:
[0118] S201. Obtain the raw PTZ data and the raw reference image of the standard preset position of the PTZ camera;
[0119] S202, Control the PTZ camera to adjust to the actual preset position and acquire the first image;
[0120] S203. Detect whether the first image contains all or part of the content of the original reference image;
[0121] S204. If the first image contains all or part of the content of the original reference image, then the offset is calculated based on the first image and the original reference image to obtain the first pixel offset.
[0122] The contents of steps S201-S204 in this embodiment are basically the same as those of steps S101-S104 in the previous embodiment, and will not be repeated here.
[0123] S205. If the first image does not contain all or part of the content of the original reference image, the camera movement step length is calculated based on the image resolution of the first image and the preset PT value data adjustment unit.
[0124] If the first image contains neither all nor part of the content of the original reference image, it may be due to a large offset. In this case, it is necessary to control the pan-tilt camera to adjust its angle and check whether the content contained in the original reference image is around the first image. Therefore, in this step, it is necessary to calculate the camera movement step size. Subsequently, based on the camera movement step size, the camera is moved several steps in multiple directions to obtain the second image.
[0125] The specific calculation method for the camera movement step length includes: acquiring the first PT value data corresponding to the first image; using the first PT value data as an adjustment reference, adjusting the position of the unit moving PT camera with preset PT value data and acquiring the adjusted image; calculating the movement pixel offset between the adjusted image and the first image; setting a movement range threshold based on the image resolution of the original reference image, recording the PT value data adjustment amount when the movement pixel offset first exceeds the movement range threshold, and obtaining the camera movement step length.
[0126] In one specific implementation, the first image is used as the original image, and the first PT value data corresponding to the first image is used as the adjustment reference. When controlling the camera movement, the first PT value data is increased or decreased by one unit each time (for example, one unit of P value data or T value data can be set to 0.1°) until the adjusted PT value meets the camera movement step size requirement. For details, please refer to [link / reference]. Figure 2 Since the desired outcome in this embodiment is to obtain the second image surrounding the first image, the movement direction can be controlled to eight directions: upper left, upper, upper right, left, right, lower left, lower, and lower right. The movement commands for each direction are as follows:
[0127] (1) Upper left: P=P-1, T=T-1;
[0128] (2) Above: P remains unchanged, T = T - 1;
[0129] (3) Upper right: P=P+1, T=T-1;
[0130] (4) Left side: P = P - 1, T remains unchanged;
[0131] (5) Right side: P = P + 1, T remains unchanged;
[0132] (6) Lower left: P=P-1, T=T+1;
[0133] (7) Below: P remains unchanged, T = T + 1;
[0134] (8) Lower right: P=P+1, T=T+1;
[0135] In this process, regardless of the direction of movement, after each unit movement, the image captured by the current camera is acquired, and an image recognition algorithm is used to calculate the offset between the current image and the first image. Then, after moving another unit in the predetermined direction, the offset between the current image and the first image is calculated again, until the pixel offset value first exceeds a preset movement range threshold. In one specific implementation, the movement range threshold can be determined based on the resolution of the original reference image. When the resolution of the original reference image is (W, H), the movement range threshold in the width direction (i.e., the P direction or the horizontal direction) is... Threshold for the range of movement in height (i.e., in the T-direction or vertical direction). Where W represents the horizontal resolution of the original reference image, H represents the vertical resolution of the original reference image, and n represents the number of segments. In a specific implementation, n=8.
[0136] When the pixel offset value exceeds the preset movement range threshold for the first time, the P-value data and T-value data of the movement at this time are compared with the first P-value data and first T-value data corresponding to the first image, the final size of the movement is recorded, and this size is recorded as the camera movement step size.
[0137] Please see Figure 4 and Figure 5 These figures represent the image positions of the first picture captured by the PTZ camera, and the positions of the PTZ camera after it first moves one step to the upper left after capturing the first image. Similarly, other directions and other numbers of steps result in similar effects.
[0138] In one specific implementation, the image recognition algorithm can be the AKAZE (Accelerated-KAZE) local feature detection and description algorithm.
[0139] S206. Based on the camera's movement step length, move the pan-tilt camera in multiple directions and capture images to obtain multiple second images;
[0140] Using the camera movement step length obtained from the above steps, the pan-tilt camera is moved in multiple directions around it and images are captured, thereby obtaining multiple second images around the first image.
[0141] In one specific implementation, when capturing the second image, the number of steps moved in each direction can be the same as the number of segments, thus obtaining eight surrounding second images that perfectly connect with the edge of the first image. In another implementation, when capturing the second image, the number of steps moved in each direction can be in the range of [1, n-1]. This results in some overlap between the eight second images and the first image, preventing gaps between the second images or between the second and first images due to lens distortion, which could lead to some parts not being covered by the first and second images, thus affecting subsequent recognition performance. In a specific example, when the number of segments n is 8, the number of steps moved in each direction can be 8, thus obtaining eight surrounding second images that perfectly connect with the edge of the first image. When the number of segments n is 8, the number of steps moved in each direction can be in the range of [1, 7], resulting in some overlap between the eight second images and the first image.
[0142] S207. Detect whether each second image contains all or part of the content of the original reference image;
[0143] S208. If there is a second image that contains all or part of the content of the original reference image, then the offset is calculated based on the second image that contains all or part of the content of the original reference image and the original reference image to obtain the second pixel offset.
[0144] The calculation process of the contents in S207 and S208 in this embodiment is basically the same as that in S105 in the previous embodiment, so it will not be described again here.
[0145] S209. If there is no second image containing all or part of the original reference image, then control the pan-tilt camera to zoom and acquire multiple third images around the first image as the center.
[0146] S210. Detect whether each third image contains part or all of the content of the original reference image;
[0147] S211. If each third image contains part or all of the content of the original reference image, then the offset is calculated based on the third image containing all or part of the content of the original reference image and the original reference image to obtain the third pixel offset.
[0148] In this embodiment, during steps S209-S211, if none of the second images obtained in the preceding steps contain all or part of the content of the original reference image, then the pan-tilt camera is controlled to zoom, allowing the pan-tilt camera to view a wider range. Multiple third images surrounding the first image are then acquired, centered on the first image. The third pixel offset is calculated using a method similar to that used for the second pixel offset.
[0149] S212. Determine whether the offset of the first pixel, the offset of the second pixel, or the offset of the third pixel exceeds the offset recognition threshold;
[0150] In this step, a preset offset recognition threshold is obtained, and based on the preset offset recognition threshold, it is determined whether the first pixel offset, second pixel offset, or third pixel offset obtained based on the first image or the second image exceeds this offset recognition threshold.
[0151] Specifically, if the result obtained during step S203 is that the first image contains all or part of the original reference image, and the first pixel offset is calculated in step S204, then the first pixel offset is used in this step to determine whether the offset recognition threshold is exceeded; if the result obtained during step S203 is that the first image does not contain all or part of the original reference image, and the second pixel offset is calculated in step S205, then the second pixel offset is used in this step to determine whether the offset recognition threshold is exceeded; if the result obtained during step S203 is that the first image does not contain all or part of the original reference image, and the result obtained during step S207 is that the second image does not contain all or part of the original reference image, but the result obtained during step S210 is that the third image contains part or all of the original reference image and the third pixel offset is obtained, then the third pixel offset is used in this step to determine whether the offset recognition threshold is exceeded.
[0152] S213. If the offset recognition threshold is exceeded, the actual preset position has been offset and offset correction is required. The offset correction PT value is calculated based on the first pixel offset, the second pixel offset, or the third offset. The offset recognition and correction of the preset position is completed based on the offset correction PT value and the Z value in the original PTZ data.
[0153] S214. If the offset recognition threshold is not exceeded, the actual preset position has not shifted or no offset correction is required.
[0154] In this embodiment, steps S213 and S214 are basically the same as steps S107 and S108 in the previous embodiment, except that when using the third pixel offset for correction, the pixel offset in the x-direction is calculated using the third pixel offset. and pixel offset in the y direction Therefore, the specific details will not be elaborated here.
[0155] In a preferred embodiment, please refer to Figure 6The contents of steps S601-S613 can be found in the description of steps S201-S214 in this embodiment. After step S612, this embodiment of the invention also includes a scheme for offset correction using a fine-tuning method.
[0156] Specifically, after calculating the offset correction PT value based on the first pixel offset or the second pixel offset, or calculating the offset correction PT value based on the third pixel offset and performing the correction operation in S612, considering that errors may occur when calculating offset pixels in image recognition, which may lead to inaccurate calculated offset correction PT values, the corrected image obtained after correction based on the calculated correction PT value may still have an offset compared to the original reference image. In this case, a fine-tuning correction method is needed to continue performing a more refined offset correction operation.
[0157] The fourth image is used to refer to the image after the correction operation. At this time, the fourth image is obtained based on the offset correction PT value and the original Z value. The fourth pixel offset of the fourth image obtained after adjustment based on the correction PT value is calculated relative to the original reference image. In step S614, it is determined whether the fourth pixel offset exceeds the offset recognition threshold. If the fourth pixel offset does not exceed the offset recognition threshold, step S613 is executed, and the correction in the fine-tuning mode is no longer performed. The offset recognition and correction process at the preset position is directly terminated.
[0158] If the offset of the fourth pixel exceeds the offset recognition threshold, then step S615 is executed, the fine-tuning algorithm is called to perform offset recognition and correction again, and the number of correction executions or the length of correction execution time in the fine-tuning mode is recorded; then the fourth image is obtained again based on the position corrected by the fine-tuning algorithm.
[0159] Next, at step S616, it is determined whether the fourth pixel offset of the fourth image after the fine-tuning algorithm is called again to perform offset recognition and correction exceeds the offset recognition threshold; if the fourth pixel offset exceeds the preset offset recognition threshold, then step S617 is executed to determine whether the number of correction executions currently recorded exceeds the preset number of correction executions threshold, or to determine whether the length of the correction execution time currently recorded exceeds the preset correction time threshold.
[0160] If the judgment result at S617 is that neither the preset number of corrections nor the preset correction time has been exceeded, then proceed to step S615, continue to call the fine-tuning mode, repeat the above process, and continue to use the fine-tuning algorithm for correction.
[0161] If the judgment result at S617 is that the preset number of corrections or the preset correction time has been exceeded, then step S613 is executed, and the correction of the fine-tuning mode is no longer repeated, thus ending the process of offset identification and correction of the preset position.
[0162] The specific scheme of the fine-tuning algorithm described in this embodiment includes adjusting with the smallest adjustment unit of P and T values, when the obtained fourth pixel offset is the pixel offset in the x direction. If the value is positive, then execute P-1, that is, move the P value of the PTZ camera one unit in the negative direction; otherwise, execute P+1, that is, move the P value of the PTZ camera one unit in the positive direction. When the obtained fourth pixel offset is the pixel offset in the y-direction... If the T-value is positive, then execute T-1, which means moving the T-value of the PT camera one unit in the negative direction; otherwise, execute T+1, which means moving the PT-value of the PT camera one unit in the positive direction. One unit of P-value or T-value can be set to 0.1°.
[0163] The fine-tuning correction scheme provided in this embodiment, compared to the scheme in step S213 which directly calculates the overall offset correction P value and T value based on the pixel offset and directly adjusts it to the correct position in one go based on the obtained offset correction P value and T value, can gradually adjust the position of the PTZ camera through a small adjustment range (such as 0.1° as mentioned above) until the PTZ camera angle that is closest to the original preset position can be achieved.
[0164] The beneficial effects of the method provided in this embodiment of the invention are that it can effectively identify the offset of the pan-tilt camera position, automatically and intelligently detect the offset of the preset position of the pan-tilt camera and correct it, reducing the reliance on manual correction. When the offset is large, it can acquire surrounding images by rotating the pan-tilt camera and zooming the camera, and automatically detect the offset of the preset position based on the surrounding images, and correct the offset according to the specific offset. This method can effectively correct the offset even when the offset is large, thus enabling the pan-tilt camera to accurately acquire the desired image of the target scene when calling the preset position. In addition, the method in this embodiment also includes a fine-tuning correction scheme when performing specific correction operations. The beneficial effect of this fine-tuning correction scheme is that it can make the adjustment effect during offset correction more precise and more accurately acquire the desired image of the target scene.
[0165] The above describes the preset position offset identification and correction method for the PTZ camera in the embodiments of the present invention. The following describes the preset position offset identification and correction system for the PTZ camera in the embodiments of the present invention. Please refer to [link / reference]. Figure 7 One embodiment of the preset position offset recognition and correction system for a PTZ camera in this invention includes:
[0166] The reference acquisition module 701 is used to acquire the raw PTZ data and the raw reference image of the standard preset position of the PTZ camera.
[0167] Image detection module 702 is used to control the PTZ camera to adjust to the actual preset position and acquire a first image; detect whether the first image contains all or part of the content of the original reference image;
[0168] Offset calculation module 703, if the first image contains all or part of the content of the original reference image, is used to perform offset calculation based on the first image and the original reference image to obtain the first pixel offset;
[0169] The image detection module 702 is further configured to: if the first image does not contain all or part of the content of the original reference image, acquire the first PT value data corresponding to the first image; use the first PT value data as an adjustment reference; adjust the position of the pan-tilt camera by a preset PT value data unit and acquire the adjusted image; calculate the moving pixel offset between the adjusted image and the first image; set a moving range threshold based on the image resolution of the original reference image; record the PT value data adjustment amount when the moving pixel offset first exceeds the moving range threshold to obtain the camera moving step size; and move the pan-tilt camera in multiple directions around the camera moving step size and capture images to obtain a second image in eight directions around the first PT value data.
[0170] The offset calculation module 703 is further configured to detect whether each of the second images contains all or part of the content of the original reference image; if there is a second image containing all or part of the content of the original reference image, then offset calculation is performed based on the second image containing all or part of the content of the original reference image and the original reference image to obtain the second pixel offset;
[0171] The offset recognition and correction module 704 is used to determine whether the first pixel offset or the second pixel offset exceeds the offset recognition threshold; if it does not exceed the offset recognition threshold, the actual preset position has not been offset or does not need to be offset corrected; if it exceeds the offset recognition threshold, the actual preset position has been offset and offset correction is required. The offset correction PT value is calculated based on the first pixel offset or the second pixel offset, and the offset recognition and correction of the preset position is completed based on the offset correction PT value and the Z value in the original PTZ data.
[0172] The beneficial effect of the system provided in this embodiment is that it can effectively identify the offset of the pan-tilt position, and can automatically and intelligently detect the offset of the preset position of the pan-tilt camera and correct the offset, so that the pan-tilt camera can accurately obtain the desired image of the target scene when calling the preset position.
[0173] In another embodiment of this application, the image detection module 702 is further configured to:
[0174] If there is no second image containing all or part of the original reference image, then the pan-tilt camera is controlled to zoom and acquire multiple third images around the first image as the center.
[0175] Detect whether each of the third images contains part or all of the content of the original reference image;
[0176] The offset calculation module 703 is further configured to: if each of the third images contains part or all of the content of the original reference image, perform offset calculation based on the third image containing all or part of the content of the original reference image and the original reference image to obtain the third pixel offset;
[0177] The offset recognition and correction module 704 is further used for:
[0178] Determine whether the offset of the third pixel exceeds the offset recognition threshold;
[0179] If the offset recognition threshold is exceeded, the actual preset position has shifted and offset correction is required. The offset correction PT value is calculated based on the third pixel offset, and the offset recognition and correction of the preset position is completed based on the offset correction PT value and the Z value in the original PTZ data.
[0180] In another embodiment of this application, the preset position offset recognition and correction system of the PTZ camera further includes a fine-tuning correction module, which is specifically used for:
[0181] The fourth image is obtained based on the offset correction PT value and the original Z value, and the fourth pixel offset of the fourth image relative to the original reference image is calculated.
[0182] Determine whether the offset of the fourth pixel exceeds the offset recognition threshold;
[0183] If the offset of the fourth pixel does not exceed the offset recognition threshold, the offset recognition and correction process at the preset position ends.
[0184] If the offset of the fourth pixel exceeds the offset recognition threshold, the fine-tuning algorithm is invoked to perform offset recognition and correction again, and the fourth image is obtained again based on the corrected position.
[0185] Determine whether the fourth pixel offset of the fourth image relative to the original reference image after the fine-tuning algorithm is called again to perform offset recognition and correction exceeds the offset recognition threshold;
[0186] If the offset of the fourth pixel of the fourth image after offset recognition and correction is not exceeded by the offset recognition threshold after the fine-tuning algorithm is called again, the offset recognition and correction process at the preset position ends.
[0187] If the current correction time has exceeded the preset correction time threshold, or the current number of corrections has exceeded the preset number of corrections threshold, then the process of offset identification and correction of the preset position ends.
[0188] In another embodiment of this application, the movement range threshold includes a horizontal movement range threshold and a vertical movement range threshold, expressed as:
[0189] Horizontal movement range threshold = ;
[0190] Vertical movement range threshold = ;
[0191] Where W represents the horizontal resolution of the original reference image, H represents the vertical resolution of the original reference image, and n represents the number of segments.
[0192] When the pan-tilt camera moves in multiple directions around the camera and captures images based on the camera's movement step size, the number of steps moved in each direction ranges from [1, n-1].
[0193] In another embodiment of this application, the step of calculating the second pixel offset based on the second image containing all or part of the original reference image and the original reference image includes:
[0194] Image feature points are extracted from the second image and the original reference image based on the image feature detection algorithm. Point matching is then performed based on the extracted image feature points. The distance between the successfully matched image feature points is calculated to obtain the pixel offset of the second image relative to the original reference image.
[0195] The movement offset is calculated based on the camera's movement step size and the total number of steps the second image moves during acquisition;
[0196] The second pixel offset is obtained by summing the pixel offset and the movement offset.
[0197] In another embodiment of this application, before controlling the PTZ camera to adjust to the actual preset position and acquiring the first image, the method further includes acquiring the horizontal field of view and the vertical field of view of the PTZ camera at the standard preset position;
[0198] The offset correction PT value includes a horizontal offset correction value and a vertical offset correction value;
[0199] When calculating the offset correction PT value based on the first pixel offset or the second pixel offset, the specific expression is as follows:
[0200]
[0201]
[0202] in, This indicates the horizontal offset correction value. This indicates the vertical offset correction value. This indicates the horizontal rotation value of the current gimbal position. This represents the vertical rotation value of the current gimbal position. This represents the calculated pixel offset in the x-direction. This represents the calculated pixel offset in the y-direction. This indicates the horizontal field of view of the pan-tilt camera. The vertical field of view of the PTZ camera is represented by , W represents the horizontal resolution of the PTZ camera, and H represents the vertical resolution of the PTZ camera.
[0203] In another embodiment of this application, the specific method executed by the above system during operation can be found in the foregoing method embodiments, and will not be repeated here.
[0204] The beneficial effects of the system provided in this invention are that it can effectively identify the offset of the pan-tilt camera position, automatically and intelligently detect and correct the offset of the preset position of the pan-tilt camera, reducing the reliance on manual correction. When the offset is large, it can acquire surrounding images by rotating the pan-tilt camera and zooming the camera, and automatically detect the offset of the preset position based on the surrounding images, and correct the offset according to the specific offset. This method can effectively correct the offset even when the offset is large, thus enabling the pan-tilt camera to accurately acquire the desired image of the target scene when calling the preset position. In addition, during the specific correction operation, a fine-tuning correction scheme is also included. The beneficial effect of this fine-tuning correction is that the adjustment effect during offset correction is more precise, and the desired image of the target scene can be acquired more accurately.
[0205] Based on the same inventive concept, this specification also provides an electronic device for preset position offset identification and correction of a PTZ camera. The electronic device for preset position offset identification and correction of a PTZ camera in this embodiment of the invention will be described in detail below from the perspective of hardware processing.
[0206] Figure 8 This is a schematic diagram of an electronic device provided as an embodiment of this specification. Refer to the following... Figure 8 To describe the electronic device 800 according to this embodiment of the invention. Figure 8 The electronic device 800 shown is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of the present invention.
[0207] like Figure 8 As shown, the electronic device 800 is presented in the form of a general-purpose computing device. The components of the electronic device 800 may include, but are not limited to: at least one processing unit 810, at least one storage unit 820, a bus 830 connecting different system components (including storage unit 820 and processing unit 810), a display unit 840, etc.
[0208] The storage unit stores program code that can be executed by the processing unit 810, causing the processing unit 810 to perform the steps described in the processing method section of this specification according to various exemplary embodiments of the present invention. For example, the processing unit 810 can perform, as follows: Figure 1 , Figure 3 or Figure 6 The steps are shown.
[0209] The storage unit 820 may include a readable medium in the form of a volatile storage unit, such as a random access memory unit (RAM) 8201 and / or a cache storage unit 8202, and may further include a read-only memory unit (ROM) 8203.
[0210] The storage unit 820 may also include a program / utility 8204 having a set (at least one) program module 8205, such program module 8205 including but not limited to: an operating system, one or more application programs, other program modules and program data, each or some combination of these examples may include an implementation of a network environment.
[0211] Bus 830 can represent one or more of several types of bus structures, including a memory cell bus or memory cell controller, a peripheral bus, a graphics acceleration port, a processing unit, or a local bus using any of the various bus structures.
[0212] Electronic device 800 can also communicate with one or more external devices 100 (e.g., keyboard, pointing device, Bluetooth device, etc.), and with one or more devices that enable a user to interact with the electronic device 800, and / or with any device that enables the electronic device 800 to communicate with one or more other computing devices (e.g., router, modem, etc.). This communication can be performed via input / output (I / O) interface 850. Furthermore, electronic device 800 can also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN), and / or public networks, such as the Internet) via network adapter 860. Network adapter 860 can communicate with other modules of electronic device 800 via bus 830. It should be understood that, although... Figure 8 As not shown in the diagram, other hardware and / or software modules may be used in conjunction with the electronic device 800, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0213] Through the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described in this invention can be implemented by software or by combining software with necessary hardware. Therefore, the technical solutions according to the embodiments of this invention can be embodied in the form of a software product, which can be stored in a computer-readable storage medium (such as a CD-ROM, USB flash drive, external hard drive, etc.) or on a network, including several instructions to cause a computing device (such as a personal computer, server, or network device, etc.) to execute the method described above according to this invention. When the computer program is executed by a data processing device, it enables the computer-readable medium to implement the method described above, i.e.: as... Figure 1 , Figure 3 or Figure 6 The method shown.
[0214] Figure 9 This is a schematic diagram of a computer-readable medium provided for embodiments of this specification.
[0215] accomplish Figure 1 , Figure 3 or Figure 6The computer program of the method shown can be stored on one or more computer-readable media. A computer-readable medium can be a readable signal medium or a readable storage medium. A readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of readable storage media (a non-exhaustive list) include: an electrical connection having one or more wires, a portable disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof.
[0216] The computer-readable storage medium may include data signals propagated in baseband or as part of a carrier wave, carrying readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. The readable storage medium may also be any readable medium other than a readable storage medium, capable of transmitting, propagating, or transmitting programs for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the readable storage medium may be transmitted using any suitable medium, including but not limited to wireless, wired, optical fiber, RF, etc., or any suitable combination thereof.
[0217] In addition, the present invention also provides a computer program product, including a computer program / instruction, which, when executed by a processor, implements the preset position offset recognition and correction method for a PTZ camera as described in any of the above embodiments.
[0218] Program code for performing the operations of this invention can be written in any combination of one or more programming languages, including object-oriented programming languages such as Java and C++, and conventional procedural programming languages such as C or similar languages. The program code can execute entirely on the user's computing device, partially on the user's device, as a standalone software package, partially on the user's computing device and partially on a remote computing device, or entirely on a remote computing device or server. In cases involving remote computing devices, the remote computing device can be connected to the user's computing device via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computing device (e.g., via the Internet using an Internet service provider).
[0219] In summary, the present invention can be implemented in hardware, or as software modules running on one or more processors, or a combination thereof. Those skilled in the art will understand that in practice, general-purpose data processing devices such as microprocessors or digital signal processors (DSPs) can be used to implement some or all of the functions of some or all of the components according to the embodiments of the present invention. The present invention can also be implemented as a device or apparatus program (e.g., a computer program and computer program product) for performing part or all of the methods described herein. Such programs implementing the present invention can be stored on a computer-readable medium or can be in the form of one or more signals. Such signals can be downloaded from an Internet website, provided on a carrier signal, or provided in any other form.
[0220] The specific embodiments described above further illustrate the purpose, technical solution, and beneficial effects of the present invention. It should be understood that the present invention is not inherently related to any specific computer, virtual device, or electronic device, and various general-purpose devices can also implement the present invention. The above descriptions are merely specific embodiments of the present invention and are not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
[0221] The various embodiments in this specification are described in a progressive manner. The same or similar parts between the various embodiments can be referred to each other. Each embodiment focuses on describing the differences from other embodiments.
[0222] If the technical solution of this application involves personal information, the product using this technical solution has clearly informed the user of the personal information processing rules and obtained the user's voluntary consent before processing the personal information. If the technical solution of this application involves sensitive personal information, the product using this technical solution has obtained the user's separate consent before processing the sensitive personal information, and also meets the requirement of "express consent". For example, at personal information collection devices such as cameras, clear and prominent signs are set up to inform users that they have entered the scope of personal information collection and that personal information will be collected. If an individual voluntarily enters the collection scope, it is deemed that they have agreed to the collection of their personal information; or on the personal information processing device, with clear signs / information informing users of the personal information processing rules, authorization is obtained from the individual through pop-up information or by asking the individual to upload their personal information; wherein, the personal information processing rules may include information such as the personal information processor, the purpose of personal information processing, the processing method, and the types of personal information processed.
[0223] The above description is merely an embodiment of this application and is not intended to limit the scope of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of the claims of this application.
Claims
1. A method for identifying and correcting preset position offset of a PTZ camera, characterized in that, include: Acquire raw PTZ data and raw reference image of the standard preset position of the PTZ camera; Control the pan-tilt camera to adjust to the actual preset position and capture the first image; Detect whether the first image contains all or part of the content of the original reference image; If the first image contains all or part of the content of the original reference image, then an offset calculation is performed based on the first image and the original reference image to obtain the first pixel offset. If the first image does not contain all or part of the content of the original reference image, then the first PT value data corresponding to the first image is obtained, the first PT value data is used as the adjustment reference, the position of the pan-tilt camera is adjusted by the preset PT value data, and the adjusted image is obtained. Calculate the shifted pixel offset between the adjusted image and the first image; Based on the image resolution of the original reference image, a motion range threshold is set, and the PT value data adjustment amount is recorded when the motion pixel offset first exceeds the motion range threshold to obtain the camera motion step size. Based on the camera's movement step size, the PT-camera is moved in multiple directions around the camera and images are captured to obtain a second image in eight directions around the first PT value data. Detect whether each of the second images contains all or part of the content of the original reference image; If there exists a second image that contains all or part of the content of the original reference image, then an offset calculation is performed based on the second image containing all or part of the content of the original reference image and the original reference image to obtain the second pixel offset. Determine whether the offset of the first pixel or the offset of the second pixel exceeds the offset recognition threshold; If the offset recognition threshold is not exceeded, then the actual preset position has not shifted or does not require offset correction. If the offset recognition threshold is exceeded, the actual preset position has shifted and offset correction is required. The offset correction PT value is calculated based on the first pixel offset or the second pixel offset, and the offset recognition and correction of the preset position is completed based on the offset correction PT value and the Z value in the original PTZ data.
2. The method for identifying and correcting preset position offset of a PTZ camera according to claim 1, characterized in that, After detecting whether each of the second images contains all or part of the content of the original reference image, the method further includes: If there is no second image containing all or part of the original reference image, then the pan-tilt camera is controlled to zoom and acquire multiple third images around the first image as the center. Detect whether each of the third images contains part or all of the content of the original reference image; If each of the third images contains part or all of the content of the original reference image, then an offset calculation is performed based on the third image containing all or part of the content of the original reference image and the original reference image to obtain the third pixel offset. The method for identifying and correcting the preset position offset of the PTZ camera further includes: Determine whether the offset of the third pixel exceeds the offset recognition threshold; If the offset recognition threshold is exceeded, the actual preset position has shifted and offset correction is required. The offset correction PT value is calculated based on the third pixel offset, and the offset recognition and correction of the preset position is completed based on the offset correction PT value and the Z value in the original PTZ data.
3. The method for identifying and correcting preset position offset of a PTZ camera according to claim 2, characterized in that, After calculating the offset correction PT value based on the first pixel offset or the second pixel offset, or calculating the offset correction PT value based on the third pixel offset, the method further includes: The fourth image is obtained based on the offset correction PT value and the original Z value, and the fourth pixel offset of the fourth image relative to the original reference image is calculated. Determine whether the offset of the fourth pixel exceeds the offset recognition threshold; If the offset of the fourth pixel does not exceed the offset recognition threshold, the offset recognition and correction process at the preset position ends. If the offset of the fourth pixel exceeds the offset recognition threshold, the fine-tuning algorithm is invoked to perform offset recognition and correction again, and the fourth image is obtained again based on the corrected position. Determine whether the fourth pixel offset of the fourth image relative to the original reference image after the fine-tuning algorithm is called again to perform offset recognition and correction exceeds the offset recognition threshold; If the offset of the fourth pixel of the fourth image after offset recognition and correction is not exceeded by the offset recognition threshold after the fine-tuning algorithm is called again, the offset recognition and correction process at the preset position ends. If the offset of the fourth pixel of the fourth image after offset recognition and correction is executed again by calling the fine-tuning algorithm exceeds the offset recognition threshold, then it is determined whether the current correction time exceeds the preset correction time threshold, or whether the current number of corrections exceeds the preset number of corrections threshold. If the current correction time has exceeded the preset correction time threshold, or the current number of corrections has exceeded the preset number of corrections threshold, then the process of offset identification and correction of the preset position ends.
4. The method for identifying and correcting preset position offset of a PTZ camera according to claim 1, characterized in that, The movement range threshold includes a horizontal movement range threshold and a vertical movement range threshold, expressed as follows: Horizontal movement range threshold = ; Vertical movement range threshold = ; Where W represents the horizontal resolution of the original reference image, H represents the vertical resolution of the original reference image, and n represents the number of segments. When the pan-tilt camera moves in multiple directions around the camera and captures images based on the camera's movement step size, the number of steps moved in each direction ranges from [1, n-1].
5. The method for identifying and correcting preset position offset of a PTZ camera according to claim 1, characterized in that, The offset calculation based on the second image containing all or part of the original reference image and the original reference image to obtain the second pixel offset includes: Image feature points are extracted from the second image and the original reference image based on the image feature detection algorithm. Point matching is then performed based on the extracted image feature points. The distance between the successfully matched image feature points is calculated to obtain the pixel offset of the second image relative to the original reference image. The movement offset is calculated based on the camera's movement step size and the total number of steps the second image moves during acquisition; The second pixel offset is obtained by summing the pixel offset and the movement offset.
6. The method for identifying and correcting preset position offset of a PTZ camera according to claim 1, characterized in that, Before controlling the pan-tilt camera to adjust to the actual preset position and acquiring the first image, the method further includes acquiring the horizontal and vertical field of view of the pan-tilt camera at the standard preset position. The offset correction PT value includes a horizontal offset correction value and a vertical offset correction value; When calculating the offset correction PT value based on the first pixel offset or the second pixel offset, the specific expression is as follows: in, This indicates the horizontal offset correction value. This indicates the vertical offset correction value. This indicates the horizontal rotation value of the current gimbal position. This represents the vertical rotation value of the current gimbal position. This represents the calculated pixel offset in the x-direction. This represents the calculated pixel offset in the y-direction. This indicates the horizontal field of view of the pan-tilt camera. The vertical field of view of the PTZ camera is represented by , W represents the horizontal resolution of the PTZ camera, and H represents the vertical resolution of the PTZ camera.
7. A preset position offset recognition and correction system for a PTZ camera, characterized in that, The preset position offset recognition and correction system for the pan-tilt camera includes: The reference acquisition module is used to acquire the raw PTZ data and the raw reference image of the standard preset position of the PTZ camera; The image detection module is used to control the PTZ camera to adjust to the actual preset position and acquire a first image; and to detect whether the first image contains all or part of the content of the original reference image. The offset calculation module is used to perform offset calculation based on the first image and the original reference image if the first image contains all or part of the content of the original reference image, so as to obtain the first pixel offset. The image detection module, if the first image does not contain all or part of the content of the original reference image, is further configured to: acquire the first PT value data corresponding to the first image; use the first PT value data as an adjustment reference; adjust the position of the pan-tilt camera by a preset PT value data unit and acquire the adjusted image; calculate the pixel offset between the adjusted image and the first image; set a movement range threshold based on the image resolution of the original reference image; record the PT value data adjustment amount when the pixel offset first exceeds the movement range threshold to obtain the camera movement step size; and move the pan-tilt camera in multiple directions around the camera movement step size and capture images to obtain a second image in eight directions around the first PT value data. The offset calculation module is further configured to detect whether each of the second images contains all or part of the content of the original reference image; if there is a second image containing all or part of the content of the original reference image, then offset calculation is performed based on the second image containing all or part of the content of the original reference image and the original reference image to obtain the second pixel offset; The offset recognition and correction module is used to determine whether the first pixel offset or the second pixel offset exceeds the offset recognition threshold; if it does not exceed the offset recognition threshold, the actual preset position has not been offset or does not need to be offset corrected; if it exceeds the offset recognition threshold, the actual preset position has been offset and offset correction is required. The module calculates the offset correction PT value based on the first pixel offset or the second pixel offset, and completes the offset recognition and correction of the preset position based on the offset correction PT value and the Z value in the original PTZ data.
8. A device for identifying and correcting preset position offset of a PTZ camera, characterized in that, The preset position offset recognition and correction device for the pan-tilt camera includes: a memory and at least one processor, wherein the memory stores instructions; The at least one processor invokes the instructions in the memory to cause the preset position offset recognition and correction device of the PTZ camera to perform the steps of the preset position offset recognition and correction method of the PTZ camera as described in any one of claims 1-6.
9. A computer-readable storage medium storing a computer program / instructions thereon, characterized in that, When the program / instruction is executed by the processor, it implements the steps of the preset position offset recognition and correction method for the PTZ camera as described in any one of claims 1-6.
10. A computer program product comprising a computer program / instructions, characterized in that, When the computer program / instruction is executed by the processor, it implements the steps of the preset position offset recognition and correction method for the PTZ camera as described in any one of claims 1-6.
Citation Information
Patent Citations
PTZ correction method
CN105513072A
Camera-based guard position correction method and device, and readable storage medium
CN115914844A