Camera control method and system based on onvif protocol

The camera is controlled to rotate multiple times and panoramic stitching through the ONVIF protocol. Combined with the user click coordinates to calculate the rotation angle, the problem of real-time camera control complexity and preset position limitation in the prior art is solved, and accurate and simple viewing angle control is achieved.

CN118921557APending Publication Date: 2024-11-08SHENZHEN TIEYUE ELECTRIC CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410560756.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-08
Publication Date
2024-11-08

AI Technical Summary

Technical Problem

In the prior art, the camera needs to set the preset position in advance through the preset position method, but cannot be used in real time, and the number of preset positions is limited; the operation is complicated by controlling the rotation of the camera, and the motion direction needs to be continuously adjusted to reach a specified viewing angle.

Method used

Based on the ONVIF protocol, the camera rotates multiple times in the horizontal direction, and the angle of each rotation is a certain degree. The image after the rotation is completed is obtained for panoramic splicing, detect the user's click position, calculate and issue control commands to achieve accurate rotation.

Benefits of technology

It realizes the generation of panoramic images, and users can accurately control the camera to rotate to a specified viewing angle through pixel coordinates, simplifying the operation process and is suitable for dome cameras that support the ONVIF protocol.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118921557A_ABST
    Figure CN118921557A_ABST
Patent Text Reader

Abstract

The invention discloses a camera control method and system based on an onvif protocol, and the method comprises the steps: controlling a camera to rotate N times in the horizontal direction based on the onvif protocol, enabling the rotation angle of each time to be M degrees, and obtaining N shot pictures after the rotation is completed; n and M are positive integers, and N * M is greater than or equal to 360; performing panoramic stitching operation on the N shot pictures to obtain a panoramic picture; detecting a click operation of a user on the panoramic picture, obtaining coordinate information corresponding to a click position of the user, and calculating a rotation angle of the camera according to the coordinate information; and sending a control instruction to the camera based on an onvif protocol, and controlling the camera to rotate to a corresponding position. According to the embodiment of the invention, the panoramic picture of the specified spherical camera can be generated, a user can accurately control the camera based on the panoramic picture, and the operation is convenient.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of image processing, and in particular to a camera control method and system based on the ONVIF protocol. Background Art

[0002] In the field of video surveillance, the image width of ordinary spherical cameras is limited and a 360-degree panoramic image cannot be seen. If the camera needs to be controlled to rotate to a certain viewing angle, it needs to be constantly controlled to rotate the camera left and right to reach the desired position, which is troublesome to operate.

[0003] Generally, there are two ways to rotate the camera to a specified viewing angle. One is to set the preset position in advance and then call the preset position to rotate to the specified viewing angle. The other way is to control the camera to rotate in different directions to reach the specified viewing angle. The preset position method requires setting the preset position in advance and cannot be used in real time, and the number of preset positions is limited. The method of controlling the rotation of the camera requires constantly adjusting the movement direction of the camera to rotate to the specified viewing angle, which is complicated to operate.

[0004] Therefore the prior art needs further development. Summary of the invention

[0005] In response to the above technical problems, an embodiment of the present invention provides a camera control method and system based on the ONVIF protocol, which can solve the technical problems in the prior art that the preset positions need to be set in advance and cannot be used in real time, and the number of preset positions is limited; and the method of controlling the rotation of the camera requires constantly adjusting the movement direction of the camera to turn to the specified viewing angle, which is complex to operate.

[0006] A first aspect of an embodiment of the present invention provides a camera control method based on the ONVI F protocol, the method comprising:

[0007] Based on the onvif protocol, control the camera to rotate N times in the horizontal direction, each rotation angle is M degrees, and obtain N pictures after the rotation is completed; where N and M are both positive integers, and N*M is greater than or equal to 360;

[0008] Perform a panoramic stitching operation on N captured pictures to obtain a panoramic picture;

[0009] Detecting a click operation of a user on the panoramic image, obtaining coordinate information corresponding to the click position of the user, and calculating the rotation angle of the camera according to the coordinate information;

[0010] Based on the onv if protocol, control instructions are sent to the camera to control the camera to rotate to the corresponding position.

[0011] Optionally, the method of controlling the camera to rotate N times in the horizontal direction based on the ONVI F protocol, with each rotation angle being M degrees, and obtaining N pictures after the rotation is completed, includes:

[0012] Based on the onv if protocol, the camera is controlled to rotate 12 times in the horizontal direction, each rotation angle is 30 degrees, and 12 pictures are obtained after the rotation is completed.

[0013] Optionally, performing a panoramic stitching operation on N photographed pictures to obtain a panoramic picture includes:

[0014] Based on opencv, 12 photos are stitched together to get a panoramic picture.

[0015] Optionally, detecting a click operation of a user on the panoramic picture, obtaining coordinate information corresponding to the click position of the user, and calculating the rotation angle of the camera according to the coordinate information includes:

[0016] Detecting a camera control command from a user, loading and displaying the panoramic image;

[0017] Detecting a click operation of a user on the panoramic image, and obtaining coordinate information corresponding to the click position of the user;

[0018] The rotation angle of the camera is calculated according to the coordinate information.

[0019] Optionally, the sending of a control instruction to the camera based on the ONVIF protocol to control the camera to rotate to a corresponding position includes:

[0020] Generate a control instruction based on the onvif protocol and the rotation angle of the camera, and send the control instruction to the camera;

[0021] The camera is controlled to rotate to a corresponding position based on the control instruction.

[0022] A second aspect of an embodiment of the present invention provides a camera control system based on the ONVIF protocol, the system comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program implements the following steps when executed by the processor:

[0023] Based on the onvif protocol, control the camera to rotate N times in the horizontal direction, each rotation angle is M degrees, and obtain N pictures after the rotation is completed; where N and M are both positive integers, and N*M is greater than or equal to 360;

[0024] Perform a panoramic stitching operation on N captured pictures to obtain a panoramic picture;

[0025] Detecting a click operation of a user on the panoramic image, obtaining coordinate information corresponding to the click position of the user, and calculating the rotation angle of the camera according to the coordinate information;

[0026] Based on the ONVIF protocol, control instructions are sent to the camera to control the camera to rotate to the corresponding position.

[0027] Optionally, when the computer program is executed by the processor, the following steps are implemented:

[0028] Based on the ONVIF protocol, the camera is controlled to rotate 12 times in the horizontal direction, each rotation angle is 30 degrees, and 12 pictures are obtained after the rotation is completed.

[0029] Optionally, when the computer program is executed by the processor, the following steps are further implemented:

[0030] Based on opencv, 12 photos are stitched together to get a panoramic picture.

[0031] Optionally, when the computer program is executed by the processor, the following steps are further implemented:

[0032] Detecting a camera control command from a user, loading and displaying the panoramic image;

[0033] Detecting a click operation of a user on the panoramic image, and obtaining coordinate information corresponding to the click position of the user;

[0034] The rotation angle of the camera is calculated according to the coordinate information.

[0035] A third aspect of an embodiment of the present invention provides a non-volatile computer-readable storage medium, characterized in that the non-volatile computer-readable storage medium stores computer-executable instructions, which, when executed by one or more processors, enable the one or more processors to execute the above-mentioned camera control method based on the ONVIF protocol.

[0036] In the technical solution provided by the embodiment of the present invention, the camera is controlled to rotate N times in the horizontal direction based on the onvif protocol, and the angle of each rotation is M degrees, and N pictures taken after the rotation are obtained; wherein N and M are both positive integers, and satisfy that N*M is greater than or equal to 360; the N pictures are subjected to a panoramic stitching operation to obtain a panoramic picture; the user's click operation on the panoramic picture is detected, the coordinate information corresponding to the user's click position is obtained, and the rotation angle of the camera is calculated according to the coordinate information; a control instruction is issued to the camera based on the onvif protocol to control the camera to rotate to the corresponding position. The embodiment of the present invention can generate a panoramic picture of a specified spherical camera, and the user can accurately control the camera based on the panoramic picture. The method will calculate the rotation angle of the camera according to the pixel coordinates on the picture and rotate it to the specified viewing angle at one time through the onvif protocol, and the method can be universal. As long as the spherical camera that supports the onvif protocol can achieve the function of precise control through this method. BRIEF DESCRIPTION OF THE DRAWINGS

[0037] Figure 1 The figure is a flow chart of a preferred embodiment of a camera control method based on the ONVIF protocol in an embodiment of the present invention;

[0038] Figure 2 The figure is a schematic diagram of the hardware structure of another embodiment of a camera control system based on the ONVIF protocol in an embodiment of the present invention. DETAILED DESCRIPTION

[0039] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only 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.

[0040] The embodiments of the present invention are described in detail below with reference to the accompanying drawings.

[0041] See also Figure 1 , Figure 1 FIG. 1 is a flow chart of an embodiment of a camera control method based on the ONVIF protocol in an embodiment of the present invention. Figure 1 As shown, including:

[0042] Step S100: Based on the onv if protocol, the camera is controlled to rotate N times in the horizontal direction, each rotation angle is M degrees, and N pictures taken after the rotation are completed are obtained; wherein N and M are both positive integers, and N*M is greater than or equal to 360;

[0043] Step S200, performing a panoramic stitching operation on N photographed pictures to obtain a panoramic picture;

[0044] Step S300: Detecting a click operation of a user on the panoramic picture, obtaining coordinate information corresponding to the click position of the user, and calculating the rotation angle of the camera according to the coordinate information;

[0045] Step S400: sending a control instruction to the camera based on the ONVIF protocol to control the camera to rotate to a corresponding position.

[0046] In specific implementation, the embodiment of the present invention controls the camera to rotate N times in the horizontal direction based on the ONVIF protocol, each rotation angle is M degrees, obtains N pictures after the rotation is completed, and then performs a panoramic stitching operation on the N pictures to obtain a panoramic picture. Among them, ONVI F (Open Network Video Interface Forum) is a global open industry forum whose goal is to promote the development and use of global open standards for physical IP-based security product interfaces. ONVI F creates a standard for how IP products in video surveillance and other physical security fields communicate with each other.

[0047] Detect the user's click operation on the panoramic picture, obtain the coordinate information corresponding to the user's click position, and calculate the rotation angle of the camera based on the coordinate information; send a control instruction to the camera based on the ONVIF protocol to control the camera to rotate to the corresponding rotation angle and stay at the corresponding position of the rotation angle, so as to facilitate the user to view the picture of the corresponding perspective.

[0048] The embodiment of the present invention can generate a panoramic picture of a specified spherical camera, and the user can accurately control the camera based on the panoramic picture. The method calculates the rotation angle of the camera according to the pixel coordinates on the picture and rotates it to the specified viewing angle at one time through the ONVIF protocol. The method can be universal. As long as the spherical camera supports the ONVIF protocol, the method can achieve the function of precise control.

[0049] Furthermore, based on the onvif protocol, the camera is controlled to rotate N times in the horizontal direction, each rotation angle is M degrees, and N pictures taken after the rotation are completed are obtained, including:

[0050] Based on the ONVIF protocol, the camera is controlled to rotate 12 times in the horizontal direction, each rotation angle is 30 degrees, and 12 pictures are obtained after the rotation is completed.

[0051] In specific implementation, the camera is controlled to rotate horizontally 12 times through the onvif protocol, each rotation angle is 30 degrees, and a picture of the viewing angle is captured after each rotation. Preferably, the quality of the panoramic image synthesized by rotating 30 degrees each time is the best, and other angles are also acceptable but the quality of the synthesized panoramic image is not so good.

[0052] In other embodiments, if the ONVIF protocol is not used, the stitching of panoramic pictures can also be achieved through the SDK. The SDK method is limited by the fact that the SDK implementation methods of each brand of camera are different and need to be implemented one by one according to the brand, and it cannot be universal; the ONVIF protocol is a global video protocol. The ONVIF specification describes the model, interface, data type and data interaction mode of network video, and reuses some existing standards, such as the WS series standards. It provides the interface of the device management and control part in the form of Web Services, and covers the definitions of XML and WSDL. Each terminal device that supports the ONVIF specification must provide the corresponding Web Service. The data interaction between the server and the client adopts the SOAP protocol, and the audio and video streams are carried out through RTP / RTSP.

[0053] Furthermore, the N photographed pictures are stitched together to obtain a panoramic picture, including:

[0054] Based on opencv, 12 photos are stitched together to get a panoramic picture.

[0055] In the specific implementation, after the scanning is completed, opencv is used to perform panoramic stitching of 12 screenshots to generate a panoramic image. The panoramic stitching process is implemented using the opencv library. You only need to call the interface without implementing it yourself. The principle of stitching panoramic images based on opencv is divided into the following three points: 1. Feature detection and matching: Detect key points in two images and find matching pairs. 2. Estimation of transformation matrix: Estimate the transformation from one image to another based on matching point pairs. 3. Image transformation and fusion: Use the transformation matrix to transform the images, and then fuse them into a panoramic image.

[0056] Among them, OpenCV is a cross-platform computer vision and machine learning software library released under the Apache2.0 license (open source), which can run on Linux, Windows, Android and Mac OS operating systems. It is lightweight and efficient - consisting of a series of C functions and a small number of C++ classes, and providing interfaces for languages ​​such as Python, Ruby, and MATLAB, implementing many common algorithms in image processing and computer vision. OpenCV is written in C++, it has C++, Python, Java and MATLAB interfaces, and supports Windows, Linux, Android and Mac OS. OpenCV mainly tends to real-time vision applications and uses MMX and SSE instructions when available. It now also provides support for C#, Ch, Ruby, and GO.

[0057] Further, detecting a click operation of a user on the panoramic picture, obtaining coordinate information corresponding to the click position of the user, and calculating the rotation angle of the camera according to the coordinate information, including:

[0058] Detecting a camera control command from a user, loading and displaying the panoramic image;

[0059] Detecting a click operation of a user on the panoramic image, and obtaining coordinate information corresponding to the click position of the user;

[0060] The rotation angle of the camera is calculated according to the coordinate information.

[0061] In specific implementation, the user can click at any position of the panoramic image, and the angle of camera rotation is calculated for the coordinates of the click on the panoramic image. With the upper left corner of the panoramic image as the coordinate origin, the mouse clicks on the point on the image to obtain the x and y coordinates relative to the origin. The width and height of the panoramic image are w and h. Because the horizontal and vertical rotation ranges of the camera rotation controlled by the onvif protocol are both (-1,1), the horizontal rotation value of the camera can be calculated as (x / w)x(1-(-1))+(-1), and the vertical rotation value can be calculated as (y / h)x(1-(-1))+(-1), and then the onvif protocol is called to rotate according to the calculated values. Among them, the xy coordinate points do not need to be calculated, but are obtained from the mouse click feedback event. This can be obtained by loading the image through opencv and associating the mouse event, or by other methods, such as the mouse click event of the front-end page, the mouse click event in Microsoft Visual Studio MFC, etc.

[0062] Furthermore, based on the onvif protocol, a control instruction is sent to the camera to control the camera to rotate to a corresponding position, including:

[0063] Generate a control instruction based on the onvif protocol and the rotation angle of the camera, and send the control instruction to the camera;

[0064] The camera is controlled to rotate to a corresponding position based on the control instruction.

[0065] During specific implementation, a control instruction is generated based on the onvif protocol and the rotation angle of the camera, and the camera is controlled to rotate to a corresponding position based on the control instruction.

[0066] From the above method embodiments, it can be seen that the present invention mainly controls the rotation of the camera through the onvif protocol. Whether it is panoramic scanning or the rotation control of the camera through the panoramic picture, the onvif protocol needs to be used to send the rotation command to the camera. The synthesis of the panoramic picture is obtained by splicing the pictures captured during the panoramic scanning process through opencv.

[0067] It should be noted that there is not necessarily a certain order between the above-mentioned steps. A person skilled in the art can understand, based on the description of the embodiments of the present invention, that in different embodiments, the above-mentioned steps may have different execution orders, that is, they may be executed in parallel, may be executed interchangeably, and so on.

[0068] The above describes the camera control method based on the onvif protocol in the embodiment of the present invention. The following describes the camera control system based on the onvif protocol in the embodiment of the present invention. Figure 2 , Figure 2 1 is a schematic diagram of the hardware structure of another embodiment of a camera control system based on the onvif protocol in an embodiment of the present invention. The camera control system based on the onvif protocol is applied to an image device, and the image device is provided with a lens module and a chassis module, such as Figure 2 As shown, the system 10 includes: a processor 101, a memory 102, and a computer program stored in the memory and executable on the processor. When the computer program is executed by the processor 101, the following steps are implemented:

[0069] Based on the onvif protocol, control the camera to rotate N times in the horizontal direction, each rotation angle is M degrees, and obtain N pictures after the rotation is completed; where N and M are both positive integers, and N*M is greater than or equal to 360;

[0070] Perform a panoramic stitching operation on N captured pictures to obtain a panoramic picture;

[0071] Detecting a click operation of a user on the panoramic image, obtaining coordinate information corresponding to the click position of the user, and calculating the rotation angle of the camera according to the coordinate information;

[0072] Based on the ONVIF protocol, control instructions are sent to the camera to control the camera to rotate to the corresponding position.

[0073] The specific implementation steps are the same as those in the method embodiment and will not be repeated here.

[0074] Optionally, when the computer program is executed by the processor 101, the following steps are further implemented:

[0075] Based on the ONVIF protocol, the camera is controlled to rotate 12 times in the horizontal direction, each rotation angle is 30 degrees, and 12 pictures are obtained after the rotation is completed.

[0076] The specific implementation steps are the same as those in the method embodiment and will not be repeated here.

[0077] Optionally, when the computer program is executed by the processor 101, the following steps are further implemented:

[0078] Based on opencv, 12 photos are stitched together to get a panoramic picture.

[0079] The specific implementation steps are the same as those in the method embodiment and will not be repeated here.

[0080] Optionally, when the computer program is executed by the processor 101, the following steps are further implemented:

[0081] Detecting a camera control command from a user, loading and displaying the panoramic image;

[0082] Detecting a click operation of a user on the panoramic image, and obtaining coordinate information corresponding to the click position of the user;

[0083] The rotation angle of the camera is calculated according to the coordinate information.

[0084] The specific implementation steps are the same as those in the method embodiment and will not be repeated here.

[0085] Optionally, when the computer program is executed by the processor 101, the following steps are further implemented:

[0086] Generate a control instruction based on the onvif protocol and the rotation angle of the camera, and send the control instruction to the camera;

[0087] The camera is controlled to rotate to a corresponding position based on the control instruction.

[0088] The specific implementation steps are the same as those in the method embodiment and will not be repeated here.

[0089] An embodiment of the present invention provides a non-volatile computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are executed by one or more processors, for example, to execute the above-described Figure 1 The method comprises steps S100 to S400.

[0090] As an example, the non-volatile storage medium can include a read-only memory (ROM), a programmable ROM (PROM), an electrically programmable ROM (EPROM), an electrically erasable ROM (EEPROM), or a flash memory. Volatile memory can include a random access memory (RAM) as an external cache memory. By way of illustration and not limitation, RAM can be obtained in many forms such as synchronous RAM (SRAM), dynamic RAM, DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), Synchlink DRAM (SLDRAM), and direct Rambus RAM (DRRAM). The disclosed memory components or memories of the operating environment described in the embodiments of the present invention are intended to include one or more of these and / or any other suitable types of memories.

[0091] The above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A camera control method based on the onvif protocol, characterized in that: Methods include: Based on the onvif protocol, control the camera to rotate N times in the horizontal direction, each rotation angle is M degrees, and obtain N pictures after the rotation is completed; where N and M are both positive integers, and N*M is greater than or equal to 360; Perform a panoramic stitching operation on N captured pictures to obtain a panoramic picture; Detecting a click operation of a user on the panoramic image, obtaining coordinate information corresponding to the click position of the user, and calculating the rotation angle of the camera according to the coordinate information; Based on the ONVIF protocol, control instructions are sent to the camera to control the camera to rotate to the corresponding position.

2. The camera control method based on the onvif protocol according to claim 1, characterized in that: The method of controlling the camera to rotate N times in the horizontal direction based on the onvif protocol, with each rotation angle being M degrees, and obtaining N pictures after the rotation is completed, includes: Based on the ONVIF protocol, the camera is controlled to rotate 12 times in the horizontal direction, each rotation angle is 30 degrees, and 12 pictures are obtained after the rotation is completed.

3. The camera control method based on the onvif protocol according to claim 2, characterized in that: The panorama stitching operation is performed on N photographed pictures to obtain a panoramic picture, including: Based on opencv, 12 photos are stitched together to get a panoramic picture.

4. The camera control method based on the onvif protocol according to claim 3, characterized in that: The detecting a click operation of a user on the panoramic picture, obtaining coordinate information corresponding to the click position of the user, and calculating the rotation angle of the camera according to the coordinate information includes: Detecting a camera control command from a user, loading and displaying the panoramic image; Detecting a click operation of a user on the panoramic image, and obtaining coordinate information corresponding to the click position of the user; The rotation angle of the camera is calculated according to the coordinate information.

5. The camera control method based on the onvif protocol according to claim 4, characterized in that: The method of sending a control instruction to the camera based on the ONVIF protocol to control the camera to rotate to a corresponding position includes: Generate a control instruction based on the onvif protocol and the rotation angle of the camera, and send the control instruction to the camera; The camera is controlled to rotate to a corresponding position based on the control instruction.

6. A camera control system based on the onvif protocol, characterized in that: The system comprises: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program implements the following steps when executed by the processor: Based on the onvif protocol, control the camera to rotate N times in the horizontal direction, each rotation angle is M degrees, and obtain N pictures after the rotation is completed; where N and M are both positive integers, and N*M is greater than or equal to 360; Perform a panoramic stitching operation on N captured pictures to obtain a panoramic picture; Detecting a click operation of a user on the panoramic image, obtaining coordinate information corresponding to the click position of the user, and calculating the rotation angle of the camera according to the coordinate information; Based on the ONVIF protocol, control instructions are sent to the camera to control the camera to rotate to the corresponding position.

7. The camera control system based on the onvif protocol according to claim 6, characterized in that: When the computer program is executed by the processor, the following steps are implemented: Based on the ONVIF protocol, the camera is controlled to rotate 12 times in the horizontal direction, each rotation angle is 30 degrees, and 12 pictures are obtained after the rotation is completed.

8. The camera control system based on the onvif protocol according to claim 7, characterized in that: When the computer program is executed by the processor, the following steps are also implemented: Based on opencv, 12 photos are stitched together to get a panoramic picture.

9. The camera control system based on the onvif protocol according to claim 8, characterized in that: When the computer program is executed by the processor, the following steps are also implemented: Detecting a camera control command from a user, loading and displaying the panoramic image; Detecting a click operation of a user on the panoramic image, and obtaining coordinate information corresponding to the click position of the user; The rotation angle of the camera is calculated according to the coordinate information.

10. A non-volatile computer-readable storage medium, characterized in that: The non-volatile computer-readable storage medium stores computer-executable instructions, which, when executed by one or more processors, enable the one or more processors to execute the camera control method based on the ONVIF protocol as described in any one of claims 1-5.