Image parameter calibration method, device and equipment
The method and device address irregular quadrilateral issues in image recognition by systematically determining vertex coordinates, improving calibration accuracy and reducing annotation errors for enhanced reliability.
Patent Information
- Application Number
- CN202411082321.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-08
- Publication Date
- 2024-12-13
- Estimated Expiration
- 2044-08-08
AI Technical Summary
Existing image recognition systems face challenges due to irregular quadrilaterals with acute and obtuse angles and random coordinate point ordering, leading to errors in target area annotation, particularly affecting text recognition reliability.
A method and device for calibrating image parameters by determining the vertex with the smallest ordinate value as the first vertex, calculating vectors between this vertex and others, and using vector operations to determine the remaining vertices, ensuring accurate parameter calibration.
Improves the convenience and accuracy of image parameter calibration by systematically arranging vertex coordinates, reducing errors in target area annotation and enhancing the reliability of image recognition.
Smart Images

Figure CN118608750B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data processing, and in particular to a method, device and equipment for calibrating image parameters. Background Art
[0002] After the target recognition in the image, including text recognition, it is usually necessary to frame the target in the image with a quadrilateral, and obtain the coordinates of the four vertices after the frame. Then, the target area is captured according to the four coordinate points, and another rectangular image is generated by image transformation. This generated rectangular image is the final result as the recognition training material, because the quadrilateral area is the main body of the target, and the image including the background image cannot be used as the training for image recognition.
[0003] However, in the actual image recognition process, due to the influence of factors such as shooting angle and target shape, the target area is often complex, so the resulting quadrilateral is also irregular, with both acute and obtuse angles, and any rotation angle is possible. At the same time, in the large amount of work of annotating data, in order to pursue work speed, operators often annotate the targets in any convenient way, and the order of the marked coordinate points is not fixed, but has a lot of randomness. If these coordinate points are not arranged in order, the left and right may be reversed and the top and bottom may be reversed when converting the rectangle, resulting in a large amount of erroneous data, especially the reversal of text, which will lead to errors in the order and font of the text in the sentence, which greatly affects the reliability of image recognition training. Summary of the invention
[0004] In view of this, the present invention provides a method, device and apparatus for calibrating image parameters to solve the problems of low convenience and accuracy of image parameter calibration in the related art.
[0005] In a first aspect, the present invention provides a method for calibrating image parameters, the method comprising:
[0006] Get the vertex coordinates of the convex quadrilateral corresponding to the target area in the image to be calibrated;
[0007] Get the vertex coordinates with the smallest ordinate value among the vertex coordinates of the convex quadrilateral, and mark them as the first vertex coordinates;
[0008] Calculate a first vector between the coordinates of the first vertex and the coordinates of one of the unmarked vertices, and two second vectors between the coordinates of the first vertex and the coordinates of any of the remaining unmarked vertices;
[0009] Determine the second vertex coordinates, the third vertex coordinates, and the fourth vertex coordinates corresponding to the unmarked vertex coordinates based on the vector operation result between the first vector and the second vector;
[0010] Based on the first vertex coordinates, the second vertex coordinates, the third vertex coordinates and the fourth vertex coordinates, parameter calibration is performed on the image to be calibrated.
[0011] In some optional implementations, obtaining the vertex coordinates with the smallest ordinate value among the vertex coordinates of the convex quadrilateral and marking them as the first vertex coordinates includes:
[0012] Get the ordinate value of each vertex coordinate in the vertex coordinates of the convex quadrilateral;
[0013] Compare the coordinate values of each vertex coordinate to obtain the vertex coordinate with the smallest ordinate value among the vertex coordinates of the convex quadrilateral;
[0014] Mark the vertex coordinate with the smallest ordinate value as the first vertex coordinate.
[0015] In some optional implementations, determining the second vertex coordinates, the third vertex coordinates, and the fourth vertex coordinates corresponding to the unmarked vertex coordinates based on the vector operation result between the first vector and the second vector includes:
[0016] Calculate the product of the first vector and the two second vectors respectively to obtain two vector products;
[0017] When the two vector products have the same sign, update the first vector;
[0018] When the two vector products have different signs, determine the third vertex coordinates and the fourth vertex coordinates corresponding to the unmarked vertex coordinates;
[0019] Based on the vector product of the two vector products that is greater than zero, the second vertex coordinates corresponding to the unmarked vertex coordinates are determined.
[0020] In some optional implementations, when the two vector products have different signs, determining the third vertex coordinates and the fourth vertex coordinates corresponding to the unmarked vertex coordinates includes:
[0021] When two vector products have different signs, the unmarked vertex coordinates in the first vector are used as the third vertex coordinates;
[0022] Based on the vector product of the two vector products being less than zero, the unmarked vertex coordinates in the second vector are used as the fourth vertex coordinates.
[0023] In some optional implementations, determining the second vertex coordinates corresponding to the unmarked vertex coordinates based on the vector product of the two vector products that is greater than zero includes:
[0024] Based on the vector product of the two vector products being greater than zero, the unmarked vertex coordinates in the second vector are taken as the second vertex coordinates.
[0025] In some optional embodiments, before calculating the first vector of the first vertex coordinate and one of the unmarked vertex coordinates, and the two second vectors of the first vertex coordinate and any of the remaining unmarked vertex coordinates, the method further includes:
[0026] Obtain the first vertex coordinates and the first coordinate value of one of the unmarked vertex coordinates, and the second coordinate values of the remaining two unmarked vertex coordinates;
[0027] The first coordinate value is compared with the second coordinate value to obtain a coordinate value comparison result, wherein the coordinate value comparison result includes that the maximum horizontal coordinate value and the maximum vertical coordinate value between the first vertex coordinate and one of the unmarked vertex coordinates are both greater than the minimum horizontal coordinate value and the minimum vertical coordinate value between the other two unmarked vertex coordinates, and the maximum horizontal coordinate value and the maximum vertical coordinate value between the other two unmarked vertex coordinates are both greater than the minimum horizontal coordinate value and the minimum vertical coordinate value between the first vertex coordinate and one of the unmarked vertex coordinates.
[0028] In some optional implementations, the above method further includes:
[0029] Obtain a first slope of a line segment formed by the first vertex coordinates and the second vertex coordinates, and a second slope of a line segment formed by the first vertex coordinates and the fourth vertex coordinates;
[0030] Comparing the absolute value of the first slope with the absolute value of the second slope to obtain a slope comparison value result;
[0031] The positions of the first vertex coordinates, the second vertex coordinates, the third vertex coordinates, and the fourth vertex coordinates are adjusted based on the slope comparison value result.
[0032] In some optional implementations, the above method further includes:
[0033] Obtain a first distance between the first vertex coordinates and the second vertex coordinates, and a second distance between the first vertex coordinates and the fourth vertex coordinates;
[0034] Comparing the absolute value of the first distance with the absolute value of the second distance to obtain a distance comparison value result;
[0035] The positions of the first vertex coordinates, the second vertex coordinates, the third vertex coordinates, and the fourth vertex coordinates are adjusted based on the distance comparison value result.
[0036] In a second aspect, the present invention provides a device for calibrating image parameters, the device comprising:
[0037] A coordinate acquisition module is used to obtain the coordinates of the convex quadrilateral vertices corresponding to the target area in the image to be calibrated;
[0038] A first marking module, used to obtain the vertex coordinates with the smallest ordinate value among the vertex coordinates of the convex quadrilateral, and mark them as the first vertex coordinates;
[0039] A coordinate marking module is used to obtain the vertex coordinates with the smallest ordinate value among the vertex coordinates of the convex quadrilateral and mark them as the first vertex coordinates;
[0040] A vector calculation module, used for calculating a first vector of the first vertex coordinate and one of the unmarked vertex coordinates, and two second vectors of the first vertex coordinate and any of the remaining unmarked vertex coordinates;
[0041] A coordinate determination module, for determining a second vertex coordinate, a third vertex coordinate, and a fourth vertex coordinate corresponding to the unmarked vertex coordinate based on a vector operation result between the first vector and the second vector;
[0042] The parameter calibration module is used to perform parameter calibration on the image to be calibrated based on the first vertex coordinates, the second vertex coordinates, the third vertex coordinates and the fourth vertex coordinates.
[0043] In a third aspect, the present invention provides a computer device, comprising:
[0044] The memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the image parameter calibration method of the first aspect or any corresponding embodiment thereof by executing the computer instructions.
[0045] In a fourth aspect, the present invention provides a computer-readable storage medium having computer instructions stored thereon, the computer instructions being used to enable a computer to execute the image parameter calibration method of the first aspect or any corresponding embodiment thereof.
[0046] The technical solution provided by the embodiment of the present invention obtains the vertex coordinates of the convex quadrilateral corresponding to the target area in the image to be calibrated, and then determines the first vertex coordinate based on the vertex coordinate with the smallest ordinate value in the vertex coordinates of the convex quadrilateral; calculates the first vector of the first vertex coordinate and one of the unmarked vertex coordinates, and the two second vectors of the first vertex coordinate and any of the remaining unmarked vertex coordinates, and determines the second vertex coordinate, the third vertex coordinate and the fourth vertex coordinate corresponding to the unmarked vertex coordinate based on the vector operation result between the first vector and the second vector; and performs parameter calibration on the image to be calibrated based on the first vertex coordinate, the second vertex coordinate, the third vertex coordinate and the fourth vertex coordinate, thereby improving the convenience and accuracy of image parameter calibration.
[0047] The above description is only an overview of the technical solution of the embodiment of the present invention. In order to more clearly understand the technical means of the embodiment of the present invention, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the embodiment of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0049] Figure 1 is a flow chart of a method for calibrating image parameters according to an embodiment of the present invention;
[0050] Figure 2 is a schematic diagram of a scene for calibration of image parameters according to an embodiment of the present invention;
[0051] Figure 3 is a structural block diagram of an image parameter calibration device according to an embodiment of the present invention;
[0052] Figure 4 It is a schematic diagram of the hardware structure of a computer device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0053] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0054] In this embodiment, a method for calibrating image parameters is provided. Figure 1 1 is a flow chart of a method for calibrating image parameters according to an embodiment of the present invention, which is applied to an image parameter calibration device. The flow chart includes the following steps:
[0055] Step S101, obtaining the vertex coordinates of the convex quadrilateral corresponding to the target area in the image to be calibrated.
[0056] The target area of the image to be calibrated may be the area where the target image is located, or the area where the target text is located. The vertex coordinates of the convex quadrilateral corresponding to the target area may be determined based on the plane coordinate system where the image to be calibrated is located, or may be determined by the coordinate system established by the plane where the convex quadrilateral is located in the calibration interface of the image parameter calibration device.
[0057] Step S102, obtaining the vertex coordinates with the smallest ordinate value among the vertex coordinates of the convex quadrilateral, and marking them as the first vertex coordinates.
[0058] Specifically, first obtain the ordinate value of each vertex coordinate in the vertex coordinates of the convex quadrilateral; then compare the coordinate values of each vertex coordinate to obtain the vertex coordinate with the smallest ordinate value in the vertex coordinates of the convex quadrilateral; finally, mark the vertex coordinate with the smallest ordinate value as the first vertex coordinate.
[0059] For example, see Figure 2 First, compare the ordinate values among the vertex coordinates of the convex quadrilateral (i.e., the four vertex coordinates) to obtain the vertex coordinate with the smallest ordinate value; mark the vertex coordinate with the smallest ordinate value as the starting point and mark it as the first vertex coordinate p 1 It can be understood that the first vertex is located closest to the x-axis of the convex quadrilateral, that is, the two endpoints of the top edge. 4 、p 1 The points at the same position may also be the first vertex. If there are two vertices with the smallest ordinate, the one with the smaller abscissa is selected.
[0060] Step S103, calculating a first vector between the first vertex coordinate and one of the unmarked vertex coordinates, and two second vectors between the first vertex coordinate and any of the remaining unmarked vertex coordinates.
[0061] As described above, by calculating the first vertex coordinate and the first vector of one of the unmarked vertex coordinates, and the two second vectors of the first vertex coordinate and any of the remaining unmarked vertex coordinates, the coordinate positions of other vertices can be confirmed based on the first vector and the second vector.
[0062] Step S104 , determining the second vertex coordinates, the third vertex coordinates, and the fourth vertex coordinates corresponding to the unmarked vertex coordinates based on the vector operation result between the first vector and the second vector.
[0063] Specifically, calculate the product of the first vector and the two second vectors respectively to obtain two vector products; when the two vector products have the same sign, update the first vector; when the two vector products have different signs, determine the third vertex coordinates and the fourth vertex coordinates corresponding to the unmarked vertex coordinates; based on the vector product greater than zero in the two vector products, determine the second vertex coordinates corresponding to the unmarked vertex coordinates.
[0064] In some optional embodiments, when two vector products have different signs, the unmarked vertex coordinates in the first vector are used as the third vertex coordinates; based on the vector product of the two vector products that is less than zero, the unmarked vertex coordinates in the second vector are used as the fourth vertex coordinates; based on the vector product of the two vector products that is greater than zero, the unmarked vertex coordinates in the second vector are used as the second vertex coordinates.
[0065] For example, see Figure 2 , let p 1 、p 2 、p 3 、p 4 The coordinates of are (x 1 ,y 1 ), (x 2 ,y 2 ), (x 3 ,y 3 ), (x 4 ,y 4 ), the coordinates of the first vertex p 1 and the coordinates of one of the unlabeled vertices, such as p 3 Coordinates, the first vector formed is p 1 p 3 , the coordinates of the first vertex p 1 and the coordinates of any other unmarked vertices (p 2 or p 4 ) are p 1 p 2 、p 1 p 4 ; Put the first vector p 1 p 3 Respectively with the two vectors p in the second vector 1 p 2 and p 1 p 4 Compute the vector product, with p 1 p 3 ×p 1 p 2 and p 1 p 3 ×p 1 p 4 , if the results of the two vector products are of opposite signs, then p 3 It can be determined as the third coordinate point, and the side where the result is greater than zero, such as p 1 p 3 ×p 1 p 2 >0, we can determine p 2 is the second coordinate, correspondingly p 1 p 3×p 1 p 4 <0 then p 4 is the fourth coordinate.
[0066] In some optional embodiments, the diagonal point of the first vertex coordinate can be determined and marked as the third vertex coordinate based on the first vertex coordinate and the first vector of one of the unmarked vertex coordinates, and the result of a vector operation between the first vertex coordinate and two second vectors of any of the remaining unmarked vertex coordinates.
[0067] Specifically, obtain the first coordinate value of the first vertex coordinate and one of the unmarked vertex coordinates, and the second coordinate value of the remaining two unmarked vertex coordinates; compare the first coordinate value with the second coordinate value to obtain a coordinate value comparison result; calculate the first vector of the first vertex coordinate and any unmarked vertex coordinate, and the vector product between the first vertex coordinate and the second vector of the remaining two unmarked vertex coordinates in the vertex coordinates of the convex quadrilateral to obtain a vector operation result; based on the vector operation result, if the two vector products have different signs, determine the diagonal point of the first vertex coordinate and mark it as the third vertex coordinate, as well as the second vertex coordinate and the fourth vertex coordinate. Wherein, the coordinate value comparison result includes the maximum horizontal coordinate value and the maximum vertical coordinate value of the first vertex coordinate and one of the unmarked vertex coordinates, both of which are greater than the minimum horizontal coordinate value and the minimum vertical coordinate value of the remaining two unmarked vertex coordinates, and the maximum horizontal coordinate value and the maximum vertical coordinate value of the remaining two unmarked vertex coordinates are greater than the minimum horizontal coordinate value and the minimum vertical coordinate value of the first vertex coordinate and one of the unmarked vertex coordinates.
[0068] For example, see Figure 2 , let p 1 、p 2 、p 3 、p 4 The coordinates of are (x 1 ,y 1 ), (x 2 ,y 2 ), (x 3 ,y 3 ), (x 4 ,y 4 ), if line segment p 1 p 3 and line segment p 2 p 4 If they intersect, then x 1 and x 3 The larger value of will be greater than x 2 and x 4 The smaller value of y 1 and 3 The larger the value of y 2 and4 The smaller value of x 2 and x 4 The larger value of will be greater than x 1 and x 3 The smaller value of y 2 and 4 The larger the value of y 1 and 3 The smaller value of , all four conditions are met, which is a necessary condition for the intersection of line segments. If any of them are not met, the two line segments must not intersect, thereby eliminating the situation where part of the two line segments do not intersect, and improving the efficiency of parameter determination.
[0069] If p 2 and p 4 On line segment p 1 p 3 At both ends, the first vector p 1 p 3 and the vector p in the second vector 1 p 2 The vector product of the first vector p 1 p 3 and the vector p in the second vector 1 p 4 The vector product of p 1 p 3 ×p 1 p 2 and p 1 p 3 ×p 1 p 4 , judge p 3 Is it p 1 At this time, if p 2 is relative to the coordinates of the first vertex p 1 If the vector product is greater than 0, then p 1 p 3 ×p 1 p 2 =(x 3 -x 1 )(y 2 -y 1 )-(x 2 -x 1 )(y 3 -y 1 )>0; Similarly, if p 4 is relative to the coordinates of the first vertex p 1 counterclockwise point, then p 1 p 3 ×p 1 p 4 =(x 3-x 1 )(y 4 -y 1 )-(x 4 -x 1 )(y 3 -y 1 )<0. By calculating the vector product, we can confirm that p 3 At the same time, p 2 and p 4 location.
[0070] In the operation, since the first vertex coordinate p 1 is the known point obtained in the above step. The remaining three endpoints are respectively based on the result of the first vector operation to find the corresponding diagonal points, that is, the coordinates of the third vertex p 3 .
[0071] It is understandable that if the result of the vector product calculation is not of opposite signs, then it is necessary to loop through the coordinate value comparison and the first vector operation of the remaining three coordinates in the vertex coordinates of the convex quadrilateral to find the first vertex coordinate p that meets the conditions. 1 The diagonal point is recorded as the coordinate of the third vertex p 3 That is, if the coordinates of the third vertex p 3 is a diagonal point, then point p 2 With p 4 In the first vector p 1 p 3 on both sides.
[0072] In some optional embodiments, when determining the second vertex coordinates and the fourth vertex coordinates corresponding to the unmarked vertex coordinates based on the vector operation result between the first vector and the second vector, it is also possible to determine that the corresponding unmarked vertex coordinates in the second vector are located in the clockwise direction of the first vertex coordinates when the vector product of the first vector (i.e., the vector corresponding to the first vertex coordinates and the third vertex coordinates) and the second vector is greater than zero; when the vector product of the first vector and the second vector is less than zero, determine that the corresponding unmarked vertex coordinates in the fourth vector are located in the counterclockwise direction of the first vertex coordinates.
[0073] Step S105 , performing parameter calibration on the image to be calibrated based on the first vertex coordinates, the second vertex coordinates, the third vertex coordinates and the fourth vertex coordinates.
[0074] As described above, by calibrating the vertex coordinates of the convex quadrilateral corresponding to the target area in the calibrated image based on the positions of the first vertex coordinates, the second vertex coordinates, the third vertex coordinates and the fourth vertex coordinates, the convenience and accuracy of the image parameter calibration are improved.
[0075] In some optional embodiments, the first slope of the line segment formed by the first vertex coordinates and the second vertex coordinates, as well as the second slope of the line segment formed by the first vertex coordinates and the fourth vertex coordinates can also be obtained; the absolute value of the first slope is compared with the absolute value of the second slope to obtain a slope comparison value result; and the positions of the first vertex coordinates, the second vertex coordinates, the third vertex coordinates and the fourth vertex coordinates are adjusted based on the slope comparison value result.
[0076] Specifically, due to the huge amount of annotation data, it is inevitable that the angle of the target position will be special. Finally, a final step is required to determine whether to adjust the coordinate order, such as Figure 2 As shown, in general, vertex p 4 More suitable as the upper left corner point (first vertex coordinates) p 1 At this time, according to the point closest to the x-axis (the coordinate of the first vertex) p 1 The absolute value of the slope of the two connected line segments is taken as the smaller line segment as the top of the convex quadrilateral, and the left endpoint of this line segment is taken as p 1 That is, if |(y 1 -y 4 ) / (x 1 -x 4 )|<|(y 1 -y 2 ) / (x 1 -x 2 )|, then point p 1 、p 2 、p 3 、p 4 Respectively changed to p 2 、p 3 、p 4 、p 1 .
[0077] In some optional embodiments, it is also possible to obtain a first distance between the first vertex coordinates and the second vertex coordinates, and a second distance between the first vertex coordinates and the fourth vertex coordinates; compare the absolute value of the first distance with the absolute value of the second distance to obtain a distance comparison value result; and adjust the positions of the first vertex coordinates, the second vertex coordinates, the third vertex coordinates, and the fourth vertex coordinates based on the distance comparison value result.
[0078] Specifically, the method of re-modifying the starting point based on the absolute value of the slope is universal, but it may be modified for different specific image scenarios. For example, in text recognition, for modern text typesetting, the text is arranged horizontally, resulting in the final result being a horizontal long rectangle. This is not only true for text recognition. The specific operation depends on the specific business scenario and is combined with reality. At this time, the method of re-modifying the coordinates of the first vertex based on the absolute value of the slope should be changed to modifying it based on the vertex distance, that is, if |p 1 p 4 |>|p 1 p 3 |, equivalent to (x 1 -x 4 ) 2 +(y 1 -y 4 ) 2 >(x 1 -x 3 ) 2 +(y 1 -y 3 ) 2 , then point p 1 、p 2 、p 3 、p 4 Respectively changed to p 2 、p 3 、p 4 、p 1 .
[0079] The technical solution provided by the embodiment of the present invention obtains the vertex coordinates of the convex quadrilateral corresponding to the target area in the image to be calibrated, and then determines the first vertex coordinate based on the vertex coordinate with the smallest ordinate value in the vertex coordinates of the convex quadrilateral; calculates the first vector of the first vertex coordinate and one of the unmarked vertex coordinates, and the two second vectors of the first vertex coordinate and any of the remaining unmarked vertex coordinates, and determines the second vertex coordinate, the third vertex coordinate and the fourth vertex coordinate corresponding to the unmarked vertex coordinate based on the vector operation result between the first vector and the second vector; and performs parameter calibration on the image to be calibrated based on the first vertex coordinate, the second vertex coordinate, the third vertex coordinate and the fourth vertex coordinate, thereby improving the convenience and accuracy of image parameter calibration.
[0080] This embodiment provides a device for calibrating image parameters, such as Figure 3 As shown, including:
[0081] The coordinate acquisition module 301 is used to acquire the coordinates of the vertices of the convex quadrilateral corresponding to the target area in the image to be calibrated.
[0082] The coordinate marking module 302 is used to obtain the vertex coordinates with the smallest ordinate value among the vertex coordinates of the convex quadrilateral, and mark them as the first vertex coordinates.
[0083] The vector calculation module 303 is used to calculate a first vector between the first vertex coordinate and one of the unmarked vertex coordinates, and two second vectors between the first vertex coordinate and any of the remaining unmarked vertex coordinates.
[0084] The coordinate determination module 304 is used to determine the second vertex coordinates, the third vertex coordinates and the fourth vertex coordinates corresponding to the unmarked vertex coordinates based on the vector operation result between the first vector and the second vector.
[0085] The parameter calibration module 350 is used to perform parameter calibration on the image to be calibrated based on the first vertex coordinates, the second vertex coordinates, the third vertex coordinates and the fourth vertex coordinates.
[0086] In some optional implementations, the coordinate marking module 302 includes:
[0087] The coordinate value acquisition unit is used to obtain the ordinate value of each vertex coordinate in the vertex coordinates of the convex quadrilateral.
[0088] The coordinate value comparison unit is used to compare the coordinate values of each vertex coordinate to obtain the vertex coordinate with the smallest ordinate value among the vertex coordinates of the convex quadrilateral.
[0089] The coordinate marking unit is used to mark the vertex coordinate with the smallest ordinate value as the first vertex coordinate.
[0090] In some optional implementations, the coordinate determination module 304 includes:
[0091] The vector product calculation unit is used to calculate the product of the first vector and two second vectors respectively to obtain two vector products.
[0092] A first vector updating unit, used for updating the first vector when the two vector products have the same sign;
[0093] The first coordinate determining unit is used to determine the third vertex coordinate and the fourth vertex coordinate corresponding to the unmarked vertex coordinate when the two vector products have different signs.
[0094] Specifically, when two vector products have different signs, the unmarked vertex coordinates in the first vector are used as the third vertex coordinates; based on the vector product of the two vector products that is less than zero, the unmarked vertex coordinates in the second vector are used as the fourth vertex coordinates.
[0095] The second coordinate calibration unit is used to determine the second vertex coordinates corresponding to the unmarked vertex coordinates based on the vector product greater than zero of the two vector products.
[0096] Specifically, based on the vector product of the two vector products that is greater than zero, the unmarked vertex coordinates in the second vector are used as the second vertex coordinates.
[0097] In some optional implementations, the vector calculation module 303 includes:
[0098] A coordinate value acquisition unit, used for acquiring the first vertex coordinate and the first coordinate value of one of the unmarked vertex coordinates, and the second coordinate values of the remaining two unmarked vertex coordinates;
[0099] The coordinate value comparison unit compares the first coordinate value with the second coordinate value to obtain a coordinate value comparison result, wherein the coordinate value comparison result includes that the maximum horizontal coordinate value and the maximum vertical coordinate value of the first vertex coordinate and one of the unmarked vertex coordinates are both greater than the minimum horizontal coordinate value and the minimum vertical coordinate value of the other two unmarked vertex coordinates, and the maximum horizontal coordinate value and the maximum vertical coordinate value of the other two unmarked vertex coordinates are both greater than the minimum horizontal coordinate value and the minimum vertical coordinate value of the first vertex coordinate and one of the unmarked vertex coordinates.
[0100] In some optional embodiments, the coordinate determination module 304 is further used to obtain a first slope of a line segment formed by the first vertex coordinates and the second vertex coordinates, and a second slope of a line segment formed by the first vertex coordinates and the fourth vertex coordinates; compare the absolute value of the first slope with the absolute value of the second slope to obtain a slope comparison value result; and adjust the positions of the first vertex coordinates, the second vertex coordinates, the third vertex coordinates, and the fourth vertex coordinates based on the slope comparison value result.
[0101] In some optional embodiments, the coordinate determination module 304 is also used to obtain a first distance between the first vertex coordinates and the second vertex coordinates, and a second distance between the first vertex coordinates and the fourth vertex coordinates; compare the absolute value of the first distance with the absolute value of the second distance to obtain a distance comparison value result; and adjust the positions of the first vertex coordinates, the second vertex coordinates, the third vertex coordinates, and the fourth vertex coordinates based on the distance comparison value result.
[0102] The image parameter calibration device provided in the present embodiment and the technical solution provided in the embodiment of the present invention obtain the vertex coordinates of the convex quadrilateral corresponding to the target area in the image to be calibrated, and then determine the first vertex coordinates based on the vertex coordinates with the smallest ordinate value in the vertex coordinates of the convex quadrilateral; calculate the first vector of the first vertex coordinate and one of the unmarked vertex coordinates, and the two second vectors of the first vertex coordinate and any of the remaining unmarked vertex coordinates, and determine the second vertex coordinates, the third vertex coordinates and the fourth vertex coordinates corresponding to the unmarked vertex coordinates based on the vector operation result between the first vector and the second vector; calibrate the parameters of the image to be calibrated based on the first vertex coordinates, the second vertex coordinates, the third vertex coordinates and the fourth vertex coordinates, thereby improving the convenience and accuracy of image parameter calibration.
[0103] The further functional description of each of the above modules and units is the same as that of the above corresponding embodiments and will not be repeated here.
[0104] The image parameter calibration device in this embodiment is presented in the form of a functional unit, where the unit refers to an ASIC (Application Specific Integrated Circuit) circuit, a processor and memory that executes one or more software or fixed programs, and / or other devices that can provide the above functions.
[0105] The embodiment of the present invention also provides a computer device having the above Figure 3 The battery health status prediction device shown.
[0106] See also Figure 4 , Figure 4 is a schematic diagram of the structure of a computer device provided by an optional embodiment of the present invention, such as Figure 4 As shown, the computer device includes: one or more processors 10, a memory 20, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. Various components are connected to each other using different buses for communication, and can be installed on a common mainboard or installed in other ways as needed. The processor can process the instructions executed in the computer device, including instructions stored in or on the memory to display the graphical information of the GUI on an external input / output device (such as, a display device coupled to the interface). In some optional embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories and multiple memories. Similarly, multiple computer devices can be connected, and each device provides some necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Figure 4 A processor 10 is taken as an example.
[0107] The processor 10 may be a central processing unit, a network processor or a combination thereof. The processor 10 may further include a hardware chip. The hardware chip may be a dedicated integrated circuit, a programmable logic device or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable gate array, a general purpose array logic or any combination thereof.
[0108] The memory 20 stores instructions executable by at least one processor 10, so that at least one processor 10 executes the method shown in the above embodiment.
[0109] The memory 20 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created according to the use of the computer device, etc. In addition, the memory 20 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some optional embodiments, the memory 20 may optionally include a memory remotely arranged relative to the processor 10, and these remote memories may be connected to the computer device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0110] The memory 20 may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a flash memory, a hard disk or a solid state drive; the memory 20 may also include a combination of the above types of memory.
[0111] The computer device further comprises a communication interface 30 for the computer device to communicate with other devices or a communication network.
[0112] The embodiment of the present invention also provides a computer-readable storage medium. The method according to the embodiment of the present invention can be implemented in hardware, firmware, or can be implemented as a computer code that can be recorded in a storage medium, or can be implemented as a computer code that is originally stored in a remote storage medium or a non-temporary machine-readable storage medium and will be stored in a local storage medium through a network download, so that the method described herein can be stored in such software processing on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only storage memory, a random access memory, a flash memory, a hard disk or a solid-state hard disk, etc.; further, the storage medium can also include a combination of the above types of memories. It can be understood that a computer, a processor, a microprocessor controller, or programmable hardware includes a storage component that can store or receive software or computer code. When the software or computer code is accessed and executed by a computer, a processor, or hardware, the method shown in the above embodiment is implemented.
[0113] Although the embodiments of the present invention have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present invention, and such modifications and variations are all within the scope defined by the appended claims.
Claims
1. A method for calibrating image parameters, characterized in that: The method comprises: Get the vertex coordinates of the convex quadrilateral corresponding to the target area in the image to be calibrated; Obtain the vertex coordinates with the smallest ordinate value among the vertex coordinates of the convex quadrilateral, and mark them as the first vertex coordinates; Calculate a first vector between the first vertex coordinate and one of the unmarked vertex coordinates, and two second vectors between the first vertex coordinate and any of the remaining unmarked vertex coordinates; Determine, based on a vector operation result between the first vector and the second vector, a second vertex coordinate, a third vertex coordinate, and a fourth vertex coordinate corresponding to the unmarked vertex coordinate; Based on the first vertex coordinates, the second vertex coordinates, the third vertex coordinates and the fourth vertex coordinates, parameter calibration is performed on the image to be calibrated; The determining of the second vertex coordinates, the third vertex coordinates and the fourth vertex coordinates corresponding to the unmarked vertex coordinates based on the vector operation result between the first vector and the second vector comprises: calculating the product of the first vector and the two second vectors respectively to obtain two vector products; when the two vector products have the same sign, updating the first vector; when the two vector products have different signs, determining the third vertex coordinates and the fourth vertex coordinates corresponding to the unmarked vertex coordinates; and determining the second vertex coordinates corresponding to the unmarked vertex coordinates based on the vector product greater than zero of the two vector products; When the two vector products have different signs, determining the third vertex coordinates and the fourth vertex coordinates corresponding to the unmarked vertex coordinates includes: when the two vector products have different signs, using the unmarked vertex coordinates in the first vector as the third vertex coordinates; based on the vector product of the two vector products that is less than zero, using the unmarked vertex coordinates in the second vector as the fourth vertex coordinates.
2. The method according to claim 1, characterized in that The step of obtaining the vertex coordinates of the convex quadrilateral with the smallest ordinate value and marking them as first vertex coordinates includes: Obtaining the ordinate value of each vertex coordinate in the vertex coordinates of the convex quadrilateral; Compare the coordinate values of the vertex coordinates to obtain the vertex coordinates with the smallest ordinate value among the vertex coordinates of the convex quadrilateral; The vertex coordinate with the smallest vertical coordinate value is marked as the first vertex coordinate.
3. The method according to claim 1, characterized in that The determining, based on the vector product of the two vector products that is greater than zero, the second vertex coordinates corresponding to the unmarked vertex coordinates comprises: Based on the vector product of the two vector products that is greater than zero, the unmarked vertex coordinates in the second vector are used as second vertex coordinates.
4. The method according to claim 1, characterized in that: Before calculating a first vector between the first vertex coordinate and one of the unlabeled vertex coordinates, and two second vectors between the first vertex coordinate and any of the remaining unlabeled vertex coordinates, the method further includes: Obtaining the first vertex coordinate and the first coordinate value of one of the unmarked vertex coordinates, and the second coordinate values of the remaining two unmarked vertex coordinates; The first coordinate value is compared with the second coordinate value to obtain a coordinate value comparison result, wherein the coordinate value comparison result includes that the maximum horizontal coordinate value and the maximum vertical coordinate value of the first vertex coordinate and one of the unmarked vertex coordinates are both greater than the minimum horizontal coordinate value and the minimum vertical coordinate value of the other two unmarked vertex coordinates, and the maximum horizontal coordinate value and the maximum vertical coordinate value of the other two unmarked vertex coordinates are both greater than the minimum horizontal coordinate value and the minimum vertical coordinate value of the first vertex coordinate and one of the unmarked vertex coordinates.
5. The method according to claim 1, characterized in that The method further comprises: Obtaining a first slope of a line segment formed by the first vertex coordinates and the second vertex coordinates, and a second slope of a line segment formed by the first vertex coordinates and the fourth vertex coordinates; Comparing the absolute value of the first slope with the absolute value of the second slope to obtain a slope comparison value result; The positions of the first vertex coordinates, the second vertex coordinates, the third vertex coordinates, and the fourth vertex coordinates are adjusted based on the slope comparison result.
6. The method according to claim 1, characterized in that The method further comprises: Acquire a first distance between the first vertex coordinates and the second vertex coordinates, and a second distance between the first vertex coordinates and the fourth vertex coordinates; Comparing the absolute value of the first distance with the absolute value of the second distance to obtain a distance comparison value result; The positions of the first vertex coordinates, the second vertex coordinates, the third vertex coordinates, and the fourth vertex coordinates are adjusted based on the distance comparison value result.
7. A device for calibrating image parameters, characterized in that: The device comprises: A coordinate acquisition module is used to obtain the coordinates of the convex quadrilateral vertices corresponding to the target area in the image to be calibrated; A coordinate marking module, used to obtain the vertex coordinates with the smallest ordinate value among the vertex coordinates of the convex quadrilateral, and mark them as the first vertex coordinates; A vector calculation module, used for calculating a first vector of the first vertex coordinate and one of the unmarked vertex coordinates, and two second vectors of the first vertex coordinate and any of the remaining unmarked vertex coordinates; a coordinate determination module, configured to determine, based on a vector operation result between the first vector and the second vector, a second vertex coordinate, a third vertex coordinate, and a fourth vertex coordinate corresponding to the unmarked vertex coordinate; A parameter calibration module, used for performing parameter calibration on the image to be calibrated based on the first vertex coordinates, the second vertex coordinates, the third vertex coordinates and the fourth vertex coordinates; The coordinate determination module includes: a vector product calculation unit, used for calculating the product of the first vector and two second vectors respectively, to obtain two vector products; a first vector update unit, used for updating the first vector when the two vector products have the same sign; a first coordinate determination unit, used for determining the third vertex coordinate and the fourth vertex coordinate corresponding to the unmarked vertex coordinate when the two vector products have different signs; a second coordinate calibration unit, used for determining the second vertex coordinate corresponding to the unmarked vertex coordinate based on the vector product greater than zero in the two vector products; The first coordinate determination unit is further used to use the unmarked vertex coordinates in the first vector as the third vertex coordinates when the two vector products have different signs; and use the unmarked vertex coordinates in the second vector as the fourth vertex coordinates based on the vector product of the two vector products that is less than zero.
8. A computer device, characterized in that: include: A memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the image parameter calibration method according to any one of claims 1 to 6 by executing the computer instructions.
Citation Information
Patent Citations
Method for calibrating convex quadrangle of image, electronic equipment and computer readable medium
CN116468798A
