Image correction method and device, storage medium, and electronic device
By acquiring and calculating the image coordinate deviation value captured by the camera device, the image area is automatically corrected, solving the problem of time-consuming and labor-intensive image correction in the existing technology, and realizing efficient image boundary correction.
Patent Information
- Application Number
- CN202210439463.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-25
- Publication Date
- 2026-01-06
- Estimated Expiration
- 2042-04-25
AI Technical Summary
In existing technologies, the image region correction process is time-consuming and laborious, especially when the parking space boundary is offset in the surveillance video, manually redrawing the boundary is time-consuming and inconvenient.
By acquiring the first and second images captured by the camera device, the coordinates of the target area are determined, the coordinate deviation value is calculated, and the image area is corrected using the deviation value, thereby achieving automated image correction.
It improves the efficiency of image correction, accurately draws parking space boundaries, and reduces the time spent on manual operations.
Smart Images

Figure CN114757846B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of images, and more specifically, to an image correction method and apparatus, a storage medium, and an electronic device. Background Technology
[0002] In the field of public surveillance, abnormal events can be determined from video images captured by cameras. For example, in determining whether a vehicle is parked in a parking space, the boundary of the corresponding parking space is usually obtained from the surveillance video captured by the camera, and the vehicle is judged to be parked correctly according to the boundary. However, in practical applications, due to factors such as hardware aging, pan-tilt-zoom (PTZ) rotation, and the surrounding environment, the boundary of the parking space defined in the surveillance video will shift relative to the actual boundary of the parking space over time, thus limiting related applications. Therefore, it is necessary to recalculate the new boundary of the parking space. Currently, this problem is usually addressed by manually redefining the parking space boundary, but this process is time-consuming and laborious, causing many inconveniences for users. Summary of the Invention
[0003] This invention provides an image correction method, apparatus, storage medium, and electronic device to at least solve the problem of time-consuming and laborious image region correction in related technologies.
[0004] According to an embodiment of the present invention, an image correction method is provided, comprising: acquiring a first image obtained by a camera device capturing a preset area, wherein the first image includes a target area within the preset area; determining the coordinates of N position points of the target area in the first image to obtain N coordinates, wherein N is a natural number greater than 1;
[0005] In the second image, the coordinates of a preset position point corresponding to each of the N position points are determined to obtain N preset coordinates. The second image is an image obtained by the camera device capturing the preset area. The deviation value between each of the above coordinates and each of the above preset coordinates is determined to obtain N deviation values. The position of the target area in the first image is corrected using the N deviation values to obtain the target image.
[0006] According to another embodiment of the present invention, an image correction device is provided, comprising: a first acquisition module, configured to acquire a first image obtained by a camera capturing a preset area, wherein the first image includes a target area within the preset area; a first determination module, configured to determine the coordinates of N position points of the target area in the first image, thereby obtaining N coordinates, wherein N is a natural number greater than 1; a second determination module, configured to determine the coordinates of a preset position point corresponding to each of the N position points in a second image, thereby obtaining N preset coordinates, wherein the second image is an image obtained by the camera capturing the preset area; a third determination module, configured to determine a deviation value between each of the coordinates and each of the preset coordinates, thereby obtaining N deviation values; and a first correction module, configured to correct the position of the target area in the first image using the N deviation values, thereby obtaining a target image.
[0007] In an exemplary embodiment, the first determining module includes: a first determining unit, configured to determine a first image region of the target region in the first image; a second determining unit, configured to determine N vertices in the first image region as the N position points; and a third determining unit, configured to determine the coordinates of the N position points in a preset image coordinate system to obtain the N coordinates.
[0008] In an exemplary embodiment, the second determining unit includes: a first marking unit, configured to mark each of the preset position points that match each of the aforementioned position points in the second image; and a fourth marking unit, configured to determine the coordinates of each of the aforementioned preset position points in a preset image coordinate system to obtain the aforementioned N preset coordinates.
[0009] In an exemplary embodiment, the third determining module includes: a fourth determining unit, configured to determine the similarity between the first image and the second image; a first calculating unit, configured to calculate each of the coordinates and the deviation region between each of the preset coordinates to obtain N deviation regions when the similarity between the first image and the second image is greater than or equal to a first preset threshold; and a fifth determining unit, configured to determine the number of pixels included in each of the deviation regions to obtain the N deviation values.
[0010] In an exemplary embodiment, the fourth determining unit includes: a first dividing subunit, configured to divide the first image into M image regions, wherein M is a natural number greater than 1; a first determining subunit, configured to determine a second image region from the M image regions; a first comparison subunit, configured to compare pixels in the second image region with pixels in corresponding image regions in the second image; and a second determining subunit, configured to determine the similarity between pixels in the second image region and pixels in corresponding image regions in the second image as the similarity between the first image and the second image.
[0011] In an exemplary embodiment, the apparatus further includes a second acquisition module, configured to acquire a third image obtained by the camera device from the preset area within a preset time period after acquiring the first image, provided that the similarity between the first image and the second image is less than the first preset threshold.
[0012] In an exemplary embodiment, the first correction module includes: a sixth determining unit, configured to determine a registration matrix between the first image and the second image based on the N coordinate deviation values; and a first correction unit, configured to correct the position of the target region in the first image using the registration matrix to obtain a target image.
[0013] In an exemplary embodiment, the sixth determining unit includes: a third determining subunit, configured to determine a first image feature of the first image and a second image feature of the second image; and a first registration subunit, configured to register the first image feature and the second image feature according to each of the coordinate deviation values to obtain the registration matrix.
[0014] In an exemplary embodiment, the first correction unit includes: a fourth determining subunit, configured to determine the three-dimensional coordinates of each of the aforementioned position points using elements in the registration matrix and each of the aforementioned coordinates; and a first correction subunit, configured to correct the position of the target region in the first image by normalizing the three-dimensional coordinates of each of the aforementioned position points and each of the aforementioned coordinates, thereby obtaining the aforementioned target image.
[0015] In an exemplary embodiment, the apparatus further includes a first update module, configured to correct the position of the target region in the first image using the registration matrix, and after obtaining the target image, update the second image using the first image if the similarity between the first image and the second image is greater than or equal to a second threshold.
[0016] In an exemplary embodiment, the apparatus further includes: a fourth determining module, configured to correct the position of the target region in the first image using the N deviation values, and after obtaining the target image, determine the corrected N position points in the target image; and a first connecting module, configured to connect the corrected N position points in the target image to obtain a corrected first image region, wherein the first image region is the image region of the target region in the first image.
[0017] According to yet another embodiment of the present invention, a computer-readable storage medium is also provided, wherein a computer program is stored therein, wherein the computer program is configured to perform the steps in any of the above method embodiments when executed.
[0018] According to yet another embodiment of the present invention, an electronic device is also provided, including a memory and a processor, wherein the memory stores a computer program and the processor is configured to run the computer program to perform the steps in any of the above method embodiments.
[0019] This invention determines the coordinates of corresponding points in a first and second image, and calculates the deviation between these coordinates. The deviation is then used to correct the image region corresponding to the target region in the first image. This achieves the goal of correcting image regions within an image. Therefore, it solves the problem of time-consuming and laborious image region correction in existing technologies, thus improving the efficiency of image correction. Attached Figure Description
[0020] Figure 1 This is a hardware structure block diagram of a mobile terminal for an image correction method according to an embodiment of the present invention.
[0021] Figure 2 This is a flowchart of an image correction method according to an embodiment of the present invention;
[0022] Figure 3 This is a schematic diagram of image differences according to an embodiment of the present invention;
[0023] Figure 4 This is a flowchart of correcting parking spaces according to an embodiment of the present invention;
[0024] Figure 5 This is a schematic diagram illustrating the effect of image correction according to an embodiment of the present invention;
[0025] Figure 6 A structural block diagram of an image correction device according to an embodiment of the present invention. Detailed Implementation
[0026] The embodiments of the present invention will be described in detail below with reference to the accompanying drawings and examples.
[0027] It should be noted that the terms "first," "second," etc., in the specification, claims, and drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence.
[0028] The methods and embodiments provided in this application can be executed on a mobile terminal, computer terminal, or similar computing device. Taking running on a mobile terminal as an example, Figure 1 This is a hardware structure block diagram of a mobile terminal for an image correction method according to an embodiment of the present invention. Figure 1 As shown, a mobile terminal may include one or more ( Figure 1 Only one is shown in the diagram. A processor 102 (which may include, but is not limited to, a microprocessor MCU or a programmable logic device FPGA, etc.) and a memory 104 for storing data are also shown. The mobile terminal may further include a transmission device 106 for communication functions and an input / output device 108. Those skilled in the art will understand that... Figure 1 The structure shown is for illustrative purposes only and does not limit the structure of the mobile terminal described above. For example, the mobile terminal may also include components that are more... Figure 1 The more or fewer components shown, or having the same Figure 1 The different configurations shown.
[0029] The memory 104 can be used to store computer programs, such as application software programs and modules, like the computer program corresponding to the image correction method in this embodiment of the invention. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, thereby implementing the above-described method. The memory 104 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include memory remotely located relative to the processor 102, and these remote memories can be connected to the mobile terminal via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.
[0030] The transmission device 106 is used to receive or send data via a network. Specific examples of the network described above may include a wireless network provided by the mobile terminal's communication provider. In one example, the transmission device 106 includes a Network Interface Controller (NIC), which can connect to other network devices via a base station to communicate with the Internet. In another example, the transmission device 106 may be a Radio Frequency (RF) module, used for wireless communication with the Internet.
[0031] This embodiment provides an image correction method. Figure 2 This is a flowchart of an image correction method according to an embodiment of the present invention, such as... Figure 2 As shown, the process includes the following steps:
[0032] Step S202: Obtain a first image obtained by the camera device capturing a preset area, wherein the first image includes the target area within the preset area;
[0033] In this embodiment, the preset area can be any area, and the target area can be any area within the preset area. For example, an image of a parking area may include parking spaces.
[0034] Step S204: Determine the coordinates of N location points of the target region in the first image, and obtain N coordinates, where N is a natural number greater than 1;
[0035] In this embodiment, the value of N can be flexibly set based on the actual application scenario or image requirements. For example, when the first image includes an image area of a parking space, the four vertices of the parking space are determined as four location points.
[0036] Step S206: Determine the coordinates of the preset position points corresponding to each of the N position points in the second image to obtain N preset coordinates. The second image is an image obtained by the camera device capturing the preset area.
[0037] In this embodiment, the second image can be a corrected image or an initialized image, meaning that the image region it includes corresponds to the location of the target region in reality. For example, the parking space region in the second image has not deviated, or the deviation has been corrected. The first image and the second image were taken at different times.
[0038] Step S208: Determine the deviation value between each coordinate and each preset coordinate to obtain N deviation values;
[0039] Step S210: Correct the position of the target region in the first image using N deviation values to obtain the target image.
[0040] In this embodiment, by compensating the deviation value to the image region where the deviation occurred, the image region can be effectively corrected.
[0041] The entity performing the above steps may be a terminal, a server, a specific processor set in the terminal or server, or a processor or processing device set up relatively independently of the terminal or server, but is not limited to these.
[0042] Through the above steps, by determining the coordinates of corresponding points in the first and second images, the deviation value of the coordinates of corresponding points in the first and second images is calculated. The deviation value is then used to correct the image region corresponding to the target region in the first image. This achieves the purpose of correcting image regions in the image. Therefore, it solves the problem of time-consuming and laborious image region correction in existing technologies, thus improving the efficiency of image correction.
[0043] In an exemplary embodiment, determining the coordinates of N location points of the target region in the first image, obtaining the N coordinates, includes:
[0044] S11, Determine the target region in the first image region of the first image;
[0045] S12, determine N vertices in the first image region as N position points;
[0046] S13, determine the coordinates of N position points in the preset image coordinate system to obtain N coordinates.
[0047] In this embodiment, the coordinates of each point in the first image are two-dimensional coordinates. For example, the coordinates of the four vertices of the parking space in the first image can be marked in a preset image coordinate system.
[0048] In one exemplary embodiment, determining the coordinates of a preset position point corresponding to each of the N position points in the second image, thereby obtaining the N preset coordinates, includes:
[0049] S21, mark each preset position point that matches each position point in the second image;
[0050] S22, determine the coordinates of each preset position point in the preset image coordinate system to obtain N preset coordinates.
[0051] In this embodiment, preset position points in the second image are mapped to position points in the first image, and deviation values are calculated for each pair of position points. For example, the four vertices of a parking space in the first image are mapped to the four vertices of the same parking space in the second image.
[0052] In one exemplary embodiment, the deviation value between each coordinate and each preset coordinate is determined to obtain N deviation values, including:
[0053] S31, determine the similarity between the first image and the second image;
[0054] S32, if the similarity between the first image and the second image is greater than or equal to the first preset threshold, calculate each coordinate and the deviation region between each preset coordinate to obtain N deviation regions;
[0055] S33, based on the number of pixels included in each deviation region, obtain N deviation values.
[0056] In this embodiment, the similarity between the first image and the second image is determined in the following way:
[0057] Divide the first image into M image regions, where M is a natural number greater than 1;
[0058] Determine the second image region from the M image regions;
[0059] Compare the pixels in the second image region with the pixels in the corresponding image region in the second image;
[0060] The similarity between pixels in the second image region and pixels in the corresponding image region in the second image is determined as the similarity between the first image and the second image.
[0061] For example, in the process of correcting parking spaces, such as Figure 3 As shown, interference from surrounding vehicles entering and exiting results in significant differences between the images at two different times, hindering registration calculations. The image blocks marked with gray boxes, however, are less affected and more similar, significantly improving the registration success rate. Dividing the image into different regions, comparing the similarity between two frames, and performing registration calculations on these regions can effectively improve the registration success rate.
[0062] In one exemplary embodiment, the method further includes:
[0063] S41, if the similarity between the first image and the second image is less than a first preset threshold, a third image obtained by the camera device shooting the preset area is acquired within a preset time period after the first image is acquired.
[0064] In this embodiment, if the matching degree between the first image and the second image is less than a first preset threshold, it indicates that the difference between the first image and the second image is relatively large. After a preset time interval (e.g., 10 seconds), the image is re-acquired and recalculated. The preset time interval is set by the user.
[0065] In one exemplary embodiment, the position of the target region in the first image is corrected using N coordinate deviation values to obtain the target image, including:
[0066] S51, determine the registration matrix between the first image and the second image based on N coordinate deviation values;
[0067] S52, the position of the target region in the first image is corrected using the registration matrix to obtain the target image.
[0068] In this embodiment, the registration matrix between the first image and the second image is determined based on N coordinate deviation values in the following manner:
[0069] Determine the first image features of the first image and the second image features of the second image;
[0070] The registration matrix is obtained by registering the first image feature and the second image feature according to each coordinate deviation value.
[0071] For example, the registration matrix tform can be represented as follows:
[0072] Where t1, t2, and t3 represent images acquired at different times.
[0073] In addition, both the first image feature and the second image feature include color information, coordinate information and depth information of each pixel.
[0074] In one exemplary embodiment, the position of the target region in the first image is corrected using a registration matrix to obtain the target image, including:
[0075] S61, using the elements in the registration matrix and each coordinate, determine the three-dimensional coordinates of each location point;
[0076] S62, by normalizing the three-dimensional coordinates of each location point and each coordinate, corrects the position of the target region in the first image to obtain the target image.
[0077] In this embodiment, the corrected coordinates of each location point can be calculated using the following formula:
[0078] Where x and y represent the column coordinates and row coordinates of a point in the first image, respectively, and tx, ty, and tz represent the horizontal, vertical, and vertical coordinates in three-dimensional space, respectively. By normalizing the vertical coordinates, x' and y' can be obtained, which are the column coordinates and row coordinates of a point after correction.
[0079] In one exemplary embodiment, after correcting the position of the target region in the first image using a registration matrix to obtain the target image, the method further includes:
[0080] S71, if the similarity between the first image and the second image is greater than or equal to a second threshold, update the second image using the first image.
[0081] In this embodiment, updating the first image can avoid the impact of environmental changes.
[0082] In one exemplary embodiment, after correcting the position of the target region in the first image using N deviation values to obtain the target image, the method further includes:
[0083] S81, determine the N corrected location points in the target image;
[0084] S82, connect the N corrected position points in the target image to obtain the corrected first image region, where the first image region is the image region of the target region in the first image.
[0085] In this embodiment, the N location points in the target image are the corrected location points. For example, if the N location points are the four vertices of a parking space, connecting the four vertices forms the four boundary lines of the parking space. This allows for the accurate drawing of the parking space boundary.
[0086] The present invention will now be described in conjunction with specific embodiments:
[0087] This embodiment takes the correction of parking space boundaries as an example. The first image is the reference image at time t0, and the second image is the scan image at time t1, for illustration:
[0088] like Figure 4 As shown, this embodiment includes the following steps:
[0089] S401: Perform registration calculations on the reference image at time t0 and the scanned image at time t1, and calculate the similarity between the registered images. No restrictions are placed on the registration algorithm or image similarity metric.
[0090] S402, if the above registration is successful and the image similarity is greater than the given threshold (it is assumed here that the higher the selected image similarity index, the more similar the images), then jump to S306. Otherwise, jump to S303;
[0091] S403. Considering the differences between the images acquired at time t0 and time t1, especially for this application, the entry and exit of vehicles and interference from other vehicles in the surrounding area may cause significant changes in the overall image content, making the registration algorithm difficult to handle. Therefore, dividing the image into different image blocks and performing registration calculations on these blocks can effectively improve the registration success rate. Figure 3 As shown, due to the interference of surrounding vehicles entering and exiting, the overall images at two different times are quite different, which is not conducive to registration calculation. However, the image blocks marked by the gray boxes are less affected by this and are more similar, which can greatly improve the registration success rate.
[0092] S43. If registration was successful in S403 and the image similarity is greater than the given threshold, then proceed to S406. Otherwise, proceed to S405.
[0093] S405, after a specific time interval, reacquire the image at time t1 and jump to S401 for recalculation. This time interval is specified in advance by the user.
[0094] S406, determine whether the similarity of the registered images is greater than threshold 2. To make the determination more accurate, threshold 2 is required to be greater than or equal to threshold 1. If this condition is met, the image at time t1 is used as the image at time t0 for the next calculation. Otherwise, proceed to S307 and do not perform the above-mentioned image update operation at time t0. This step can effectively address the correction difficulties caused by factors such as seasonal and scene changes in this scheme.
[0095] S408, Obtain the tform matrix generated by registration, as shown below:
[0096]
[0097] S409-S410, based on the tform matrix and the vertex coordinates of the parking space at time t0, perform vertex correction on time t1 to obtain the corrected vertex coordinates. These vertex coordinates can then be used to accurately draw the parking space boundary. The calculation formula is as follows:
[0098]
[0099] Where x and y represent the column and row coordinates of a vertex at time t1 before correction, respectively, and tx, ty, and tz represent the x, y, and y coordinates of the three-dimensional space, respectively. By normalizing the y coordinate, we can obtain x' and y', which are the column and row coordinates of the vertex after correction.
[0100] S411, import all corrected vertex coordinates into the device, thus completing the correction of the parking space boundaries. For example... Figure 5As shown, the outer boundary represents the effect before correction, and the inner boundary represents the effect after correction.
[0101] In summary, this embodiment avoids the problem of existing technologies not fully considering the impact of environmental changes on such applications by adding a reference image update strategy; and significantly improves the computational success rate of such applications by using a combination of local and global matching and registration.
[0102] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods according to the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods described in the various embodiments of the present invention.
[0103] This embodiment also provides an image correction device for implementing the above embodiments and preferred embodiments; details already described will not be repeated. As used below, the term "module" can refer to a combination of software and / or hardware that performs a predetermined function. Although the device described in the following embodiments is preferably implemented in software, hardware implementation, or a combination of software and hardware, is also possible and contemplated.
[0104] Figure 6 A structural block diagram of the image correction device according to an embodiment of the present invention is shown below. Figure 6 The device includes:
[0105] The first acquisition module 62 is used to acquire a first image obtained by the camera device capturing a preset area, wherein the first image includes a target area within the preset area;
[0106] The first determining module 64 is used to determine the coordinates of N position points of the target region in the first image, thereby obtaining N coordinates, where N is a natural number greater than 1;
[0107] The second determining module 66 is used to determine the coordinates of a preset position point corresponding to each of the N position points in the second image, thereby obtaining N preset coordinates. The second image is an image obtained by the camera device from capturing images of the preset area.
[0108] The third determining module 68 is used to determine the deviation value between each coordinate and each preset coordinate, and obtain N deviation values;
[0109] The first correction module 610 is used to correct the position of the target region in the first image using N deviation values to obtain the target image.
[0110] In one exemplary embodiment, the first determining module described above includes:
[0111] The first determining unit is used to determine the target region as a first image region in the first image.
[0112] The second determining unit is used to determine the N vertices in the first image region as the N position points.
[0113] The third determining unit is used to determine the coordinates of the above N position points in the preset image coordinate system, and obtain the above N coordinates.
[0114] In one exemplary embodiment, the second determining unit includes:
[0115] The first marking unit is used to mark each of the preset position points that match each of the aforementioned position points in the second image;
[0116] The fourth marking unit is used to determine the coordinates of each of the above-mentioned preset position points in the preset image coordinate system, so as to obtain the above-mentioned N preset coordinates.
[0117] In one exemplary embodiment, the third determining module described above includes:
[0118] The fourth determining unit is used to determine the similarity between the first image and the second image.
[0119] The first calculation unit is used to calculate each of the above coordinates and the deviation region between each of the above preset coordinates when the similarity between the above first image and the above second image is greater than or equal to a first preset threshold, and obtain N deviation regions.
[0120] The fifth determining unit is used to determine the number of pixels included in each of the above-mentioned deviation regions to obtain the above-mentioned N deviation values.
[0121] In one exemplary embodiment, the fourth determining unit includes:
[0122] The first dividing subunit is used to divide the first image into M image regions, where M is a natural number greater than 1;
[0123] The first determining subunit is used to determine the second image region from the above M image regions;
[0124] The first comparison subunit is used to compare the pixels in the second image region with the pixels in the corresponding image region in the second image.
[0125] The second determining subunit is used to determine the similarity between pixels in the second image region and pixels in the corresponding image region in the second image as the similarity between the first image and the second image.
[0126] In one exemplary embodiment, the above-described apparatus further includes:
[0127] The second acquisition module is used to acquire a third image obtained by the camera device from the preset area within a preset time period after acquiring the first image, when the similarity between the first image and the second image is less than the first preset threshold.
[0128] In one exemplary embodiment, the first correction module described above includes:
[0129] The sixth determining unit is used to determine the registration matrix between the first image and the second image based on the above N coordinate deviation values;
[0130] The first correction unit is used to correct the position of the target region in the first image using the registration matrix to obtain the target image.
[0131] In one exemplary embodiment, the sixth determining unit includes:
[0132] The third determining subunit is used to determine the first image feature of the first image and the second image feature of the second image.
[0133] The first registration subunit is used to register the first image feature and the second image feature according to each of the above coordinate deviation values to obtain the above registration matrix.
[0134] In one exemplary embodiment, the first correction unit includes:
[0135] The fourth determining sub-unit is used to determine the three-dimensional coordinates of each of the above-mentioned position points using the elements in the above-mentioned registration matrix and each of the above-mentioned coordinates;
[0136] The first correction subunit is used to correct the position of the target region in the first image by normalizing the three-dimensional coordinates of each of the above-mentioned location points and each of the above-mentioned coordinates, so as to obtain the target image.
[0137] In one exemplary embodiment, the above-described apparatus further includes:
[0138] The first update module is used to correct the position of the target region in the first image using the registration matrix, and after obtaining the target image, update the second image using the first image if the similarity between the first image and the second image is greater than or equal to a second threshold.
[0139] In one exemplary embodiment, the above-described apparatus further includes:
[0140] The fourth determining module is used to correct the position of the target region in the first image using the above N deviation values, and after obtaining the target image, to determine the corrected N position points in the target image;
[0141] The first connection module is used to connect the corrected N position points in the target image to obtain the corrected first image region, wherein the first image region is the image region of the target region in the first image.
[0142] It should be noted that the above modules can be implemented by software or hardware. For the latter, they can be implemented in the following ways, but are not limited to: all the above modules are located in the same processor; or, the above modules are located in different processors in any combination.
[0143] Embodiments of the present invention also provide a computer-readable storage medium storing a computer program, wherein the computer program is configured to perform the steps in any of the above method embodiments when executed.
[0144] In this embodiment, the computer-readable storage medium described above may be configured to store a computer program for performing the above steps.
[0145] In one exemplary embodiment, the aforementioned computer-readable storage medium may include, but is not limited to, various media capable of storing computer programs, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard disk, magnetic disk, or optical disk.
[0146] Embodiments of the present invention also provide an electronic device including a memory and a processor, the memory storing a computer program and the processor being configured to run the computer program to perform the steps in any of the above method embodiments.
[0147] In one exemplary embodiment, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor and the input / output device is connected to the processor.
[0148] In one exemplary embodiment, the processor described above may be configured to perform the above steps via a computer program.
[0149] Specific examples in this embodiment can be found in the examples described in the above embodiments and exemplary implementations, and will not be repeated here.
[0150] It is obvious to those skilled in the art that the modules or steps of the present invention described above can be implemented using general-purpose computing devices. They can be centralized on a single computing device or distributed across a network of multiple computing devices. They can be implemented using computer-executable program code, and thus can be stored in a storage device for execution by a computing device. In some cases, the steps shown or described can be performed in a different order than those described herein, or they can be fabricated as separate integrated circuit modules, or multiple modules or steps can be fabricated as a single integrated circuit module. Thus, the present invention is not limited to any particular combination of hardware and software.
[0151] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, or improvements made within the principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. An image correction method characterized by, The method comprises: obtaining a first image captured by a camera device on a preset region, wherein the first image comprises a target region in the preset region; determining coordinates of N position points of the target region in the first image, to obtain N coordinates, wherein N is a natural number greater than 1; determining, in a second image, coordinates of preset position points corresponding to each of the N position points, to obtain N preset coordinates, wherein the second image is an image captured by the camera device on the preset region; determining a deviation value between each of the coordinates and each of the preset coordinates, to obtain N deviation values; correcting the position of the target region in the first image by using the N deviation values, to obtain a target image; wherein determining a deviation value between each of the coordinates and each of the preset coordinates, to obtain N deviation values, comprises: determining a similarity between the first image and the second image; in a case where the similarity between the first image and the second image is greater than or equal to a first preset threshold, calculating a deviation region between each of the coordinates and each of the preset coordinates, to obtain N deviation regions; and obtaining the N deviation values based on a number of pixels included in each of the deviation regions.
2. The method of claim 1, wherein, determining coordinates of N position points of the target region in the first image, to obtain N coordinates, comprises: determining a first image region of the target region in the first image; determining N vertices in the first image region as the N position points; determining coordinates of the N position points in a preset image coordinate system, to obtain the N coordinates.
3. The method of claim 1, wherein, determining, in a second image, coordinates of preset position points corresponding to each of the N position points, to obtain N preset coordinates, comprises: labeling each of the preset position points matched with each of the position points in the second image; determining coordinates of each of the preset position points in a preset image coordinate system, to obtain the N preset coordinates.
4. The method of claim 1, wherein, determining a similarity between the first image and the second image, comprises: dividing the first image into M image regions, wherein M is a natural number greater than 1; determining a second image region from the M image regions; comparing pixels in the second image region with pixels in a corresponding image region in the second image; determining a similarity between the pixels in the second image region and the pixels in the corresponding image region in the second image as the similarity between the first image and the second image.
5. The method of claim 1, wherein, The method further comprises: in a case where the similarity between the first image and the second image is less than the first preset threshold, obtaining a third image captured by the camera device on the preset region within a preset time period after obtaining the first image.
6. The method of claim 1, wherein, correcting the position of the target region in the first image by using the N coordinate deviation values, to obtain a target image, comprises: determining a registration matrix between the first image and the second image based on the N coordinate deviation values; The registration matrix is used to correct the position of the target region in the first image, and a target image is obtained.
7. The method of claim 6, wherein, The registration matrix between the first image and the second image is determined based on the N coordinate deviation values, including: First image features of the first image and second image features of the second image are determined. The first image features and the second image features are registered according to each of the coordinate deviation values, and the registration matrix is obtained.
8. The method of claim 7, wherein, The registration matrix is used to correct the position of the target region in the first image, and a target image is obtained, including: The three-dimensional coordinates of each of the position points are determined by using the elements in the registration matrix and each of the coordinates. The position of the target region in the first image is corrected by normalizing the three-dimensional coordinates of each of the position points and each of the coordinates, and the target image is obtained.
9. The method of claim 6, wherein, After the registration matrix is used to correct the position of the target region in the first image, and a target image is obtained, the method further includes: In a case where the similarity between the first image and the second image is greater than or equal to a second threshold value, the second image is updated by using the first image.
10. The method of claim 1, wherein, After the N deviation values are used to correct the position of the target region in the first image, and a target image is obtained, the method further includes: N corrected position points in the target image are determined. The N corrected position points are connected in the target image, and a corrected first image region is obtained, wherein the first image region is an image region of the target region in the first image.
11. An image correction apparatus characterized by comprising: It includes: The first acquisition module is configured to acquire a first image obtained by a camera device capturing a preset region, wherein the first image includes a target region in the preset region. The first determination module is configured to determine coordinates of N position points of the target region in the first image, and obtain N coordinates, wherein N is a natural number greater than 1. The second determination module is configured to determine coordinates of preset position points corresponding to each of the N position points in a second image, and obtain N preset coordinates, wherein the second image is an image obtained by the camera device capturing the preset region. The third determination module is configured to determine a deviation value between each of the coordinates and each of the preset coordinates, and obtain N deviation values. The first correction module is configured to correct the position of the target region in the first image by using the N deviation values, and obtain a target image. The third determination module is further configured to determine the similarity between the first image and the second image, and in a case where the similarity between the first image and the second image is greater than or equal to a first preset threshold value, calculate a deviation area between each of the coordinates and each of the preset coordinates, and obtain N deviation areas. The N deviation values are obtained based on the number of pixels included in each of the deviation areas.
12. A computer-readable storage medium, characterized in that, The computer readable storage medium stores a computer program, wherein the computer program is executed by a processor to implement the method described in any one of claims 1 to 10. The computer readable storage medium stores a computer program, wherein the computer program is executed by a processor to implement the method described in any one of claims 1 to 10. 13.An electronic device comprising a memory and a processor, the electronic device characterized by, The memory stores a computer program, and the processor is configured to run the computer program to execute the method in any one of claims 1 to 10.
Citation Information
Patent Citations
Spacecraft autonomous navigation rapid image matching method
CN107481273A
Image stitching method based on unmanned aerial vehicle POS information and image SURF feature combination
CN107808362A