Disclosure of Invention
In order to overcome the defect of fuzzy one-way control of the image pickup monitoring equipment in the existing image pickup tracking system, the invention provides the image pickup monitoring equipment matching control method based on the pixel coordinates.
The invention relates to a camera monitoring equipment matching control method based on pixel coordinates, which comprises the following steps:
s01: a camera acquires a collected image; calibrating a target and acquiring a pixel coordinate of the target;
s02: sequentially executing steps S03 and S04, or executing S04 and then executing S03; completing the matching control of the camera shooting monitoring equipment based on the pixel coordinates;
the S03 is as follows: according to the current value P of the target ratio1Current value of horizontal angle of view theta of camera1Setting the target ratio to a set value P2Converting into a set value theta of horizontal visual angle of the camera2;
According to the obtained horizontal visual angle set value theta of the camera2Controlling the zoom lens of the camera to enable the proportion of the target in the picture to reach a set proportion;
the S04 is as follows: obtaining a target angle offset according to the central coordinate of the target and the central coordinate of the collected image; and adjusting the camera according to the target angle offset to return the target to the center of the picture.
As a preferred aspect of the present invention, the method for controlling a zoom lens of a camera specifically comprises:
the camera comprises a camera shooting tracking host, an external hardware module and a zoom lens;
uniformly dividing the focal length of the zoom lens into N gears, and recording delta t as the time required by adjacent gear change; then
T is the moving time of the focal length of the motorized zoom lens from the maximum value to the minimum value or from the minimum value to the maximum value, and a lens gear-visual angle comparison table is established;
according to the lens gear-visual angle comparison table, the camera shooting tracking host machine sets the horizontal visual angle of the camera to be a set value theta2Converting into a gear setting gear n 2; the camera shooting tracking host sends gear setting information to the external hardware module, and the external hardware module compares the current gear to generate a focal length moving instruction to control the zoom lens and periodically feeds back the current gear to the camera shooting tracking host.
As a preferred scheme of the invention, the external hardware module receives a command from the camera tracking host, and updates the set gear n2 after verification;
every delta t time, the external hardware module judges the following steps: judging the current focal length control direction Dir, wherein a positive number indicates increasing, a negative number indicates decreasing, and 0 indicates stopping; calculating a gear potential difference delta n which is n2-n1, wherein the positive delta n represents that the focal length needs to be increased, the negative delta n represents that the focal length needs to be decreased, and 0 represents that the focal length value is just right;
and changing the current focal length control direction according to the values corresponding to the delta n and the Dir, and simultaneously returning the current gear value to the camera monitoring host.
The invention improves the native PELCO control protocol, realizes the quantitative stepping control and the periodic feedback of the zoom value of the zoom lens and the visual angle value of the camera; constructing a mathematical geometric model for calculating and correcting the target ratio, and further obtaining a calculation formula of a set value of a visual angle of the camera, so that the target pixel size ratio reaches the set value; and (3) constructing a mathematical geometric model for calculating and correcting the target offset, and further obtaining a calculation formula of the rotation value of the rotating holder, so that the target returns to the center of the picture. Through effect experiments, the invention can realize accurate and stable control of the camera monitoring equipment, so that the size of the visual angle of the equipment is self-matched with the size of a target, and the direction of the visual angle is self-matched with the movement amount of the target.
The method not only can realize the accurate control and feedback of the visual angle and orientation of the camera monitoring equipment, but also can realize the accurate matching calculation with the pixel coordinate, so that the target can return to the center of the picture and reach the set proportion.
Detailed Description
The invention will be further illustrated and described with reference to specific embodiments. The technical features of the embodiments of the present invention can be combined correspondingly without mutual conflict.
Zoom lens control protocol improvement
In the prior art, the precise focal length control and feedback of the zoom lens cannot be realized through the native control protocol PELCO of the zoom lens, so that the protocol is improved and gear control is added in the embodiment.
The gear control method divides the focal length of the zoom lens into N gears approximately uniformly, the minimum value is recorded as 1 gear, and after the zoom lens is moved to the increasing direction for time delta t, the minimum value is recordedAnd 2, and the like until the maximum value is N gear. And delta T is the time required by adjacent gear shifting, and the time from the maximum value to the minimum value of the focal length of the motorized zoom lens (and conversely, the time is still consistent) is recorded as T, then
And establishing a lens gear-visual angle comparison table.
The external hardware module is schematically connected as shown in fig. 1, and is located between the camera tracking host and the zoom lens. The camera shooting tracking host sends a gear set value to the external hardware module through a user-defined protocol, the external hardware module generates a focal length moving instruction to control the zoom lens by comparing with the current gear, and the current gear is periodically fed back to the camera shooting tracking host.
Based on the PELCO-D protocol, a gear transmission/feedback command format is designed, as shown in Table 1, wherein byte 1 is a synchronization byte, byte 2 is a device number, byte 4 is information category information, byte 6 is gear information, and byte 7 is a check value.
TABLE 1 Camera tracking host gear position transmission/feedback command format
Command
|
Byte1
|
Byte2
|
Byte3
|
Byte4
|
Byte5
|
Byte6
|
Byte7
|
Gear setting
|
0xFF
|
Device numbering
|
0x00
|
0x4f
|
0x00
|
Gear position
|
Check Sum
|
Gear pass-back
|
0xFF
|
Device numbering
|
0x00
|
0x5d
|
0x00
|
Gear position
|
Check Sum |
The internal logic of the external hardware module is shown in fig. 2, and the main part is serial port interrupt and timer interrupt. And the serial port interrupt receives a command from the camera tracking host, and the set gear n2 is updated after verification. Triggering once every delta t time by timed interruption, judging the current focal length control direction Dir after triggering, wherein a positive number indicates increasing, a negative number indicates decreasing, and 0 indicates stopping; if the value is not 0, the action is represented to have been executed for a delta t period, and corresponding addition and subtraction operations need to be carried out on the current state n 1; calculating a gear potential difference delta n which is n2-n1, wherein the positive delta n represents that the focal length needs to be increased, the negative delta n represents that the focal length needs to be decreased, and 0 represents that the focal length value is just right; the comprehensive judgment of the Δ n and the Dir has 9 cases, and the classified cases have 5 cases:
a) delta n is greater than 0, Dir is less than or equal to 0, the current focal length control direction is inconsistent with the gear change requirement, the gear requirement is increased, and an 'increase' instruction is sent;
b) delta n is less than 0, Dir is more than or equal to 0, the current focal length control direction is inconsistent with the gear change requirement, the gear requirement is reduced, and a reduction command is sent;
c) Δ n is 0, Dir! When the current gear is consistent with the set gear, and the focal length control direction is not stopped, a 'stop' instruction is sent;
d) delta n x Dir is more than 0, the current focal length control direction is consistent with the gear change requirement, the current change is kept, and no command is sent;
e) when Δ n is Dir 0, the focus control is finished and no command is sent.
And changing the current focal length control direction according to the corresponding value, and simultaneously returning the current gear value to the camera monitoring host, wherein the returning format is shown in a 'gear return' column in table 1.
Second, calculating and correcting target ratio
The camera imaging geometry model is shown in fig. 3, where the camera horizontal view angle is θ, the surveillance distance is L, the target diameter is D, and the surveillance range diameter is D. For convenience, the current value of a parameter is indexed by 1, e.g., θ1And D1While the parameter set point index is 2, e.g. θ2And D2。
The resolution of the acquired image is recorded as [ I ]h,Iv](h is a horizontal axis, v is a vertical axis). The target pixel coordinate value is [ [ L ]h,Lv],[Rh,Rv]]Wherein the former is the coordinate value of the pixel at the upper left corner of the target calibration frame, and the latter is the value of the lower right corner.
The geometric relationship is described as shown in equation (2.1):
let the ratio of the target in the image be P, and similarly, let the current value of the target ratio be P1The set value is set to P2,P1And P2As shown in equation (2.2):
by eliminating the monitoring distance L and the monitoring range diameter D in the formula (2.1) and the formula (2.2), the formula (2-3) can be obtained:
wherein the target ratio current value P1As shown in (2.4):
thus, according to the current value P of the target ratio1The current value theta of the horizontal visual angle of the camera is the target ratio set value P2Converting into a set value theta of horizontal visual angle of the camera2And then, the visual angle control is realized according to the improved control protocol of the motorized zoom lens, so that the target ratio is proper. Target ratio set point P2The effect is better when the concentration is set to be 8-13%.
Third, target offset calculation and correction
The resolution of the acquired image is recorded as [ I ]h,Iv](h is a horizontal axis, v is a vertical axis). The target pixel coordinate value is [ [ L ]h,Lv],[Rh,Rv]]Wherein the former is the coordinate value of the pixel at the upper left corner of the target calibration frame, and the latter is the value of the lower right corner. The imaging visual angle of the camera is [ theta ]h,θv]。
Target center coordinate [ C ]h,Cv]As shown in equation (3.1):
the image center coordinates are
The target pixel shift amount is the difference between the target center and the image center coordinate
Then, through the geometric relation, the target angle offset [ O ] can be deduced
h,O
v]As shown in equation (3.2):
θvcan be expressed as formula (3.3):
let theta equal to thetahFormula (3.4) can be simplified from formula (3.1) to formula (3.3):
rotation angle of the rotary head, i.e. target angle offset [ O ]h,Ov]The parameter involved includes the image resolution [ I ] as shown in equation (3.4)h,Iv]Target pixel coordinate value [ [ L ]h,Lv],[Rh,Rv]]And a camera horizontal imaging view angle theta. The current rotating cradle head often supports angle accurate control, so the current rotating cradle head can be directly connected with a camera tracking host or forwarded through an external hardware module.
The technical scheme of the invention is used for tracking and controlling the actual unmanned aerial vehicle, and the effect is shown in figure 4.
The method comprises the steps of returning the target to the center of the picture and enabling the proportion of the target in the picture to reach the set proportion, wherein the execution sequence between the two steps is not required. In the embodiment shown in fig. 4, the step of returning the object to the center of the screen is performed first. In fig. 4, lines a and b are visible and infrared tracking for a four-axis drone, and lines c and d are visible and infrared tracking for a six-axis drone. The 1 st column completes the identification of the unmanned aerial vehicle, calibrates the unmanned aerial vehicle and acquires the pixel coordinates of the unmanned aerial vehicle; column 2, completing the matching control of the rotating pan-tilt, and returning the target to the center of the picture; column 3 completes zoom camera control to make the ratio of the target in the frame reach the set ratio.
The effect graph shows that the invention can realize the quantitative stepping control and the periodic feedback of the zoom value of the zoom lens and the visual angle value of the camera by improving the native PELCO control protocol, can realize the accurate and stable control of the camera monitoring equipment, and can ensure that the visual angle of the equipment is self-matched with the target size and the visual angle direction is self-matched with the target movement amount.
The above-mentioned embodiments only express several embodiments of the present invention, and the description thereof is more specific and detailed, but not construed as limiting the scope of the present invention. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the inventive concept, which falls within the scope of the present invention. Therefore, the protection scope of the present patent shall be subject to the appended claims.