Camera control method and device based on virtual rocker, equipment and storage medium
Through the sliding operation and offset correction technology of the virtual rocker head, the upper limit of the motion amplitude of the virtual rocker's control operation on the camera gimbal is solved, and more flexible and efficient camera control is achieved.
Patent Information
- Application Number
- CN202310583066.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-22
- Publication Date
- 2024-11-22
AI Technical Summary
In the prior art, there is an upper limit on the control operation of the virtual rocker on the camera gimbal, and in some scenarios, combined operations are required to complete the established operation target.
By receiving the sliding operation of the virtual rocker head, confirm the real-time offset and generate control parameters, and correct it based on the relationship between the real-time offset and the virtual base to ensure that the display position of the virtual rocker head is within the range of the virtual base, thereby achieving more Large operating range and more flexible camera control.
The upper limit of motion amplitude of the virtual rocker controls the camera gimbal control operation is eliminated, and more established operating goals can be achieved through a single operation, improving operation efficiency and flexibility.
Smart Images

Figure CN119012005A_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present invention relate to the field of interactive control technology, and in particular to a camera control method, device, equipment and storage medium based on a virtual joystick. Background Art
[0002] In the camera usage scenario, there are different acquisition range control strategies according to the different accuracy requirements of the image acquisition object. For example, you can collect images in a fixed area, you can collect images back and forth in a larger area according to a preset movement mode, and you can automatically or manually control the image collection with one or more targets as the center.
[0003] Taking the educational recording and broadcasting scene as an example, it is often necessary to manually operate the camera and adjust the target to achieve close-up image acquisition. Educational recording and broadcasting scenes include recorded classes, live classes, interactive teaching, teaching and research activities, online class inspections and other forms of teaching activities. In educational recording and broadcasting scenes, it is usually necessary to capture close-up images of different roles in the teaching scene according to the specific teaching links, so that people outside the scene can have a more intuitive experience of the teaching scene.
[0004] The existing camera control methods used in educational recording and broadcasting scenarios, for example, use a virtual joystick to control the camera pan / tilt, so as to adjust the acquisition range of the camera when acquiring images. The method of controlling the camera pan / tilt with a virtual joystick can only be performed within a predetermined control area according to the operation interface of the virtual joystick. There is an upper limit on the range of motion for each user's control operation of the camera pan / tilt, and in some scenarios, combined operations are required to complete the predetermined operation goals. Summary of the invention
[0005] The present invention provides a camera control method, device, equipment and storage medium based on a virtual joystick to solve the technical problems in the prior art that each user's control operation on the camera pan / tilt has an upper limit on the movement range, and in some scenarios, combined operations are required to complete the established operation goals.
[0006] In a first aspect, an embodiment of the present invention provides a camera control method based on a virtual joystick, comprising:
[0007] receiving a sliding operation of a virtual joystick head acting on a virtual joystick, wherein the virtual joystick includes a virtual base and a virtual joystick head, the virtual base is displayed in a first range, the virtual joystick head is initially displayed in a second range, and the second range is located within the first range;
[0008] Determining a real-time offset of the virtual joystick head relative to the second range according to the real-time position corresponding to the sliding operation;
[0009] Generate control parameters for the camera according to the real-time offset;
[0010] Based on the real-time offset and the first range, confirm in real time the relative position relationship between the third range and the first range during the sliding operation, the third range being obtained by offsetting the second range according to the real-time offset;
[0011] When the center of the third range is outside the first range, the real-time offset is corrected to obtain a corrected offset;
[0012] The second range is offset according to the correction offset to obtain a fourth range within the first range;
[0013] The virtual joystick head is displayed within the fourth range.
[0014] In a second aspect, an embodiment of the present invention further provides a camera control device based on a virtual joystick, comprising:
[0015] an operation receiving unit, configured to receive a sliding operation of a virtual joystick head acting on a virtual joystick, wherein the virtual joystick includes a virtual base and a virtual joystick head, the virtual base is displayed in a first range, the virtual joystick head is initially displayed in a second range, and the second range is located within the first range;
[0016] An offset confirmation unit, used to confirm a real-time offset of the virtual joystick head relative to the second range according to a real-time position corresponding to the sliding operation;
[0017] A parameter generating unit, used for generating control parameters for the camera according to the real-time offset;
[0018] a relationship confirmation unit, configured to confirm in real time, based on the real-time offset and the first range, the relative position relationship between the third range and the first range during the sliding operation, the third range being obtained by offsetting the second range according to the real-time offset;
[0019] an offset correction unit, configured to correct the real-time offset when the center of the third range is outside the first range to obtain a corrected offset;
[0020] A display range confirmation unit, configured to offset the second range according to the correction offset to obtain a fourth range within the first range;
[0021] The joystick head display unit is used to display the virtual joystick head within the fourth range.
[0022] In a third aspect, an embodiment of the present invention further provides an electronic device, including:
[0023] one or more processors;
[0024] a memory for storing one or more computer programs;
[0025] When one or more computer programs are executed by one or more processors, the electronic device implements the virtual joystick-based camera control method as in the first aspect.
[0026] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the camera control method based on a virtual joystick as in the first aspect.
[0027] In the above-mentioned camera control method, device, electronic device and storage medium based on virtual joystick, by receiving a sliding operation of a virtual joystick head acting on the virtual joystick, the virtual joystick includes a virtual base and a virtual joystick head, the virtual base is displayed in a first range, the virtual joystick head is initially displayed in a second range, and the second range is located within the first range; the real-time offset of the virtual joystick head relative to the second range is confirmed according to the real-time position corresponding to the sliding operation; the control parameters for the camera are generated according to the real-time offset; based on the real-time offset and the first range, the relative position relationship of the third range with the first range during the sliding operation is confirmed in real time, and the third range is obtained by offsetting the second range according to the real-time offset; when the center of the third range is outside the first range, the real-time offset is corrected to obtain a corrected offset; the second range is offset according to the corrected offset to obtain a fourth range located within the first range; and the virtual joystick head is displayed within the fourth range. When the camera is controlled by a virtual joystick, a control parameter is generated corresponding to the real-time offset generated by the sliding operation based on the initial display, and based on the relationship between the real-time offset and the virtual base, when the sliding operation exceeds the display range of the virtual base, the real-time offset is corrected to obtain a corrected offset, and the display position of the virtual joystick head is controlled within the display range of the virtual base. This makes it possible to maintain the established display area of the virtual joystick while controlling the camera according to the actual sliding operation, eliminating the upper limit of the movement range of the control operation of the camera gimbal based on the virtual joystick, and completing more established operation goals through a single operation. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] Figure 1 A method flow chart of a camera control method based on a virtual joystick provided in an embodiment of the present invention.
[0029] Figure 2 Schematic diagram of several changes in controlling a camera in an embodiment of the present invention.
[0030] Figure 3 It is a schematic diagram of a sliding operation on a virtual joystick according to an embodiment of the present invention.
[0031] Figure 4 A schematic structural diagram of a camera control device based on a virtual joystick provided in an embodiment of the present invention.
[0032] Figure 5 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0033] The present invention will be further described in detail below in conjunction with the accompanying drawings and embodiments. It is to be understood that the specific embodiments described herein are used to explain the present invention, rather than to limit the present invention. It should also be noted that, for ease of description, only the parts related to the present invention, rather than all structures, are shown in the accompanying drawings.
[0034] It should be noted that the present application specification does not enumerate all optional implementation modes. After reading the present application specification, those skilled in the art should be able to understand that as long as the technical features do not contradict each other, any combination of the technical features can constitute an optional implementation mode.
[0035] When using a camera for image acquisition (such as video acquisition, picture acquisition), the direction of the camera lens is usually adjusted due to the scene requirements. The camera lens is usually installed on a pan / tilt, which is a supporting device for installing and fixing the camera. It is divided into fixed and electric pan / tilt. Fixed pan / tilt is suitable for situations where the monitoring range is not large. After the camera is installed on the fixed pan / tilt, the horizontal and pitch angles of the camera can be adjusted. After reaching the best working posture, just lock the adjustment mechanism. That is, the camera installed on the fixed pan / tilt can only adjust the lens direction before actual use. Electric pan / tilt is suitable for flexible image acquisition over a large range, and it can expand the image acquisition range of the camera. The posture adjustment of the electric pan / tilt can drive the posture adjustment of the camera. The posture adjustment of the electric pan / tilt is realized by two actuator motors. The motor receives the signal from the controller to accurately operate and position. Under the action of the control signal, the camera on the pan / tilt can automatically perform scanning image acquisition over a large range, and can also adjust the lens direction under human control for image acquisition. In camera products based on electric pan / tilt, it is usually regarded as a whole. The adjustment control of the camera lens direction is actually the posture adjustment control of the electric pan / tilt.
[0036] Among the existing methods for controlling the direction of the camera lens, there is control achieved through a virtual joystick. Specifically, the camera is connected to a host computer (such as a personal computer, a dedicated control tablet, etc.), and a virtual joystick is displayed on the host computer. The virtual joystick corresponds to the physical joystick design, and when displayed on the host computer, it includes a virtual base and a virtual joystick head. According to the sliding operation detected by the virtual joystick head, control parameters with reference to the direction of the virtual base can be obtained. In the implementation process, the existing virtual joystick limits the operation to the range of the virtual base. The part that exceeds the virtual base during the sliding operation cannot generate corresponding control parameters. The movement range of the camera gimbal control operation is limited to the range of the virtual base. For lens direction adjustments with a larger amplitude, multiple operations on the virtual joystick are required to complete the established operation target. Expanding the range of the virtual base by expanding the display size of the virtual base may affect the display of other content in the host computer.
[0037] In response to the above technical problems, this solution proposes a camera control method based on a virtual joystick, which generates control parameters corresponding to the real-time offset generated by the sliding operation based on the initial display, and based on the relationship between the real-time offset and the virtual base, when the sliding operation exceeds the display range of the virtual base, the real-time offset is corrected to obtain a corrected offset, and the display position of the virtual joystick head is controlled within the display range of the virtual base. This makes it possible to maintain the established display area of the virtual joystick while controlling the camera according to the actual sliding operation, eliminating the upper limit of the movement amplitude of the control operation of the camera gimbal based on the virtual joystick, and more established operation goals can be completed through a single operation.
[0038] The following is a detailed description of the various embodiments of the present invention.
[0039] Figure 1 A method flow chart of a camera control method based on a virtual joystick provided by an embodiment of the present invention, wherein the camera control method based on a virtual joystick is implemented by an electronic device. Figure 1 The camera control method based on the virtual joystick includes steps S110 to S170:
[0040] Step S110: receiving a sliding operation of a virtual joystick head acting on a virtual joystick, wherein the virtual joystick includes a virtual base and a virtual joystick head, the virtual base is displayed in a first range, the virtual joystick head is initially displayed in a second range, and the second range is located within the first range.
[0041] like Figure 2As shown, the camera lens is currently facing a person in the center, and the lens direction needs to be adjusted to face the clock in the upper right corner. At the interaction level, for example, the user can achieve this by sliding upward and then rightward (i.e., the operation shown in P1), by sliding rightward and then upward (i.e., the operation shown in P2), or by directly sliding diagonally (i.e., the operation shown in P3).
[0042] The above operations at the interactive level are performed as follows Figure 3 The virtual joystick is implemented as shown. The virtual joystick mainly includes a virtual base 11 and a virtual joystick head 12. A direction mark 13 may be further displayed in the virtual base 11 to indicate the adjustment direction to the user. It may also be further used as an adjustment control, and fine-tuning may be achieved by clicking. An optional implementation of the virtual joystick is that the virtual base 11 and the virtual joystick head 12 are both circular, and the virtual joystick head 12 coincides with the center of the virtual base 11 when initially displayed. In an embodiment of the present invention, the main elements in the virtual joystick are defined as the virtual base 11 and the virtual joystick head 12, and the positions corresponding to the elements in different states are defined as ranges. For example, the virtual base 11 does not change position during operation, and its corresponding position is always the first range during operation; the virtual joystick head 12 is generally located at the center of the virtual base 11 when it is just displayed, and is defined as the second range at this time. According to the general display relationship between the virtual joystick head 12 and the virtual base 11, the second range is within the first range.
[0043] The operation on the virtual joystick targeted by the embodiment of the present invention is mainly the sliding operation starting from the virtual joystick head. The sliding operation is a continuous operation. When the sliding operation continues, the touch position data used to characterize the contact position will be continuously generated accordingly. It is also necessary to perform the relevant data processing process in this solution on the touch position data in real time, that is, to process the position data during the sliding operation in real time. The result of the real-time processing is the continuous generation of control parameters and the display position of the virtual joystick head.
[0044] Step S120: confirming the real-time offset of the virtual joystick head relative to the second range according to the real-time position corresponding to the sliding operation.
[0045] The real-time offset is the coordinate change of the real-time position confirmed by the real-time touch position data of the sliding operation relative to the position at the start of the sliding operation. In the interface displayed by the virtual joystick, the position is described by the coordinate system. The coordinate system has directionality, and the coordinate change has positive and negative properties. For example Figure 3 In the sliding operation shown, the starting point is located at the center of the virtual base 11, and the real-time position at a certain moment is the touch point 14. In the coordinate system where the virtual joystick is located, rightward and upward are positive directions, so the real-time offset corresponding to the touch point 14 is negative.
[0046] Step S130: Generate control parameters for the camera according to the real-time offset.
[0047] According to the embodiment, the offset generates control parameters for the camera, mainly generating the moving angle and the moving angular velocity, wherein the moving angular velocity can be positively correlated with the duration of the sliding operation, that is, the longer the user's operation time, the greater the user's target adjustment range can be considered, and a faster moving angular velocity can be assigned at this time, thereby improving the control efficiency. The positive correlation method can be accelerated in time periods, for example, the moving angular velocity is accelerated once each time the operation duration exceeds a certain threshold. While improving the control efficiency, in order to ensure the stability, safety and accuracy of the camera operation, the moving angular velocity is preset with a maximum value, that is, the upper limit of movement is set to avoid camera overload and missing the user's acquisition target.
[0048] When the real-time position of the sliding operation is compared with the coordinates of the center of the virtual base, the horizontal and vertical distances of the real-time position relative to the center of the virtual base can be calculated, and then the azimuth angle of the real-time position relative to the center of the virtual base can be calculated by inverse trigonometric functions.
[0049] Specifically, the azimuth angle of the real-time position relative to the virtual base can be calculated using the following formula:
[0050]
[0051] Among them, xtouch and ytouch are the coordinates of the real-time position, xcenter and ycenter are the center coordinates of the virtual base, and θ represents the angle of the real-time position relative to the virtual base.
[0052] If the center coordinates of the virtual base are (0,0) and the coordinates of the real-time position are (-100,100), then the angle of the real-time position relative to the center of the virtual base can be calculated by the following steps:
[0053] 1. Calculate the horizontal and vertical distances of the real-time position relative to the center of the virtual base in the coordinate system:
[0054] dx=xtouch-xcenter=-100-0=-100
[0055] dy=ytouch-ycenter=100-0=100
[0056] 2. Calculate the angle of the touch point on the virtual joystick disc:
[0057] Because the real-time position is in the second quadrant, its x-coordinate is negative, and we need to add π to the result to measure the correct angle:
[0058]
[0059] Therefore, the angle of the real-time position in the rectangular coordinate system of the plane where the virtual base is located is 225 degrees.
[0060] After the control parameters are generated, it is also necessary to generate command data corresponding to the preset command transmission protocol in real time according to the control parameters, and send it to the corresponding camera to adjust the direction of the camera lens. There are multiple command transmission protocols in the camera, such as VISCA, LG, SAMSUNG, CNB and HITACHI, etc. The control parameters of the cameras under different protocols may be different. For example, VISCA sends command data, and onvif sends angle offset percentage. In the embodiment of the present invention, the interface of the camera's pan / tilt can be further layered and compatible.
[0061] That is, a conversion layer and a protocol delivery layer can be set, and control parameters (i.e., specific adjustment angles) are input into the conversion layer and converted into parameter forms that can be used by various protocols, and corresponding instruction data are generated. For example, the onvif protocol generates a soapxml message.
[0062] The following describes the specific process of generating command data. There are two types of movement for the pan / tilt movement in each camera control protocol, absolute position movement and relative position movement. The corresponding keywords in VISCA and onvif are RelativePosition and ContinuousMove respectively. Absolute position movement refers to moving to the specified position according to the input parameters. Relative position movement refers to moving in that direction in proportion to the input parameters. An example of an exemplary movement method implemented with a virtual joystick is relative position movement.
[0063] Taking the instruction data based on relative position movement in VISCA as an example, the structure of the command code for relative position movement in VISCA is 81 01 06 03 VV WW 0Y 0Y 0Y 0Y 0Z 0Z 0Z 0Z FF, in this command code, 81 is the starting byte of the command, indicating that the address of the pan / tilt controller is 1; 01 is the target byte of the command, indicating that the address of the camera is 1; 06: this is the command type byte, indicating that this is a relative angle movement command; 03 is the data length byte, indicating that there are 3 data bytes next; VV is the relative movement speed of the vertical angle, ranging from 00-18 (hexadecimal); WW is the relative movement speed of the horizontal angle, ranging from 00-18 (hexadecimal); 0Y, 0Y, 0Y, 0Y is 4 bytes, specifying 4-bit relative angle movement, with vertical angle priority (e.g., the first byte refers to the relative rotation of up and down movement); 0Z, 0Z, 0Z, 0Z is 4 bytes, specifying 4-bit relative angle movement, with horizontal angle priority (e.g., the first byte refers to the relative rotation of left and right movement); FF is the end byte, indicating the end of the command.
[0064] According to the command code format in the VISCA protocol, the relative rotation angles in the vertical and horizontal directions need to be converted into hexadecimal data and stored in the four bytes of 0Y and 0Z. The conversion method is shown below with a specific angle example:
[0065] 20 degrees in the vertical direction can be converted into hexadecimal data by the following formula: 20 degrees ÷ 0.0625 degrees / step = 320 steps ≈ 0140 (hexadecimal). Therefore, storing 0140 in the first two bytes of 0Y (high bit first) indicates a relative rotation of 20 degrees in the vertical direction.
[0066] 30 degrees in the horizontal direction can be converted into a hexadecimal number by the following formula: 30 degrees ÷ 0.0625 degrees / step = 480 steps ≈ 01E0 (hexadecimal). Therefore, storing 01E0 in the first two bytes of 0Z (high bit first) indicates a relative rotation of 30 degrees in the horizontal direction.
[0067] Set the moving speed to the maximum value, then the command code is:
[0068] 81 01 06 03FF FF 01 40 01 40 01E0 01E0 FF
[0069] Among them, 01 40 means 20 degrees in the vertical direction, 01E0 means 30 degrees in the horizontal direction, and FF means that the moving speed in both the vertical and horizontal directions is the maximum value.
[0070] In the VISCA protocol, cameras and pan / tilt heads use stepper motors to control the rotation angle. Each step of the stepper motor will move the device to a specific position. In order to accurately control the rotation angle of the device, a standard step angle needs to be determined. The VISCA protocol stipulates that the step angle is 0.0625 degrees.
[0071] Take the implementation of command data based on relative position movement in the onvif protocol as an example. The interface for relative movement in onvif is ContinuousMove, but the Velocity parameter of this interface transmits the moving speed. At this time, the parameter can be converted by mapping the angle to the speed. In some specific cases, this method can be used to map the angle to the speed. However, it should be noted that this method is only applicable to certain specific scenarios, and not all cameras can support this method. In actual use, many cameras may use different mapping relationships between speed and angle, depending on the specific implementation of the device. Therefore, the best way is to check the camera's documentation or contact the device manufacturer to determine the correct mapping relationship between speed and angle. In addition, it should be noted that even if the correct mapping relationship between speed and angle is known, the camera's motion limitations, such as the camera's maximum speed and acceleration parameters, need to be considered. If the set speed exceeds the camera's limit, the camera may stop moving or fail to reach the target position. Therefore, in order to ensure that the camera can work properly and obtain the best results, the best way is to debug and optimize according to the actual situation of the camera. For example, if you want to move in the 320-degree direction (the second quadrant), if you use the angle mapping speed method, the Velocity parameters should be confirmed in the following way:
[0072] 1. Calculate the offset
[0073] Offset angle = target angle - current angle
[0074] Offset angle = 360 degrees - 320 degrees = 40 degrees
[0075] 2. Calculate the angle mapping speed value
[0076] Pan speed = tan(α)
[0077] Tilt speed = tan(β)
[0078] tan(40)≈0.839
[0079] So the Velocity parameter is
[0080] x=0.83,y=0.83
[0081] Step S140: Based on the real-time offset and the first range, the relative position relationship between the third range and the first range during the sliding operation is confirmed in real time, and the third range is obtained by offsetting the second range according to the real-time offset.
[0082] In the design of the virtual joystick, the virtual base and the virtual joystick head generally adopt symmetrical graphics, so the relative position relationship can be confirmed based on the center, circumscribed circle, etc., and the virtual base and the virtual joystick head are designed as circles as a reference. When confirming the relative position relationship, firstly, based on the real-time offset, the center distance between the center of the third range and the center of the first range is confirmed in real time; then, based on the center distance, the relative position relationship between the third range and the first range during the sliding operation is confirmed in real time. In the embodiment of the present invention, the third range is not necessarily the range where the virtual joystick head is actually displayed, which is determined by the real-time position of the sliding operation, that is, if it can be confirmed that the third range is within the first range based on the real-time position, the virtual joystick head is directly displayed within the third range, and the virtual joystick head as a whole presents an interactive effect of completely following the sliding operation to move and display.
[0083] Step S150: When the center of the third range is outside the first range, the real-time offset is corrected to obtain a corrected offset.
[0084] When the center of the third range is outside the first range, for example, when the virtual base and the virtual joystick head are both circular, when the center distance between the center of the third range and the center of the virtual joystick head is greater than the radius of the first range, it is confirmed that the center of the third range is outside the first range. If the virtual joystick head is displayed directly within the third range, it cannot be fully displayed within the first range. The display of the virtual joystick head is not constrained by the first range, and the interactive experience is poor. At this time, the real-time offset needs to be corrected to obtain the corrected offset. The specific correction process is based on the distance corresponding to the real-time offset and the size of the first range. Specifically, when the center of the third range is outside the first range, the correction coefficient is confirmed based on the difference between the size parameters of the first range and the size parameters of the first range, and the ratio of the offset distance corresponding to the real-time offset; the correction coefficient is respectively multiplied with the components of the real-time offset to obtain the corrected offset.
[0085] Step S160: offset the second range according to the correction offset to obtain a fourth range within the first range.
[0086] The specific processing process in step S140-step S160 is as follows: Figure 3 The circular virtual base and the circular virtual joystick head are used as examples for illustration. The real-time offset includes the horizontal offset component and the vertical offset component of the virtual joystick head relative to the virtual base. The values of these two components will change as the user drags the virtual joystick head, and ultimately determine the real position of the virtual joystick head.
[0087] offsetX=pointX-(baseRadius-stickRadius);
[0088] offsetY=pointY-(baseRadius-stickRadius)
[0089] baseRadius represents the radius of the virtual base, stickRadius represents the radius of the virtual joystick head, pointX and pointY represent the real-time position of the sliding operation, and are generally also used as the position of the center of the virtual joystick head.
[0090] The length of the real-time offset of the center of the virtual joystick head relative to the center of the base is calculated to determine whether it exceeds the first range.
[0091]
[0092] OffsetLength represents the distance between the center of the virtual joystick head and the center of the virtual base, and determines whether the distance between the center of the virtual joystick head and the center of the virtual base exceeds the radius of the virtual base. If it exceeds the radius, the real-time offset correction needs to be limited to the base range, so that the position of the virtual joystick head does not exceed the range of the virtual base, and the boundary of the virtual joystick head is kept in contact with the boundary of the virtual base, that is, the two circles are inscribed.
[0093] If it exceeds the base radius, a ratio value is determined to limit the offset within the base range, that is, a correction offset is determined. Specifically, when the real-time offset exceeds the virtual base range, a ratio value is calculated so that the product of the ratio value and the real-time offset is equal to the radius of the virtual base minus the radius of the virtual joystick head, and then the original offset is multiplied by the ratio value ratio to obtain the limited offset.
[0094] ratio=(baseRadius-stickRadius) / offsetLength;
[0095] offsetX*=ratio;
[0096] offsetY*=ratio;
[0097] Calculate the coordinates of the final center of the virtual joystick head. The final center position targetX and targetY are:
[0098] targetX=baseRadius+offsetX
[0099] targetY=baseRadius+offsetY
[0100] Taking specific data as an example, assuming that the virtual base radius is limited to 50, the virtual joystick head radius is 10, the center of the virtual base is (50, 50), and the real-time position is (110, 110). While ensuring that the virtual joystick head position does not exceed the base range and the boundary of the virtual joystick head is in contact with the boundary of the virtual base, find the final position of the center of the virtual joystick head.
[0101] 1. Calculate the horizontal and vertical offsets of the center of the virtual joystick head relative to the center of the virtual base.
[0102] offsetX=110-(50-10)=70
[0103] offsetY=110-(50-10)=70
[0104] At this time, offsetX and offsetY are 70
[0105] 2. Calculate the length of the real-time offset of the center of the virtual joystick head relative to the center of the virtual base.
[0106]
[0107] 3. Since 98.99>50, the length of the real-time offset of the center of the virtual joystick head relative to the center of the virtual base is greater than the radius of the virtual base, so it is necessary to limit the offset, that is, to obtain the correction offset.
[0108] ratio=(50-10) / 98.99≈0.404
[0109] offsetX*=0.404=28.28
[0110] offsetY*=0.404=28.28
[0111] 4. Calculate the final coordinates of the center of the virtual joystick head.
[0112] targetX = 50 + 28.28 = 78.28
[0113] targetY=50+28.28=78.28
[0114] Step S170: Display the virtual joystick head within the fourth range.
[0115] The virtual joystick head is displayed within the fourth range as a response to the sliding operation. Based on the fourth range confirmed by the process described above, it can be ensured that the virtual joystick head is displayed within the first range corresponding to the virtual base. It should be understood that each time the fourth range is confirmed according to the new real-time position, the virtual joystick head in the previously confirmed fourth range stops being displayed, thereby achieving the effect that the virtual joystick head as a whole is constrained to be displayed within the first range in response to the sliding operation.
[0116] In the above method, by receiving a sliding operation of a virtual joystick head acting on a virtual joystick, the virtual joystick includes a virtual base and a virtual joystick head, the virtual base is displayed in a first range, the virtual joystick head is initially displayed in a second range, and the second range is located within the first range; the real-time offset of the virtual joystick head relative to the second range is confirmed according to the real-time position corresponding to the sliding operation; the control parameters for the camera are generated according to the real-time offset; based on the real-time offset and the first range, the relative position relationship of the third range with the first range during the sliding operation is confirmed in real time, and the third range is obtained by offsetting the second range according to the real-time offset; when the center of the third range is outside the first range, the real-time offset is corrected to obtain a corrected offset; the second range is offset according to the corrected offset to obtain a fourth range located within the first range; and the virtual joystick head is displayed within the fourth range. When the camera is controlled by a virtual joystick, a control parameter is generated corresponding to the real-time offset generated by the sliding operation based on the initial display, and based on the relationship between the real-time offset and the virtual base, when the sliding operation exceeds the display range of the virtual base, the real-time offset is corrected to obtain a corrected offset, and the display position of the virtual joystick head is controlled within the display range of the virtual base. This makes it possible to maintain the established display area of the virtual joystick while controlling the camera according to the actual sliding operation, eliminating the upper limit of the movement range of the control operation of the camera gimbal based on the virtual joystick, and completing more established operation goals through a single operation.
[0117] Figure 4 A schematic diagram of the structure of a camera control device based on a virtual joystick provided by an embodiment of the present invention. Figure 4 The virtual joystick-based camera control device includes an operation receiving unit 210, an offset confirmation unit 220, a parameter generation unit 230, a relationship confirmation unit 240, an offset correction unit 250, a display range confirmation unit 260 and a joystick head display unit 270.
[0118] Among them, the operation receiving unit 210 is used to receive a sliding operation of a virtual joystick head acting on a virtual joystick, the virtual joystick includes a virtual base and a virtual joystick head, the virtual base is displayed in a first range, the virtual joystick head is initially displayed in a second range, and the second range is located within the first range; the offset confirmation unit 220 is used to confirm the real-time offset of the virtual joystick head relative to the second range according to the real-time position corresponding to the sliding operation; the parameter generation unit 230 is used to generate control parameters for the camera according to the real-time offset; the relationship confirmation unit 240 is used to confirm in real time the relative position relationship between the third range and the first range during the sliding operation based on the real-time offset and the first range, and the third range is obtained by offsetting the second range according to the real-time offset; the offset correction unit 250 is used to correct the real-time offset when the center of the third range is outside the first range to obtain a corrected offset; the display range confirmation unit 260 is used to offset the second range according to the corrected offset to obtain a fourth range located within the first range; the joystick head display unit 270 is used to display the virtual joystick head within the fourth range.
[0119] Based on the above embodiment, the offset correction unit 250 includes:
[0120] a coefficient confirmation module, configured to confirm a correction coefficient according to a ratio of a difference between a size parameter of the first range and a size parameter of the second range to an offset distance corresponding to the real-time offset when the center of the third range is outside the first range;
[0121] The component confirmation module is used to respectively multiply the correction coefficient and the components of the real-time offset to obtain a correction offset.
[0122] Based on the above embodiment, the virtual base and the virtual joystick head are both circular, and the virtual joystick head coincides with the center of the virtual base when initially displayed.
[0123] Based on the above embodiment, the relationship confirmation unit 240 includes:
[0124] A distance confirmation module, configured to confirm in real time the distance between the center of the third range and the center of the first range based on the real-time offset;
[0125] The distance comparison module is used to confirm in real time the relative position relationship between the third range and the first range during the sliding operation according to the circle center distance.
[0126] Based on the above embodiment, the distance comparison module includes:
[0127] The first confirmation submodule is used to confirm that the center of the third range is outside the first range when the center distance is greater than the radius of the first range.
[0128] Based on the above embodiment, the camera control device further includes:
[0129] The parameter encoding unit is used to generate command data corresponding to a preset command transmission protocol in real time according to the control parameters, and send the command data to the corresponding camera to adjust the direction of the camera lens.
[0130] Based on the above embodiment, the control parameters include a moving angle and a moving angular velocity.
[0131] Based on the above embodiment, the moving angular velocity is positively correlated with the duration of the sliding operation.
[0132] Based on the above embodiment, the moving angular velocity is preset with a maximum value.
[0133] The virtual joystick-based camera control device provided in an embodiment of the present invention is included in an electronic device and can be used to execute any virtual joystick-based camera control method provided in the above embodiments, and has corresponding functions and beneficial effects.
[0134] It is worth noting that in the above-mentioned embodiment of the virtual joystick-based camera control device, the various units and modules included are only divided according to functional logic, but are not limited to the above-mentioned division, as long as the corresponding functions can be achieved; in addition, the specific names of the functional units are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of the present invention.
[0135] Figure 5 FIG. 1 is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. Figure 5 As shown, the electronic device includes a processor 310 and a memory 320, and may also include an input device 330, an output device 340 and a communication device 350; the number of the processor 310 in the electronic device may be one or more, Figure 5 A processor 310 is taken as an example; the processor 310, the memory 320, the input device 330, the output device 340 and the communication device 350 in the electronic device can be connected via a bus or other means. Figure 5 The example of connecting through bus is taken in the following.
[0136] The memory 320, as a computer-readable storage medium, can be used to store software programs, computer executable programs and modules, such as program instructions / modules corresponding to the camera control method based on the virtual joystick in the embodiment of the present invention. The processor 310 executes various functional applications and data processing of the electronic device by running the software programs, instructions and modules stored in the memory 320, that is, realizes the above-mentioned camera control method based on the virtual joystick.
[0137] The memory 320 may mainly 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 electronic device, etc. In addition, the memory 320 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some instances, the memory 320 may further include a memory remotely arranged relative to the processor 310, and these remote memories may be connected to the electronic 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.
[0138] The input device 330 can be used to receive input digital or character information and generate key signal input related to user settings and function control of the electronic device. The output device 340 can include a display device such as a display screen for displaying power, working mode, virtual joystick, etc.
[0139] An embodiment of the present invention also provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, it is used to perform relevant operations in the virtual joystick-based camera control method provided in any embodiment of the present application, and has corresponding functions and beneficial effects.
[0140] Those skilled in the art should understand that the embodiments of the present application may be provided as methods, systems, or computer program products.
[0141] Therefore, the present application may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present application may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code. The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the functions in the process. Figure 1 A process or multiple processes and / or boxes Figure 1These computer program instructions can also be stored in a computer-readable memory that can guide a computer or other programmable data processing device to work in a specific way, so that the instructions stored in the computer-readable memory produce a product including an instruction device, which implements the functions specified in the process. Figure 1 A process or multiple processes and / or boxes Figure 1 These computer program instructions can also be loaded onto a computer or other programmable data processing device, so that a series of operation steps are executed on the computer or other programmable device to produce a computer-implemented process, so that the instructions executed on the computer or other programmable device provide for implementing the process in the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0142] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory. The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0143] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0144] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0145] Note that the above are only preferred embodiments of the present invention and the technical principles used. Those skilled in the art will understand that the present invention is not limited to the specific embodiments herein, and that various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in more detail through the above embodiments, the present invention is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the present invention, and the scope of the present invention is determined by the scope of the appended claims.
Claims
1. A camera control method based on a virtual joystick, characterized in that: include: receiving a sliding operation of a virtual joystick head acting on a virtual joystick, the virtual joystick comprising a virtual base and a virtual joystick head, the virtual base being displayed in a first range, the virtual joystick head being initially displayed in a second range, and the second range being within the first range; Determining a real-time offset of the virtual joystick head relative to the second range according to the real-time position corresponding to the sliding operation; generating a control parameter for the camera according to the real-time offset; Based on the real-time offset and the first range, confirming in real time the relative positional relationship between a third range and the first range during the sliding operation, the third range being obtained by offsetting the second range according to the real-time offset; When the center of the third range is outside the first range, correcting the real-time offset to obtain a corrected offset; offsetting the second range according to the correction offset to obtain a fourth range within the first range; The virtual joystick head is displayed within the fourth range.
2. The camera control method according to claim 1, characterized in that: When the center of the third range is outside the first range, correcting the real-time offset to obtain a corrected offset comprises: When the center of the third range is outside the first range, determining a correction coefficient according to a ratio of a difference between a size parameter of the first range and a size parameter of the second range to an offset distance corresponding to the real-time offset; The correction coefficient is multiplied by the components of the real-time offset to obtain a correction offset.
3. The camera control method according to claim 1 or 2, characterized in that: The virtual base and the virtual joystick head are both circular, and the virtual joystick head coincides with the center of the virtual base when initially displayed.
4. The camera control method according to claim 3, characterized in that: The step of confirming in real time the relative position relationship between the third range and the first range during the sliding operation based on the real-time offset and the first range includes: Based on the real-time offset, confirm in real time the distance between the center of the third range and the center of the first range; According to the circle center distance, the relative position relationship between the third range and the first range during the sliding operation is confirmed in real time.
5. The camera control method according to claim 4, characterized in that: The step of confirming in real time, based on the circle center distance, the relative position relationship between the third range and the first range during the sliding operation includes: When the circle center distance is greater than the radius of the first range, it is confirmed that the center of the third range is outside the first range.
6. The camera control method according to claim 1 or 2, characterized in that: Also includes: Instruction data corresponding to a preset instruction transmission protocol is generated in real time according to the control parameters, and sent to a corresponding camera to adjust the direction of the camera lens.
7. The camera control method according to claim 1 or 2, characterized in that: The control parameters include a moving angle and a moving angular velocity.
8. The camera control method according to claim 7, characterized in that: The moving angular velocity is positively correlated with the duration of the sliding operation.
9. The camera control method according to claim 8, characterized in that: The moving angular velocity is preset with a maximum value.
10. A camera control device based on a virtual joystick, characterized in that: include: an operation receiving unit, configured to receive a sliding operation of a virtual joystick head acting on a virtual joystick, wherein the virtual joystick includes a virtual base and a virtual joystick head, wherein the virtual base is displayed in a first range, and the virtual joystick head is initially displayed in a second range, and the second range is located within the first range; an offset confirmation unit, configured to confirm a real-time offset of the virtual joystick head relative to the second range according to a real-time position corresponding to the sliding operation; A parameter generating unit, used for generating a control parameter for the camera according to the real-time offset; a relationship confirmation unit, configured to confirm in real time, based on the real-time offset and the first range, a relative position relationship between a third range and the first range during the sliding operation, the third range being obtained by offsetting the second range by the real-time offset; an offset correction unit, configured to correct the real-time offset to obtain a corrected offset when the center of the third range is outside the first range; A display range confirmation unit, configured to offset the second range according to the correction offset to obtain a fourth range within the first range; The joystick head display unit is used to display the virtual joystick head within the fourth range.
11. An electronic device, characterized in that: include: one or more processors; a memory for storing one or more computer programs; When the one or more computer programs are executed by the one or more processors, the electronic device implements the virtual joystick-based camera control method as described in any one of claims 1-9.
12. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the virtual joystick-based camera control method as described in any one of claims 1 to 9 is implemented.
