Method and apparatus for storing image data

文档序号:1492818 发布日期:2020-02-04 浏览:5次 中文

阅读说明:本技术 存储图像数据的方法和装置 (Method and apparatus for storing image data ) 是由 周晓超 周文斋 于 2018-07-24 设计创作,主要内容包括:本发明公开了一种存储图像数据的方法和装置,属于网络技术领域。所述方法包括:在向服务器传输拍摄的图像数据的过程中,以第一时长为检测周期,检测与服务器之间的网络连接状态;当检测到网络连接状态为连接失败时,将检测周期调节为第二时长,其中,所述第二时长小于第一时长;当连续预设数目个检测周期检测到网络连接状态为连接失败时,确定与所述服务器之间发生网络连接故障,将缓存器中缓存的图像数据和后续拍摄的图像数据存储到本地的非易失存储器中。采用本发明,可以减小图像数据丢失的可能性。(The invention discloses a method and a device for storing image data, and belongs to the technical field of networks. The method comprises the following steps: in the process of transmitting the shot image data to the server, detecting the network connection state between the server and the server by taking the first duration as a detection period; when the network connection state is detected to be a connection failure, adjusting the detection period to be a second time length, wherein the second time length is less than the first time length; and when the network connection state is detected to be connection failure in a continuous preset number of detection periods, determining that network connection failure occurs between the server and the network, and storing the image data cached in the buffer and the subsequently shot image data into a local nonvolatile memory. By adopting the invention, the possibility of image data loss can be reduced.)

1. A method of storing image data, the method comprising:

in the process of transmitting the shot image data to a server, detecting the network connection state between the server and the server by taking a first duration as a detection period;

when the network connection state is detected to be a connection failure, adjusting a detection period to be a second time length, wherein the second time length is smaller than the first time length;

and when the network connection state is detected to be connection failure in a continuous preset number of detection periods, determining that network connection failure occurs between the server and the network, and storing the image data cached in the buffer and the subsequently shot image data into a local nonvolatile memory.

2. The method of claim 1, wherein the second duration is 1/n of the first duration, and wherein n is a positive integer.

3. The method of claim 1, wherein after adjusting the detection period to the second duration, further comprising:

and when the network connection state is detected to be successful, adjusting the detection period to the first duration.

4. The method of claim 1, further comprising:

and when the network connection state is detected to be the connection failure in the continuous preset number of detection periods, adjusting the detection period to be the first time length.

5. The method of claim 1, further comprising:

and when the network connection state is detected to be successful, transmitting the image data in the nonvolatile memory to the server, and transmitting the subsequently shot image data to the server.

6. The method of claim 5, further comprising:

continuously acquiring key frame data from the shot image data, backing up, and covering the key frame data backed up firstly when the data volume of the backed up key frame data reaches a preset threshold value;

when the network connection state is detected to be connection failure in a continuous preset number of detection periods, copying currently backed-up key frame data into the nonvolatile memory;

and when the network connection state is detected to be successful, transmitting the copied key frame data to the server.

7. The method of claim 1, further comprising:

when any image data is stored in a buffer, adding a first state label to any image data, modifying the first state label of any image data into a second state label when a target storage address of the server is applied to any image data, modifying the second state label of any image data into a third state label when uploading of any image data to the server is started, and modifying the third state label of any image data into a fourth state label when uploading of any image data is finished;

the step of storing the image data cached in the buffer and the image data shot subsequently into a local nonvolatile memory comprises the following steps:

storing the image data of which the state label cached in the buffer is not the fourth state label into a local nonvolatile memory;

in the nonvolatile memory, a state tag of the image data, the state tag of which is the second state tag or the third state tag, is modified to the first state tag.

8. The method of claim 1, further comprising:

and when the occupation notice of the target storage address sent by the server is received under the condition that the state label of any image data is the second state label or the third state label, modifying the state label of any image data into the first state label.

9. An apparatus for storing image data, the apparatus comprising:

the network module is used for detecting the network connection state between the network module and the server by taking a first duration as a detection period in the process of transmitting the shot image data to the server;

the processor is used for adjusting the detection period to a second time length when the network module detects that the network connection state is connection failure, wherein the second time length is smaller than the first time length;

and the processor is used for determining that network connection failure occurs between the processor and the server when the network connection state is detected to be connection failure in a continuous preset number of detection cycles, and storing the image data cached in the buffer and the subsequently shot image data into a local nonvolatile memory.

10. The apparatus of claim 9, wherein the second duration is 1/n of the first duration, and wherein n is a positive integer.

11. The apparatus of claim 9, wherein the processor is further configured to:

and after the detection period is adjusted to the second time length, when the network module detects that the network connection state is successful, the detection period is adjusted to the first time length.

12. The apparatus of claim 9, wherein the processor is further configured to:

and when the network module detects that the network connection state is the connection failure in a preset number of detection periods, adjusting the detection period to the first duration.

13. The apparatus of claim 9, wherein the processor is further configured to:

and when the network module detects that the network connection state is successful, transmitting the image data in the nonvolatile memory to the server through the network module, and transmitting the subsequently shot image data to the server.

14. The apparatus of claim 13, wherein the processor is further configured to:

continuously acquiring key frame data from the shot image data, backing up, and covering the key frame data backed up firstly when the data volume of the backed up key frame data reaches a preset threshold value;

when the network module detects that the network connection state is the connection failure in a continuous preset number of detection periods, copying currently backed-up key frame data into the nonvolatile memory;

and when the network module detects that the network connection state is successful, transmitting the copied key frame data to the server through the network module.

15. The apparatus of claim 9, wherein the processor is further configured to:

when any image data is stored in a buffer, adding a first state label to any image data, modifying the first state label of any image data into a second state label when a target storage address of the server is applied to any image data, modifying the second state label of any image data into a third state label when the network module starts to upload any image data to the server, and modifying the third state label of any image data into a fourth state label when the uploading of any image data is finished;

the processor is further configured to:

storing the image data of which the state label cached in the buffer is not the fourth state label into a local nonvolatile memory;

in the nonvolatile memory, a state tag of the image data, the state tag of which is the second state tag or the third state tag, is modified to the first state tag.

16. The apparatus of claim 9, wherein the processor is further configured to:

and when the state tag of any image data is a second state tag or a third state tag, modifying the state tag of any image data into a first state tag when the network module receives an occupation notification of the target storage address sent by the server.

17. The computer equipment is characterized by comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory are communicated with each other through the bus; a memory for storing a computer program; a processor for executing a program stored in the memory to perform the method steps of any of claims 1 to 8.

18. A computer readable storage medium having stored therein at least one instruction, at least one program, a set of codes, or a set of instructions, which is loaded and executed by a processor to implement a method of storing image data according to any one of claims 1 to 8.

Technical Field

The present invention relates to the field of network technologies, and in particular, to a method and an apparatus for storing image data.

Background

With the rapid development of networks, webcams have gradually entered the fields of education, medical treatment, business, and the like, and have played an important role in various fields. At present, pictures or videos taken by the network cameras are generally uploaded to a server for storage, and the limitation of the storage capacity of a local storage is reduced in this way.

When the network camera shoots, the shot image data are temporarily stored in a cache, the cache is divided into a plurality of cache units, and when one cache unit is full, the network camera uploads the data in the cache unit to a server. When all the cache units in the cache are full, the network camera will overwrite the stored image data in sequence from the cache unit which stores the data first when storing the subsequent image data. Meanwhile, the network camera has a mechanism for detecting network disconnection, periodically sends a network detection signaling to the server port, determines that the network camera is disconnected from the server when the server port is detected to be in a connection failure state for three consecutive times, namely, a network fault occurs, and stores image data cached by the shot image data and subsequently shot image data in the local memory.

In the process of implementing the invention, the inventor finds that the prior art has at least the following problems:

in the above scheme, there is a certain response time from the occurrence of the network failure to the detection and processing of the network failure by the network camera, and the response time is relatively long, so that the image data stored in the buffer may be overwritten, resulting in the loss of the image data.

Disclosure of Invention

To solve the problems of the prior art, embodiments of the present invention provide a method and apparatus for storing image data. The technical scheme is as follows:

in a first aspect, a method of storing image data is provided, the method comprising:

in the process of transmitting the shot image data to a server, detecting the network connection state between the server and the server by taking a first duration as a detection period;

when the network connection state is detected to be a connection failure, adjusting a detection period to be a second time length, wherein the second time length is smaller than the first time length;

and when the network connection state is detected to be connection failure in a continuous preset number of detection periods, determining that network connection failure occurs between the server and the network, and storing the image data cached in the buffer and the subsequently shot image data into a local nonvolatile memory.

Optionally, the second time duration is 1/n of the first time duration, where n is a positive integer.

Optionally, after the adjusting the detection period to the second duration, the method further includes:

and when the network connection state is detected to be successful, adjusting the detection period to the first duration.

Optionally, the method further comprises:

and when the network connection state is detected to be the connection failure in the continuous preset number of detection periods, adjusting the detection period to be the first time length.

Optionally, the method further comprises:

and when the network connection state is detected to be successful, transmitting the image data in the nonvolatile memory to the server, and transmitting the subsequently shot image data to the server.

Optionally, the method further comprises:

continuously acquiring key frame data from the shot image data, backing up, and covering the key frame data backed up firstly when the data volume of the backed up key frame data reaches a preset threshold value;

when the network connection state is detected to be connection failure in a continuous preset number of detection periods, copying currently backed-up key frame data into the nonvolatile memory;

and when the network connection state is detected to be successful, transmitting the copied key frame data to the server.

Optionally, the method further comprises:

when any image data is stored in a buffer, adding a first state label to any image data, modifying the first state label of any image data into a second state label when a target storage address of the server is applied to any image data, modifying the second state label of any image data into a third state label when uploading of any image data to the server is started, and modifying the third state label of any image data into a fourth state label when uploading of any image data is finished;

the step of storing the image data cached in the buffer and the image data shot subsequently into a local nonvolatile memory comprises the following steps:

storing the image data of which the state label cached in the buffer is not the fourth state label into a local nonvolatile memory;

in the nonvolatile memory, a state tag of the image data, the state tag of which is the second state tag or the third state tag, is modified to the first state tag.

Optionally, the method further comprises:

and when the occupation notice of the target storage address sent by the server is received under the condition that the state label of any image data is the second state label or the third state label, modifying the state label of any image data into the first state label.

In a second aspect, there is provided an apparatus for storing image data, the apparatus comprising:

the network module is used for detecting the network connection state between the network module and the server by taking a first duration as a detection period in the process of transmitting the shot image data to the server;

the processor is used for adjusting the detection period to a second time length when the network module detects that the network connection state is connection failure, wherein the second time length is smaller than the first time length;

and the processor is used for determining that network connection failure occurs between the processor and the server when the network connection state is detected to be connection failure in a continuous preset number of detection cycles, and storing the image data cached in the buffer and the subsequently shot image data into a local nonvolatile memory.

Optionally, the second time duration is 1/n of the first time duration, where n is a positive integer.

Optionally, the processor is further configured to:

and after the detection period is adjusted to the second time length, when the network module detects that the network connection state is successful, the detection period is adjusted to the first time length.

Optionally, the processor is further configured to:

and when the network module detects that the network connection state is the connection failure in a preset number of detection periods, adjusting the detection period to the first duration.

Optionally, the processor is further configured to:

and when the network module detects that the network connection state is successful, transmitting the image data in the nonvolatile memory to the server, and transmitting the subsequently shot image data to the server.

Optionally, the processor is further configured to:

continuously acquiring key frame data from the shot image data, backing up, and covering the key frame data backed up firstly when the data volume of the backed up key frame data reaches a preset threshold value;

when the network module detects that the network connection state is the connection failure in a continuous preset number of detection periods, copying currently backed-up key frame data into the nonvolatile memory;

and when the network module detects that the network connection state is successful, transmitting the copied key frame data to the server through the network module.

Optionally, the processor is further configured to:

when any image data is stored in a buffer, adding a first state label to any image data, modifying the first state label of any image data into a second state label when a target storage address of the server is applied to any image data, modifying the second state label of any image data into a third state label when the network module starts to upload any image data to the server, and modifying the third state label of any image data into a fourth state label when the uploading of any image data is finished;

the processor is further configured to:

storing the image data of which the state label cached in the buffer is not the fourth state label into a local nonvolatile memory;

in the nonvolatile memory, a state tag of the image data, the state tag of which is the second state tag or the third state tag, is modified to the first state tag.

Optionally, the processor is further configured to:

and when the state tag of any image data is a second state tag or a third state tag, modifying the state tag of any image data into a first state tag when the network module receives an occupation notification of the target storage address sent by the server.

In a third aspect, a computer device is characterized in that the computer device comprises a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory complete mutual communication through the bus; a memory for storing a computer program; a processor for executing a program stored in the memory to perform the method steps as described in the first aspect above.

In a fourth aspect, there is provided a computer readable storage medium having stored therein at least one instruction, at least one program, set of codes, or set of instructions, which is loaded and executed by the processor to implement the method of storing image data as described in the first aspect above.

The technical scheme provided by the embodiment of the invention has the beneficial effects that at least:

in the embodiment of the invention, when the network connection state between the network camera and the server is detected according to the detection period, and the network connection state is detected to be the connection failure, the detection period is adjusted to be shorter, so that whether the network connection failure occurs between the network camera and the server can be determined more quickly, the response time from the occurrence of the network failure to the detection and processing of the network failure by the network camera is shortened, the possibility of the image data stored in the cache being covered is reduced, and the possibility of the image data being lost is reduced.

Drawings

In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed to be used in the description of the embodiments will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.

FIG. 1 is a flow chart of a method of storing image data according to an embodiment of the present invention;

FIG. 2 is a diagram illustrating a method for storing image data according to an embodiment of the present invention;

FIG. 3 is a diagram illustrating a method for storing image data according to an embodiment of the present invention;

FIG. 4 is a diagram illustrating a method for storing image data according to an embodiment of the present invention;

FIG. 5 is a schematic structural diagram of an apparatus for storing image data according to an embodiment of the present invention;

fig. 6 is a schematic structural diagram of a network camera according to an embodiment of the present invention.

Detailed Description

In order to make the objects, technical solutions and advantages of the present invention more apparent, embodiments of the present invention will be described in detail with reference to the accompanying drawings.

The embodiment of the invention provides a method for storing image data, which can be realized by a network camera. Wherein, the network camera is provided with a local nonvolatile memory.

The webcam may include a processor, memory, transceiver, image detection components, and the like. The processor, which may be a CPU (Central Processing Unit), may be configured to detect a network connection state with the server according to a detection period, adjust the detection period, determine that a network connection failure occurs with the server, and store the image data cached in the buffer in a local nonvolatile memory. The memory may be a RAM (Random access memory), a Flash memory, a nonvolatile memory, and the like, and may be configured to store received data, data required by a processing procedure, data generated in the processing procedure, and the like, such as captured image data, a first duration, a second duration, a network connection state, a preset number, cached image data, and the like. The transceiver may be used for data transmission with other devices, for example, uploading captured image data to a server, and may include an antenna, a matching circuit, a modem, and the like. The image detection means may be a camera or the like. The network camera may further include a screen, an image detection part, an audio output part, an audio input part, and the like. The screen may be used for the photographed image data. The audio output component may be a speaker, headphones, or the like. The audio input means may be a microphone or the like.

As shown in fig. 1, the processing flow of the method may include the following steps:

in step 101, a network connection state with a server is detected with a first duration as a detection period in transmitting captured image data to the server.

In implementation, a webcam may be used to take video or capture a picture and upload it to a server for storage, as shown by transmission line ① in fig. 2, in such a way as to reduce the limitations on local memory storage capacity.

In the process of transmitting the shot image data to the server, the network camera is provided with a mechanism for detecting the network disconnection, and periodically sends a network detection signaling to a server port by taking the first time length as a detection period so as to determine the network connection state between the server and the network camera.

In step 102, when the network connection state is detected to be a connection failure, the detection period is adjusted to a second duration, wherein the second duration is smaller than the first duration.

In implementation, after the network connection state is periodically determined through the above steps, when it is detected that the network connection state is a connection failure, it indicates that the connection between the current network camera and the server may have a failure, and in order to determine whether the connection with the server is disconnected as soon as possible, the detection period may be adjusted to a second duration, where the second duration is shorter than the first duration. Therefore, the time for judging the network connection state can be shortened, whether the connection with the server is disconnected or not can be determined as soon as possible, and the detection efficiency is improved.

Optionally, the second duration is 1/n of the first duration, where n is a positive integer.

In practice, the technician may set the second length of time to 1/n of the first length of time, which may be 1/5 of the first length of time based on the technician's experience with multiple trials.

Optionally, after detecting that the network connection status is connection failure, when detecting that the network connection status is connection success, the detection period is adjusted to the first duration.

In implementation, when the network connection state is detected to be a connection failure and then the network connection state is detected to be a connection success, it is indicated that the current network is clear, that is, the data transmission can be performed with the server.

Optionally, when the network connection status is detected to be a connection failure for a preset number of detection cycles, the detection cycle is adjusted to be the first duration.

In implementation, according to the setting of a technician, when the network connection state is detected to be a connection failure in a preset number of detection cycles, it can be determined that the network camera is disconnected from the server and data transmission cannot be performed. Therefore, it is not necessary to detect the network connection state too frequently in this case to avoid wasting resources, and therefore, the detection period is readjusted to the first duration in this case.

In step 103, when the network connection state is detected to be a connection failure for a preset number of detection cycles, it is determined that a network connection failure occurs between the server and the network connection state, and the image data cached in the buffer and the image data shot subsequently are stored in a local nonvolatile memory.

In implementation, a technician may preset that when the network connection state is detected as a connection failure in a preset number of detection cycles, that is, a network connection failure occurs between the technician and the server, and if the network connection state is detected as a connection failure in three consecutive times, the technician determines that a network connection failure occurs between the technician and the server, so that the accuracy of detection can be improved.

When it is determined that the connection with the server fails, the image data cached in the current buffer and the image data captured subsequently may be stored in a local non-volatile memory for saving in order to retain the image data captured by the network camera during the period of disconnection from the server.

Optionally, after the webcam is reconnected to the server, the image data may be backed up in the server, and the corresponding processing is as follows: and when the network connection state is detected to be successful, transmitting the image data in the nonvolatile memory to the server, and transmitting the image data of the subsequent shooting to the server.

In an implementation, when the network camera detects again that the network connection status is successful, it is described that the current network camera establishes a connection with the server and data transmission is possible, and in this case, in order to alleviate the limitation caused by the capacity of the local nonvolatile memory, the image data stored in the nonvolatile memory may be backed up in the server, as shown by a transmission line ② in fig. 2, and the subsequently captured image data may be normally transmitted to the server.

Therefore, when the storage capacity of the nonvolatile memory is insufficient, the newly shot image data can be used for carrying out the covering processing on the image data in the nonvolatile memory, so that the nonvolatile memory can be provided with a covering mechanism, the limitation caused by the storage capacity is avoided, and the nonvolatile memory with the covering mechanism can be prevented from losing the stored image data.

Alternatively, in order to reduce image data lost during the period from the occurrence of the network failure to the network camera detecting and processing the network failure, the following processing may be performed: continuously acquiring key frame data from the shot image data, backing up, and covering the key frame data backed up firstly when the data volume of the backed up key frame data reaches a preset threshold value; when the network connection state is detected to be connection failure in a continuous preset number of detection periods, copying currently backed-up key frame data into a nonvolatile memory; and when the network connection state is detected to be successful, transmitting the copied key frame data to the server.

In implementation, when the photographed image data is temporarily stored in the buffer, the buffer is associated with a preset storage region (i.e., a first storage region) to which a storage pointer of the buffer points. Key frame data of the image data are extracted from the buffer, and the key frame data are stored in the first storage area in a backup mode. If the network connection is normal, the network camera continuously backs up the acquired key frame data to the first storage area by adopting an overlay mechanism while uploading the shot image data to the server.

When the network connection state is detected to be a connection failure in a preset number of detection cycles, that is, when the network camera detects that the network camera is disconnected from the server, the network camera does not cover the data of the first storage area but newly applies a storage space for subsequently acquired key frame data, that is, a second storage area, while storing the captured image data in the local nonvolatile memory, as shown in fig. 3, the storage pointer associated with the buffer is pointed to the second storage area, that is, a covering mechanism for subsequently extracted key frame data is temporarily stored in the second storage area. In this way, it is possible to retain key frames of image data taken during the period from the occurrence of a network failure to the time when the network camera detects and processes the network failure, i.e., to retain important images of the lost image data.

After the network camera is successfully connected with the server, the network camera can upload the key frame data cached in the period from the network failure to the network camera for detecting and processing the network failure, the image data stored in the local nonvolatile memory during the whole network failure period, and the image data shot after being connected with the server to the server.

It should be noted that the image data may be managed by forming a complete image file according to image data of a preset size, for example, 256M image data is a complete file. In the process of uploading the image data to the server by the network camera, the image data may be divided into a plurality of image data units according to a preset unit value for uploading, for example, one image data unit is uploaded according to 1M image data. The preset size value of the image file and the preset unit value of the image data unit are both determined by the storage format of the local nonvolatile memory.

Optionally, the image data may adopt four different state tags to label the state of the image data, when any image data is stored in the buffer, a first state tag is added to any image data, when a target storage address of the server is applied for any image data, the first state tag of any image data is modified into a second state tag, when any image data is uploaded to the server, the second state tag of any image data is modified into a third state tag, and when any image data is uploaded, the third state tag of any image data is modified into a fourth state tag.

In a possible embodiment, for the four state tags, it can be used in the data backup process, and the conversion process in the backup process according to the four state tags is: first status tab → second status tab → third status tab → fourth status tab, as shown in table 1 below.

TABLE 1

Status label State interpretation
First state tag Data to be distributed
Second state tag Distributed data
Third status label Completion data
Fourth status label Normal document

When it is detected that image data is stored in the buffer, the network camera determines the image data stored in the buffer as a first status tag. The first state label represents a file needing to be backed up, and when the network camera and the server reestablish connection and the network camera detects the image data marked with the first state label, the image data is distributed in the storage position of the server.

After the storage position of the server is allocated to the image data, the state label of the image data is modified into a second state label. The second status label indicates that the allocation of storage locations has been completed on the network storage media, awaiting the data backup.

And modifying the state label of the image data into a third state label at the beginning of the backup in the image data backup server according to the allocated storage position. The third status tag indicates that image data is being sent to the server.

And when the backup of a complete image file is completed, modifying the state label of the image data in the complete image file in the local nonvolatile memory into a fourth state label. The fourth status label represents the status after the backup is completed, and the image data belongs to the image data which is already backed up, and the backup is not triggered.

Optionally, when the network camera detects that a network connection failure occurs with the server, when the image data cached in the buffer and the subsequently captured image data are stored in the local non-volatile memory, which image data need to be stored in the local non-volatile memory may be distinguished according to the status tag of the image data, and the corresponding processing steps may be as follows: storing the image data of which the state label cached in the buffer is not the fourth state label into a local nonvolatile memory; in the nonvolatile memory, a state tag of the image data whose state tag is the second state tag or the third state tag is modified to the first state tag.

In a possible embodiment, since the fourth status tag is used to indicate that the image data has been backed up, the image data marked with the fourth status tag in the buffer is the image data that has been backed up to the server, and therefore, the image data whose status tag is the fourth status tag in the buffer does not need to be stored in the local nonvolatile memory, and therefore, the webcam stores the image data that is not the fourth status tag (i.e., the image data whose status tags are the first status tag, the second status tag, and the third status tag) in the local nonvolatile memory, so that when the webcam is reconnected to the server, the image data can be backed up to the server.

After the image data of which the state labels are the first state label, the second state label and the third state label are stored in the nonvolatile memory, the state label of the image data of which the state labels are the second state label or the third state label is modified into the first state label, so that after the network camera and the server are reestablished, the storage address in the server is applied for the image data needing to be backed up to the server, and the image data can be smoothly backed up to the server.

It should be noted that, the operation of modifying the state tag of the image data, which is stored in the nonvolatile memory and whose state tag is the second state tag or the third state tag, into the first state tag may be performed after the image data is stored in the nonvolatile memory as described above, or may be performed after the network camera and the server reestablish a connection, and the network camera detects whether the image data whose state tag is the second state tag or the third state tag exists in the nonvolatile memory, and if so, modifies the state tag of the image data into the first state tag. The invention does not limit the time when this modification process occurs.

In the process of backing up the image data, the above four states of the image data to be backed up are converted for each image data to be backed up. In addition, the four state tags can be used not only for image data, but also for managing configuration files of the storage space, so as to indicate the state of the storage space. For a configuration file on a server that manages storage space, there may be three state tags, whose transformation process during backup is: second status tab → third status tab → fourth status tab.

When the network camera applies for the image data in the local nonvolatile memory to the storage space of the server, the state label of the configuration file for managing the storage space is modified to be a second state label, which indicates that the space is preset, and the storage of the image data is waited.

When the network camera starts to upload the image data in the local nonvolatile memory to the server, the state label of the configuration file for managing the storage space is modified into a third state label, which indicates that the storage space is receiving data.

When the network camera uploads the image data in the complete image file in the local nonvolatile memory to the server, the state tag of the configuration file for managing the storage space is modified into a fourth state tag to indicate that the storage space stores the complete image file, and the server updates the image file index according to the image file, so that the image file can be inquired through the image file index, namely the image data stored in the storage space can be viewed or downloaded.

Alternatively, for the above-mentioned process of state transition, an error may occur due to detection of an abnormality or execution, in which case, the correction may be performed by modifying the state label of the image data, and the corresponding operation steps may be as follows: and when the occupation notice of the target storage address sent by the server is received under the condition that the state label of any image data is the second state label or the third state label, modifying the state label of any image data into the first state label.

In one possible embodiment, when the status label of the image data is the second status label, as shown at ① in fig. 4, that is, when the storage location of the server has been applied for the image data, the connection between the webcam and the server fails again or the storage space allocated for the image data is occupied by other threads with higher priority, the status label may be modified to the first status label, and the storage location may be applied for the image data again.

When the status label of the image data stored in the local nonvolatile memory is the third status label, as shown in ② in fig. 4, that is, when the image data is being uploaded to the server, the connection between the network camera and the server fails again, so that the image data cannot be uploaded to the server normally, or the storage space allocated for the image data is occupied by other threads with higher priority, the status label of the image data is modified to the first status label, and the storage location is applied for the image data again.

It should be noted that, in addition to modifying the status tag of the image data, the status tag of the configuration file for managing the storage space may also be modified to correct the abnormal situation.

When the status label of the image data stored in the storage space of the server is the third status label, as shown in ③ in fig. 4, that is, when the image data of the complete image file has not been transmitted yet, and the connection between the network camera and the server fails again, so that the image data cannot be uploaded to the server normally, the status label of the image data received in the server is modified to the fourth status label, so that the image data cannot update the index because of not being the complete image file, and when the server detects that the status label of the image data is the fourth status label but cannot check the image data in the index, the image data is determined to be invalid image data, the storage space can be reapplied, and the image data in the storage space can be overwritten by the newly stored image data, so that the storage space can be prevented from being occupied by invalid data all the time.

When the status label of the profile for managing the storage space is the second status label, as shown in ④ in fig. 4, that is, when the storage space has been reserved, it is detected that a network failure occurs again in the network camera and the server, or the local nonvolatile memory is damaged, that is, the image data cannot be normally stored in the storage space, in this case, the status label of the profile for managing the storage space may be modified to the fourth status label, so that the storage space may be applied for by other image data, and the storage space is prevented from being wasted.

When it is detected that the status label of the image data stored in the server is the first status label, as shown in ⑤ in fig. 4, that is, when it is detected that the status label of the image data is the first status label which is abnormal, for example, when the status label of the image data which has been backed up is the first status label, the status label of the image data is modified to the fourth status label, so that the image data becomes the image data which does not need to be backed up.

It should be noted that, for the data stored in the server, when the storage space of the server is about to be full, the user may select to preferentially reserve the image data with the earlier backup time, or preferentially reserve the image data that is backed up most recently.

When the user selects to reserve the image data with the backup time earlier in priority, if the server detects that the storage capacity is insufficient, the image data sent by the network camera is refused to be stored.

When the user selects to preferentially reserve the image data which is backed up most recently, if the server detects that the storage capacity is insufficient, the image data which is stored first are sequentially overwritten according to the storage order of the image data.

In the embodiment of the invention, when the network connection state between the network camera and the server is detected according to the detection period, and the network connection state is detected to be the connection failure, the detection period is adjusted to be shorter, so that whether the network connection failure occurs between the network camera and the server can be determined more quickly, the response time from the occurrence of the network failure to the detection and processing of the network failure by the network camera is shortened, the possibility of the image data stored in the cache being covered is reduced, and the possibility of the image data being lost is reduced.

Based on the same technical concept, an embodiment of the present invention further provides an apparatus for storing image data, where the apparatus may be the network camera in the foregoing embodiment, and as shown in fig. 5, the apparatus includes: a network module 510 and a processor 520.

The network module 510 is configured to detect a network connection state with the server with a first duration as a detection period in the process of transmitting the photographed image data to the server;

the processor 520 is configured to adjust the detection period to a second duration when the network connection status is detected as a connection failure, wherein the second duration is smaller than the first duration;

the processor 520 is further configured to determine that a network connection failure occurs with the server when the network connection status is detected as a connection failure for a preset number of detection cycles, and store the image data cached in the buffer and the image data captured subsequently in the local non-volatile memory.

Optionally, the second time duration is 1/n of the first time duration, where n is a positive integer.

Optionally, the processor 520 is further configured to:

after the detection period is adjusted to the second duration, when the network module 510 detects that the network connection status is successful, the detection period is adjusted to the first duration.

Optionally, the processor 520 is further configured to:

when the network module 510 detects that the network connection status is a connection failure for a preset number of detection cycles, the detection cycle is adjusted to the first duration.

Optionally, the processor 520 is further configured to:

when the network module 510 detects that the network connection status is successful, the network module 510 transmits the image data in the non-volatile memory to the server, and transmits the image data of the subsequent shot to the server.

Optionally, the processor 520 is further configured to:

continuously acquiring key frame data from the shot image data, backing up, and covering the key frame data backed up firstly when the data volume of the backed up key frame data reaches a preset threshold value;

when the network module 510 detects that the network connection status is a connection failure for a preset number of detection cycles, copying currently backed-up key frame data into the nonvolatile memory;

when the network module 510 detects that the network connection status is successful, the copied key frame data is transmitted to the server through the network module 510.

Optionally, the processor 520 is further configured to:

when any image data is stored in a buffer, adding a first state label to any image data, modifying the first state label of any image data into a second state label when a target storage address of a server is applied to any image data, modifying the second state label of any image data into a third state label when the network module 510 starts to upload any image data to the server, and modifying the third state label of any image data into a fourth state label when the uploading of any image data is finished;

the processor 520 is further configured to:

storing the image data of which the state label cached in the buffer is not the fourth state label into a local nonvolatile memory;

in the nonvolatile memory, a state tag of the image data, the state tag of which is the second state tag or the third state tag, is modified to the first state tag.

Optionally, the processor 520 is further configured to:

when the status tag of any image data is the second status tag or the third status tag, the status tag of any image data is modified into the first status tag when the occupation notification of the target storage address sent by the server is received through the network module 510.

In the embodiment of the invention, when the network connection state between the network camera and the server is detected according to the detection period, and the network connection state is detected to be the connection failure, the detection period is adjusted to be shorter, so that whether the network connection failure occurs between the network camera and the server can be determined more quickly, the response time from the occurrence of the network failure to the detection and processing of the network failure by the network camera is shortened, the possibility of the image data stored in the cache being covered is reduced, and the possibility of the image data being lost is reduced.

With regard to the apparatus in the above-described embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment related to the method, and will not be elaborated here.

It should be noted that: in the device for storing image data provided in the above embodiment, when storing image data, only the division of the above functional modules is taken as an example, and in practical applications, the above functions may be distributed by different functional modules according to needs, that is, the internal structure of the network camera is divided into different functional modules to complete all or part of the above described functions. In addition, the apparatus for storing image data and the method for storing image data provided by the above embodiments belong to the same concept, and specific implementation processes thereof are detailed in the method embodiments and are not described herein again.

Fig. 6 is a block diagram of a network camera according to an embodiment of the present invention. In general, the network camera 600 includes: a processor 601 and a memory 602.

Processor 601 may include one or more processing cores, such as a 4-core processor, a 10-core processor, and so forth. The processor 601 may be implemented in at least one hardware form of a DSP (Digital Signal Processing), an FPGA (Field-Programmable Gate Array), and a PLA (Programmable Logic Array). The processor 601 may also include a main processor and a coprocessor, where the main processor is a processor for processing data in an awake state, and is also called a Central Processing Unit (CPU); a coprocessor is a low power processor for processing data in a standby state. In some embodiments, the processor 601 may be integrated with a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content required to be displayed on the display screen. In some embodiments, processor 601 may also include an AI (Artificial Intelligence) processor for processing computational operations related to machine learning.

Memory 602 may include one or more computer-readable storage media, which may be tangible and non-transitory. The memory 602 may also include high-speed random access memory, as well as non-volatile memory, such as one or more magnetic disk storage devices, flash memory storage devices. In some embodiments, a non-transitory computer readable storage medium in memory 602 is used to store at least one instruction for execution by processor 601 to implement the methods of storing image data provided herein.

In some embodiments, the webcam 600 may further include: a peripheral interface 603 and at least one peripheral. Specifically, the peripheral device includes: at least one of a radio frequency circuit 604, a touch screen display 605, a camera 606, an audio circuit 607, a positioning component 608, and a power supply 609.

The peripheral interface 603 may be used to connect at least one peripheral related to I/O (Input/Output) to the processor 601 and the memory 602. In some embodiments, the processor 601, memory 602, and peripheral interface 603 are integrated on the same chip or circuit board; in some other embodiments, any one or two of the processor 601, the memory 602, and the peripheral interface 603 may be implemented on a separate chip or circuit board, which is not limited in this embodiment.

The Radio Frequency circuit 604 is used for receiving and transmitting RF (Radio Frequency) signals, also called electromagnetic signals. The radio frequency circuitry 604 communicates with communication networks and other communication devices via electromagnetic signals. The rf circuit 604 converts an electrical signal into an electromagnetic signal to transmit, or converts a received electromagnetic signal into an electrical signal. Optionally, the radio frequency circuit 604 comprises: an antenna system, an RF transceiver, one or more amplifiers, a tuner, an oscillator, a digital signal processor, a codec chipset, a subscriber identity module card, and so forth. The radio frequency circuit 604 may communicate with other webcams via at least one wireless communication protocol. The wireless communication protocols include, but are not limited to: the world wide web, metropolitan area networks, intranets, generations of mobile communication networks (2G, 3G, 4G, and 5G), Wireless local area networks, and/or WiFi (Wireless Fidelity) networks. In some embodiments, the rf circuit 604 may further include NFC (Near Field Communication) related circuits, which are not limited in this application.

The touch display 605 is used to display a UI (User Interface). The UI may include graphics, text, icons, video, and any combination thereof. The touch display screen 605 also has the ability to acquire touch signals on or over the surface of the touch display screen 605. The touch signal may be input to the processor 601 as a control signal for processing. The touch display 605 is used to provide virtual buttons and/or a virtual keyboard, also referred to as soft buttons and/or a soft keyboard. In some embodiments, the touch display 605 may be one, providing the front panel of the webcam 600; in other embodiments, the touch screen display 605 may be at least two, respectively disposed on different surfaces of the webcam 600 or in a folded design; in still other embodiments, the touch display 605 may be a flexible display disposed on a curved surface or on a folded surface of the webcam 600. Even more, the touch screen display 605 may be arranged in a non-rectangular irregular pattern, i.e., a shaped screen. The touch screen 605 may be made of LCD (Liquid Crystal Display), OLED (Organic Light-emitting diode), and the like.

The camera assembly 606 is used to capture images or video. Optionally, camera assembly 606 includes a front camera and a rear camera. Generally, a front camera is used for realizing video call or self-shooting, and a rear camera is used for realizing shooting of pictures or videos. In some embodiments, the number of the rear cameras is at least two, and each of the rear cameras is any one of a main camera, a depth-of-field camera and a wide-angle camera, so that the main camera and the depth-of-field camera are fused to realize a background blurring function, and the main camera and the wide-angle camera are fused to realize a panoramic shooting function and a VR (Virtual Reality) shooting function. In some embodiments, camera assembly 606 may also include a flash. The flash lamp can be a monochrome temperature flash lamp or a bicolor temperature flash lamp. The double-color-temperature flash lamp is a combination of a warm-light flash lamp and a cold-light flash lamp, and can be used for light compensation at different color temperatures.

The audio circuit 607 is used to provide an audio interface between the user and the network camera 600. Audio circuitry 607 may include a microphone and a speaker. The microphone is used for collecting sound waves of a user and the environment, converting the sound waves into electric signals, and inputting the electric signals to the processor 601 for processing or inputting the electric signals to the radio frequency circuit 604 to realize voice communication. For stereo capture or noise reduction purposes, multiple microphones may be provided at different locations of the webcam 600. The microphone may also be an array microphone or an omni-directional pick-up microphone. The speaker is used to convert electrical signals from the processor 601 or the radio frequency circuit 604 into sound waves. The loudspeaker can be a traditional film loudspeaker or a piezoelectric ceramic loudspeaker. When the speaker is a piezoelectric ceramic speaker, the speaker can be used for purposes such as converting an electric signal into a sound wave audible to a human being, or converting an electric signal into a sound wave inaudible to a human being to measure a distance. In some embodiments, audio circuitry 607 may also include a headphone jack.

The positioning component 608 is used to locate the current geographic Location of the webcam 600 to implement navigation or LBS (Location Based Service). The positioning component 608 can be a positioning component based on the GPS (global positioning System) in the united states, the beidou System in china, or the galileo System in russia.

The power supply 609 is used to supply power to the various components in the network camera 600. The power supply 609 may be ac, dc, disposable or rechargeable. When the power supply 609 includes a rechargeable battery, the rechargeable battery may be a wired rechargeable battery or a wireless rechargeable battery. The wired rechargeable battery is a battery charged through a wired line, and the wireless rechargeable battery is a battery charged through a wireless coil. The rechargeable battery may also be used to support fast charge technology.

In some embodiments, the webcam 600 further includes one or more sensors 610. The one or more sensors 610 include, but are not limited to: acceleration sensor 611, gyro sensor 612, pressure sensor 613, fingerprint sensor 614, optical sensor 615, and proximity sensor 616.

The acceleration sensor 611 can detect the magnitude of acceleration on three coordinate axes of the coordinate system established with the network camera 600. For example, the acceleration sensor 611 may be used to detect components of the gravitational acceleration in three coordinate axes. The processor 601 may control the touch screen display 605 to display the user interface in a landscape view or a portrait view according to the gravitational acceleration signal collected by the acceleration sensor 611. The acceleration sensor 611 may also be used for acquisition of motion data of a game or a user.

The gyro sensor 612 may detect a body direction and a rotation angle of the network camera 600, and the gyro sensor 612 may cooperate with the acceleration sensor 611 to acquire a 3D motion of the user on the network camera 600. The processor 601 may implement the following functions according to the data collected by the gyro sensor 612: motion sensing (such as changing the UI according to a user's tilting operation), image stabilization at the time of photographing, game control, and inertial navigation.

The pressure sensor 613 may be disposed on a side frame of the webcam 600 and/or on a lower layer of the touch display screen 605. When the pressure sensor 613 is provided on the side frame of the network camera 600, a user's grip signal on the network camera 600 can be detected, and left-right hand recognition or quick operation can be performed based on the grip signal. When the pressure sensor 613 is disposed at the lower layer of the touch display screen 605, it is possible to control an operability control on the UI interface according to a pressure operation of the user on the touch display screen 605. The operability control comprises at least one of a button control, a scroll bar control, an icon control and a menu control.

The fingerprint sensor 614 is used for collecting a fingerprint of the user to identify the identity of the user according to the collected fingerprint. Upon identifying that the user's identity is a trusted identity, the processor 601 authorizes the user to perform relevant sensitive operations including unlocking the screen, viewing encrypted information, downloading software, paying, and changing settings, etc. The fingerprint sensor 614 may be provided on the front, back, or side of the webcam 600. When a physical button or vendor Logo is provided on the webcam 600, the fingerprint sensor 614 may be integrated with the physical button or vendor Logo.

The optical sensor 615 is used to collect the ambient light intensity. In one embodiment, processor 601 may control the display brightness of touch display 605 based on the ambient light intensity collected by optical sensor 615. Specifically, when the ambient light intensity is high, the display brightness of the touch display screen 605 is increased; when the ambient light intensity is low, the display brightness of the touch display screen 605 is turned down. In another embodiment, the processor 601 may also dynamically adjust the shooting parameters of the camera assembly 606 according to the ambient light intensity collected by the optical sensor 615.

A proximity sensor 616, also called a distance sensor, is typically provided on the front side of the network camera 600. The proximity sensor 616 is used to capture the distance between the user and the front of the web camera 600. In one embodiment, when the proximity sensor 616 detects that the distance between the user and the front surface of the network camera 600 gradually decreases, the processor 601 controls the touch display screen 605 to switch from the bright screen state to the dark screen state; when the proximity sensor 616 detects that the distance between the user and the front surface of the network camera 600 becomes gradually larger, the processor 601 controls the touch display screen 605 to switch from the screen-on state to the screen-on state.

Those skilled in the art will appreciate that the configuration shown in fig. 6 does not constitute a limitation of the network camera 600, and may include more or fewer components than those shown, or combine some components, or adopt a different arrangement of components.

In the embodiment of the invention, when the network connection state between the network camera and the server is detected according to the detection period, and the network connection state is detected to be the connection failure, the detection period is adjusted to be shorter, so that whether the network connection failure occurs between the network camera and the server can be determined more quickly, the response time from the occurrence of the network failure to the detection and processing of the network failure by the network camera is shortened, the possibility of the image data stored in the cache being covered is reduced, and the possibility of the image data being lost is reduced.

In an exemplary embodiment, a computer readable storage medium is also provided, in which at least one instruction, at least one program, code set, or instruction set is stored, and the at least one instruction, the at least one program, the code set, or the instruction set is loaded and executed by a processor to implement the method for identifying an action category in the above embodiments. For example, the computer readable storage medium may be a ROM, a Random Access Memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, and the like.

It will be understood by those skilled in the art that all or part of the steps for implementing the above embodiments may be implemented by hardware, or may be implemented by a program instructing relevant hardware, where the program may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a magnetic disk or an optical disk, etc.

The above description is only for the purpose of illustrating the preferred embodiments of the present invention and is not to be construed as limiting the invention, and any modifications, equivalents, improvements and the like that fall within the spirit and principle of the present invention are intended to be included therein.

20页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:行车轨迹记录方法、装置及行车轨迹分享系统

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!

技术分类