Method and device for retrieving video
By performing target recognition and merging processing on the video streams collected by the video recording equipment, a target digital matrix is generated, which solves the problem of low video retrieval accuracy in the existing technology and achieves more efficient and accurate video retrieval.
Patent Information
- Application Number
- CN202411136282.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-19
- Publication Date
- 2024-10-29
- Estimated Expiration
- 2044-08-19
AI Technical Summary
Video retrieval methods in the existing technology mainly rely on time and location information, and cannot filter retrieval by area, resulting in low retrieval accuracy and efficiency.
By obtaining the video stream collected by the video recording device, target recognition is performed on each video frame, a digital matrix set is generated, and target areas of the same type are merged to form a target digital matrix, and video retrieval is performed based on these matrices.
It improves the accuracy and efficiency of video retrieval, enables precise retrieval by region, time and target type, reduces the amount of data storage and saves resources.
Smart Images

Figure CN118656519B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the field of image processing, and in particular, to a method and device for retrieving a video. Background Art
[0002] With the development of artificial intelligence technology, cameras are increasingly used in life, such as home, business, and transportation. By recording the surrounding behavior, environment, and events in real time through cameras, and querying the content recorded by the camera afterwards, the event can be effectively traced, thereby improving the convenience and safety of life. However, the current method of retrieving video clips is mainly based on information such as time and location, and it is impossible to filter the search by area, which affects the accuracy and efficiency of the search.
[0003] There is currently no effective solution to the above problems. Summary of the invention
[0004] The embodiments of the present invention provide a method and device for retrieving videos, so as to at least solve the problem of low video retrieval accuracy in the related art.
[0005] According to an embodiment of the present invention, a method for retrieving a video is provided, comprising: obtaining N video streams, wherein the N video streams are video clips captured by a video recording device in N time periods, N is an integer greater than or equal to 2, and each of the video streams includes multiple video frames; performing target recognition on the multiple video frames included in each of the video streams to obtain N digital matrix sets corresponding to the N video streams, wherein the target recognition is performed on one of the video frames to obtain a digital matrix for identifying an area where a target in the video frame is located, and the digital matrix set includes a digital matrix obtained by performing the target recognition on the video frames of the video streams, Each position of the area where the target is located in the digital matrix is a preset value, and the digital matrix is used to identify the area where at least one type of target is located; based on the areas where the same type of targets are located identified by multiple digital matrices included in each digital matrix set, the digital matrix set is merged to obtain N target digital matrices, wherein each target digital matrix is used to identify at least one target area, and each target area is an area obtained by merging the areas where the same type of targets are located identified by multiple digital matrices included in the corresponding digital matrix set; video retrieval is performed based on the N target digital matrices.
[0006] In an exemplary embodiment, video retrieval is performed based on the N target digital matrices, including: obtaining a target retrieval request, wherein the target retrieval request includes the type of the target to be retrieved and the time period to be retrieved; determining M first target digital matrices in the N target digital matrices according to the time period to be retrieved, wherein the time of the time period to be retrieved is within M time periods of the M first target digital matrices, and M is an integer greater than or equal to 1 and less than or equal to N; determining S second target digital matrices in the M first target digital matrices according to the type of the target to be retrieved, wherein S is an integer greater than or equal to 1 and less than or equal to M; and determining a target video stream according to the S second target digital matrices, wherein the target video stream is the retrieved video stream.
[0007] In an exemplary embodiment, S second target digital matrices are determined from the M first target digital matrices according to the type of the target to be retrieved, including: determining the target digital matrix containing the target of the same type as the target to be retrieved in the M first target digital matrices as the second target digital matrix.
[0008] In an exemplary embodiment, determining a target video stream according to the S second target digital matrices includes: determining S video streams corresponding to the S second target digital matrices as the target video streams; or, in the case where S is greater than 1 and the target retrieval request also includes a to-be-retrieved area, determining S target areas where targets of the same type as the to-be-retrieved target are located in the S second target digital matrices; determining a digital matrix where the target areas whose intersections among the S target areas with the to-be-retrieved area are greater than or equal to a preset threshold are located as a third target digital matrix; determining a video stream corresponding to the third target digital matrix as the target video stream; or, in the case where S is greater than 1 and the target retrieval request also includes a to-be-retrieved area, determining a digital matrix where the target areas of the same type as the to-be-retrieved target are located in the S second target digital matrices. The method comprises the following steps: determining S target regions where the target region having the largest intersection with the region to be retrieved among the S target regions is located as a fourth target digital matrix; determining a video stream corresponding to the fourth target digital matrix as the target video stream; or, when S is greater than 1 and the target retrieval request also includes the region to be retrieved, determining S target regions where the target region having the same type as the target to be retrieved is located in the S second target digital matrices; sorting the intersection regions with the region to be retrieved among the S target regions, and determining the digital matrices where the Q target regions corresponding to the first Q intersection regions are located as a fifth target digital matrix; and determining a video stream corresponding to the fifth target digital matrix as the target video stream, wherein Q is an integer greater than or equal to 1 and less than or equal to S.
[0009] In an exemplary embodiment, obtaining N video streams includes: performing video frame acquisition through the video recording device; determining the currently acquired video frame and the last acquired video frame as video frames in the same video stream when the time interval between the video frame currently acquired by the video recording device and the last acquired video frame is less than or equal to a preset time threshold; and determining the currently acquired video frame and the last acquired video frame as video frames in different video streams when the time interval between the video frame currently acquired by the video recording device and the last acquired video frame is greater than the preset time threshold.
[0010] In an exemplary embodiment, target recognition is performed on the multiple video frames included in each of the video streams to obtain N digital matrix sets corresponding to the N video streams, including: performing the following operations on the video frames in each of the video streams, the video frame on which the following operations are performed is the current video frame: performing the target recognition on the current video frame, setting the value of the position where the target is located in the current video frame to the preset value, and setting other positions in the current video frame except the position where the target is located to other values to obtain the digital matrix of the current video frame.
[0011] In an exemplary embodiment, based on the regions where the targets of the same type identified by the multiple digital matrices included in each of the digital matrix sets are located, the digital matrix sets are merged, including: when the digital matrix set currently being processed is the current digital matrix set, determining the types of targets included in the current digital matrix set to obtain at least one type of the target; performing the following operations on the at least one type of the target, and determining the type performed by the following operations as the current type: determining the regions where the targets of the current type are located in the current digital matrix set to obtain T regions, wherein T is an integer greater than or equal to 1 and less than or equal to N; when T is greater than 1, determining the current target region obtained by performing the merging process on the T regions as the region of the target of the current type in the current target digital matrix, wherein the current target digital matrix is the target digital matrix corresponding to the current digital matrix set, and at least one target region of the current target digital matrix includes the current target region; when T is equal to 1, determining a region as the region of the target of the current type in the current target digital matrix, wherein the current target digital matrix is the target digital matrix corresponding to the current digital matrix set.
[0012] According to another embodiment of the present invention, there is provided an apparatus for retrieving a video, comprising: an acquisition module, for acquiring N video streams, wherein the N video streams are video clips captured by a video recording device in N time periods, N is an integer greater than or equal to 2, and each of the video streams includes a plurality of video frames; an identification module, for performing target identification on the plurality of video frames included in each of the video streams, respectively, to obtain N digital matrix sets corresponding to the N video streams, wherein the target identification is performed on one of the video frames to obtain a digital matrix for identifying an area where a target in the video frame is located, and the digital matrix set includes a digital matrix obtained by performing the target identification on the video frames of the video streams, Each position of the area where the target is located in the digital matrix is a preset value, and the digital matrix is used to identify the area where at least one type of target is located; a merging module is used to merge the digital matrix set based on the areas where the same type of targets are located identified by multiple digital matrices included in each digital matrix set, to obtain N target digital matrices, wherein each target digital matrix is used to identify at least one target area, and each target area is an area obtained by merging the areas where the same type of targets are located identified by multiple digital matrices included in the corresponding digital matrix set; a retrieval module is used to perform video retrieval based on the N target digital matrices.
[0013] According to yet another embodiment of the present invention, a computer-readable storage medium is provided, wherein a computer program is stored in the computer-readable storage medium, wherein the computer program implements the steps of any of the above methods when executed by a processor.
[0014] According to yet another embodiment of the present invention, there is provided an electronic device, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.
[0015] According to yet another embodiment of the present invention, a computer program product is provided, comprising a computer program, wherein when the computer program is executed by a processor, the steps of any of the above methods are implemented.
[0016] Through the present invention, by identifying the video clips collected by the video recording device, a digital matrix of the target area in each video frame included in the video clip is obtained, and the obtained digital matrix is merged and stored, so as to perform video retrieval based on the stored digital matrix. Therefore, the problem of low video retrieval accuracy in the related art can be solved, and the effect of improving the video retrieval accuracy can be achieved. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] Figure 1is a hardware structure block diagram of a mobile terminal according to a method for retrieving videos according to an embodiment of the present invention;
[0018] Figure 2 is a flow chart of a method for retrieving videos according to an embodiment of the present invention;
[0019] Figure 3 is a schematic diagram of the structure of a digital matrix according to an embodiment of the present invention;
[0020] Figure 4 is a schematic diagram of digital matrix merging according to an embodiment of the present invention;
[0021] Figure 5 is a schematic diagram of digital matrix filtering according to an embodiment of the present invention;
[0022] Figure 6 is a flowchart of video retrieval according to an embodiment of the present invention;
[0023] Figure 7 is a flow chart of storing a digital matrix according to an embodiment of the present invention;
[0024] Figure 8 is a flowchart based on digital matrix retrieval according to an embodiment of the present invention;
[0025] Fig. 9 A structural block diagram of an apparatus for retrieving videos according to an embodiment of the present invention. DETAILED DESCRIPTION
[0026] Hereinafter, embodiments of the present invention will be described in detail with reference to the accompanying drawings and in combination with the embodiments.
[0027] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.
[0028] The method embodiments provided in the embodiments of the present application can be executed in a mobile terminal, a computer terminal or a similar computing device. Taking running on a mobile terminal as an example, Figure 1 FIG. 1 is a hardware structure block diagram of a mobile terminal of a method for retrieving videos according to an embodiment of the present invention. Figure 1 As shown, the mobile terminal may include one or more ( Figure 1 Only one is shown in the figure) a processor 102 (the processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA) and a memory 104 for storing data, wherein the mobile terminal may also include a transmission device 106 and an input / output device 108 for communication functions. It can be understood by those skilled in the art that Figure 1The structure shown is for illustration only and does not limit the structure of the mobile terminal. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations are shown.
[0029] The memory 104 can be used to store computer programs, for example, software programs and modules of application software, such as the computer program corresponding to the method for retrieving videos in the embodiment of the present invention. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, to implement the above method. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the mobile terminal via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0030] The transmission device 106 is used to receive or send data via a network. The specific example of the above network may include a wireless network provided by a communication provider of the mobile terminal. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, referred to as NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0031] In this embodiment, a method for retrieving videos running on the mobile terminal is provided. Figure 2 is a flow chart of a method for retrieving a video according to an embodiment of the present invention. Figure 2 As shown, the process includes the following steps:
[0032] Step S202, obtaining N video streams, wherein the N video streams are video clips captured by a video recording device in N time periods, N is an integer greater than or equal to 2, and each video stream includes multiple video frames;
[0033] The video recording device can be any mobile terminal with a camera or a device dedicated to video recording, such as a camera, tablet, or video camera; the video stream is a video clip or a video clip captured by the video recording device, wherein each video clip is composed of multiple identical or different image frames, each image frame is an independent image, and by playing these image frames in sequence, a dynamic video effect can be obtained. By capturing video clips at N different time periods by the video recording device, N video streams can be obtained.
[0034] Specifically, video frames are captured by the video recording device; when the time interval between a video frame currently captured by the video recording device and a video frame captured last time is less than or equal to a preset time threshold, the currently captured video frame and the video frame captured last time are determined as video frames in the same video stream; when the time interval between a video frame currently captured by the video recording device and a video frame captured last time is greater than the preset time threshold, the currently captured video frame and the video frame captured last time are determined as video frames in different video streams.
[0035] The above-mentioned preset time threshold can be set according to actual conditions, such as 6h, 12h, one day, etc., wherein the shorter the preset time threshold, the more video streams are obtained, and the more accurate the effect of subsequent video retrieval is; when the time interval between two acquisitions is less than the preset time threshold, the two acquired video clips are determined to be the same video stream, and when the time interval between two acquisitions is greater than or equal to the preset time threshold, the two acquired video clips are determined to be different video streams, thereby obtaining N video streams acquired in N time periods. By setting a preset time threshold to distinguish different acquired video clips as the same video stream or different video streams, it is beneficial to intuitively reflect the video clips on the timeline, and it is also convenient for users to quickly locate and identify related content when browsing and managing video clips, thereby improving the efficiency and accuracy of video processing.
[0036] Step S204, performing target recognition on the multiple video frames included in each of the video streams, respectively, to obtain N digital matrix sets corresponding to the N video streams, wherein the target recognition is performed on one of the video frames to obtain a digital matrix for identifying an area where a target in the video frame is located, and the digital matrix set includes a digital matrix obtained by performing the target recognition on the video frame of the video stream, and each position of the area where the target is located in the digital matrix is a preset value, and the digital matrix is used to identify an area where at least one type of target is located;
[0037] The above-mentioned target may be an area of interest in an image, such as a person, a vehicle, an animal, etc.; the above-mentioned video frame may be a still video screen in a video stream, and the video screen may be an independent image, wherein each video frame may be divided into a rectangular determinant, and the position of the target in the video frame may be determined by marking the corresponding position in the determinant. Therefore, target recognition is performed on the multiple video frames included in each video stream respectively, and a digital matrix of the area of interest in each video frame is obtained, thereby obtaining N digital matrix sets corresponding to N video streams, wherein each digital matrix set includes a digital matrix obtained by identifying multiple video frames in the video stream. By identifying and obtaining the digital matrix of the area where the target is located in the video frame, and storing it in the form of a digital matrix, the user can perform video retrieval by the target area, thereby improving the efficiency and accuracy of video retrieval.
[0038] Specifically, the following operations are performed on the video frames in each of the video streams, and the video frame on which the following operations are performed is the current video frame: the target is identified on the current video frame, the value of the position where the target is located in the current video frame is set to the preset value, and other positions in the current video frame except the position where the target is located are set to other values, so as to obtain a digital matrix of the current video frame.
[0039] Figure 3 is a schematic diagram of the structure of a digital matrix according to an embodiment of the present invention. Figure 3 As shown in the figure, each video frame can be divided into 18 rows and 22 columns, so that the video frame area can be represented by each small square bit by bit, where each row has 22 squares, which can be represented by 4 bytes (32 bits), and the entire video frame can be represented by data as int a
[18] ; by setting the target area (interest area) to 1 (preset value) in the corresponding square position occupied by the video frame, different types of targets can be recorded separately. For example, the solid-line frame area in the figure represents the target person area, and the dotted-line frame area represents the target car area, etc., so as to identify and obtain the data representation results (digital matrix) of different target types and obtain the digital matrix of the video frame.
[0040] Step S206, based on the regions where the targets of the same type identified by the multiple digital matrices included in each of the digital matrix sets are located, the digital matrix sets are merged to obtain N target digital matrices, wherein each of the target digital matrices is used to identify at least one target region, and each of the target regions is a region obtained by merging the regions where the targets of the same type identified by the multiple digital matrices included in the corresponding digital matrix set are located;
[0041] The above-mentioned target digital matrix can be a digital matrix obtained by merging digital matrices of targets of the same type, and the merging process can be a union operation on the matrix; each digital matrix in the N digital matrix sets is merged to obtain target digital matrices of N different time periods, and the obtained target digital matrices are stored in a database. By expressing the detected target area in each time period according to the target type union, the expression (digital matrix) of the target appearing in each time period can be obtained, which is helpful for retrieving videos by target type. At the same time, the union of target areas of different types in each time period is stored in the data storage library, thereby greatly reducing the amount of stored data, reducing the space occupied by data storage, and saving resources.
[0042] Specifically, when the currently processed digital matrix set is the current digital matrix set, the types of targets contained in the current digital matrix set are determined to obtain at least one type of the target; the following operations are performed on the at least one type of the target, and the type of the operations performed is determined to be the current type: the area containing the target of the current type is determined in the current digital matrix set to obtain T areas, wherein T is an integer greater than or equal to 1 and less than or equal to N; when T is greater than 1, the current target area obtained by performing the merging process on the T areas is determined as the area of the target of the current type in the current target digital matrix, wherein the current target digital matrix is the target digital matrix corresponding to the current digital matrix set, and at least one target area of the current target digital matrix includes the current target area; when T is equal to 1, a area is determined as the area of the target of the current type in the current target digital matrix, wherein the current target digital matrix is the target digital matrix corresponding to the current digital matrix set.
[0043] Figure 4 is a schematic diagram of digital matrix merging according to an embodiment of the present invention. Figure 4 As shown in the figure, the two solid-line frame areas respectively represent the digital matrices of the areas where the same type of targets are located obtained by identifying the same video frame or different video frames, wherein the two solid-line frames have overlapping parts, and the areas represented by the two solid-line frames are unioned to obtain a new target digital matrix.
[0044] Step S208: performing video retrieval based on the N target digital matrices.
[0045] The above-mentioned target digital matrix can be the area where different types of targets are located within a certain time period; through the stored target digital matrix, videos can be retrieved in various ways such as time, video area, target type, etc., thereby reducing the time of video retrieval, improving the efficiency of video retrieval, and at the same time, improving the accuracy of video retrieval.
[0046] Specifically, a target retrieval request is obtained, wherein the target retrieval request includes the type of the target to be retrieved and the time period to be retrieved; M first target digital matrices are determined in the N target digital matrices according to the time period to be retrieved, wherein the time of the time period to be retrieved is within M time periods of the M first target digital matrices, and M is an integer greater than or equal to 1 and less than or equal to N; S second target digital matrices are determined in the M first target digital matrices according to the type of the target to be retrieved, wherein S is an integer greater than or equal to 1 and less than or equal to M; a target video stream is determined according to the S second target digital matrices, wherein the target video stream is the retrieved video stream.
[0047] The above-mentioned M first target digital matrices are target digital matrices within the retrieval time period, and the above-mentioned S second target digital matrices are target digital matrices within the time period to be retrieved and include a type with the retrieval target. According to the information to be retrieved contained in the target retrieval request, S second target digital matrices within the time period to be retrieved and include a type with the retrieval target are obtained from the stored N target digital matrices.
[0048] Optionally, the executor of the above steps may be a background processor, or other devices with similar processing capabilities, or a machine that integrates at least an image acquisition device and a data processing device, wherein the image acquisition device may include a graphics acquisition module such as a camera, and the data processing device may include a computer, a mobile phone or other terminal, but is not limited thereto.
[0049] Through the above steps, the video clips collected by the recording device are identified, and the digital matrix of the target area in each video frame included in the video clip is obtained, and the obtained digital matrix is merged and stored, so as to perform video retrieval based on the stored digital matrix. The problem of low video retrieval accuracy in the related art is solved, and the efficiency and accuracy of video retrieval efficiency are improved.
[0050] As an optional implementation, S second target digital matrices are determined from the M first target digital matrices according to the type of the target to be retrieved, including: determining the target digital matrix containing the target of the same type as the target to be retrieved in the M first target digital matrices as the second target digital matrix.
[0051] As an optional implementation, determining the target video stream according to the S second target digital matrices includes: determining the S video streams corresponding to the S second target digital matrices as the target video stream; or, when S is greater than 1 and the target retrieval request also includes a to-be-retrieved area, determining S target areas where targets of the same type as the to-be-retrieved target are located in the S second target digital matrices; determining the digital matrix where the target area whose intersection among the S target areas with the to-be-retrieved area is greater than or equal to a preset threshold is located as a third target digital matrix; determining the video stream corresponding to the third target digital matrix as the target video stream; or, when S is greater than 1 and the target retrieval request also includes a to-be-retrieved area, determining the digital matrix where the target area of the same type as the to-be-retrieved target is located in the S second target digital matrices. The method comprises the following steps: determining S target regions where the target region having the largest intersection with the region to be retrieved among the S target regions is located as a fourth target digital matrix; determining a video stream corresponding to the fourth target digital matrix as the target video stream; or, when S is greater than 1 and the target retrieval request also includes the region to be retrieved, determining S target regions where the target region having the same type as the target to be retrieved is located in the S second target digital matrices; sorting the intersection regions with the region to be retrieved among the S target regions, and determining the digital matrices where the Q target regions corresponding to the first Q intersection regions are located as a fifth target digital matrix; and determining a video stream corresponding to the fifth target digital matrix as the target video stream, wherein Q is an integer greater than or equal to 1 and less than or equal to S.
[0052] As an optional implementation, Figure 5 is a schematic diagram of digital matrix filtering according to an embodiment of the present invention. Figure 5 As shown in the figure, the dotted box represents the selected filtering area (interest area). When searching, the target area is filtered out according to the type of the target to be detected included in the target search request. At the same time, the user's interest area (to be searched area) is drawn, and the interest area is compared with the filtered target area to determine the intersection between the two areas, and the area whose intersection is greater than the preset threshold is obtained. The target digital matrix corresponding to the area is determined, thereby obtaining the video stream corresponding to the target digital matrix (video stream to be detected).
[0053] As an optional implementation, Figure 6 is a flowchart of video retrieval according to an embodiment of the present invention. Figure 6 As shown, the specific process is as follows:
[0054] Video stream module: provides real-time video source data;
[0055] Target analysis module: Analyze and identify targets and types in video sources, use existing mature and general video structuring algorithms to analyze targets such as people and vehicles, and report target areas;
[0056] Video recording module: collect video stream;
[0057] Recording module: When the video is turned on, the target area of each target type that appears in the time period is recorded at a certain time interval and then combined in the time domain for comparison;
[0058] Retrieval module: Based on the user's interest area, target type, time and other query records, quickly filter out the video clips that meet the conditions.
[0059] As an optional implementation, Figure 7 is a flow chart of storing a digital matrix according to an embodiment of the present invention, such as Figure 7 As shown, the specific process is as follows:
[0060] S701, acquiring real-time video streams to obtain N video streams;
[0061] S702, inputting N video streams into a target analysis module for analysis, identifying the area where the target is located, and obtaining a digital matrix set;
[0062] S703, merging digital matrices of the same type in the digital matrix set to obtain a target digital matrix;
[0063] S704, recording the target digital matrix according to the start time and the end time.
[0064] As an optional implementation, Figure 8 is a flowchart based on digital matrix retrieval according to an embodiment of the present invention, such as Figure 8 As shown, the specific process is as follows:
[0065] S801, enter the video search page;
[0066] S802, drawing a filtering area in the video area according to the type of the target to be retrieved and the time period to be retrieved carried in the target retrieval request;
[0067] S803, comparing the stored target digital matrix with the drawn area;
[0068] S804: Determine a video segment according to the intersection of the two regions.
[0069] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for enabling a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in each embodiment of the present invention.
[0070] In the present embodiment, a device for retrieving video is also provided, and the device is used to implement the above-mentioned embodiment and preferred implementation mode, and the description has been made no further. As used below, the term "module" can implement a combination of software and / or hardware of a predetermined function. Although the device described in the following embodiments is preferably implemented in software, the implementation of hardware, or a combination of software and hardware is also possible and conceived.
[0071] Fig. 9 is a structural block diagram of a device for retrieving video according to an embodiment of the present invention, such as Fig. 9 As shown, the device includes: an acquisition module 902, which is used to acquire N video streams, wherein the N video streams are video clips collected by a video recording device in N time periods, N is an integer greater than or equal to 2, and each of the video streams includes multiple video frames; an identification module 904, which is used to perform target identification on the multiple video frames included in each of the video streams, respectively, to obtain N digital matrix sets corresponding to the N video streams, wherein the target identification is performed on one of the video frames to obtain a digital matrix for identifying the area where the target in the video frame is located, and the digital matrix set includes the digital matrix obtained by performing the target identification on the video frames of the video stream, and the target in the digital matrix The preset values are placed at various positions in the region, and the digital matrix is used to identify the region where at least one type of target is located; a merging module 906 is used to merge the digital matrix set based on the regions where the targets of the same type identified by multiple digital matrices included in each of the digital matrix sets are located, to obtain N target digital matrices, wherein each of the target digital matrices is used to identify at least one target region, and each of the target regions is a region obtained by merging the regions where the targets of the same type identified by multiple digital matrices included in the corresponding digital matrix set are located; a retrieval module 908 is used to perform video retrieval based on the N target digital matrices.
[0072] In an exemplary embodiment, the device is also used to obtain a target retrieval request, wherein the target retrieval request includes the type of the target to be retrieved and the time period to be retrieved; M first target digital matrices are determined in the N target digital matrices according to the time period to be retrieved, wherein the time of the time period to be retrieved is within the M time periods of the M first target digital matrices, and M is an integer greater than or equal to 1 and less than or equal to N; S second target digital matrices are determined in the M first target digital matrices according to the type of the target to be retrieved, wherein S is an integer greater than or equal to 1 and less than or equal to M; a target video stream is determined according to the S second target digital matrices, wherein the target video stream is the retrieved video stream.
[0073] In an exemplary embodiment, the apparatus is further configured to determine a target digital matrix in the M first target digital matrices that contains a target of the same type as the target to be retrieved as the second target digital matrix.
[0074] In an exemplary embodiment, the device is also used to determine the S video streams corresponding to the S second target digital matrices as the target video stream; or, when S is greater than 1 and the target retrieval request also includes a to-be-retrieved area, determine the S target areas where the target of the same type as the to-be-retrieved target is located in the S second target digital matrices; determine the digital matrix where the target area whose intersection with the to-be-retrieved area among the S target areas is greater than or equal to a preset threshold is located as a third target digital matrix; determine the video stream corresponding to the third target digital matrix as the target video stream; or, when S is greater than 1 and the target retrieval request also includes a to-be-retrieved area, determine the S target areas where the target of the same type as the to-be-retrieved target is located in the S second target digital matrices. S target areas; determining the digital matrix where the target area among the S target areas that has the largest intersection with the area to be retrieved is located as the fourth target digital matrix; determining the video stream corresponding to the fourth target digital matrix as the target video stream; or, when S is greater than 1 and the target retrieval request also includes the area to be retrieved, determining S target areas where targets of the same type as the target to be retrieved are located in the S second target digital matrices; sorting the intersection areas with the area to be retrieved among the S target areas, and determining the digital matrices where the Q target areas corresponding to the first Q intersection areas are located as the fifth target digital matrix; determining the video stream corresponding to the fifth target digital matrix as the target video stream, wherein Q is an integer greater than or equal to 1 and less than or equal to S.
[0075] In an exemplary embodiment, the apparatus is also used to capture video frames through the video recording device; when the time interval between a video frame currently captured by the video recording device and a video frame captured last time is less than or equal to a preset time threshold, the currently captured video frame and the video frame captured last time are determined as video frames in the same video stream; when the time interval between a video frame currently captured by the video recording device and a video frame captured last time is greater than the preset time threshold, the currently captured video frame and the video frame captured last time are determined as video frames in different video streams.
[0076] In an exemplary embodiment, the device is also used to perform the following operations on the video frames in each of the video streams, and the video frame on which the following operations are performed is the current video frame: performing the target identification on the current video frame, setting the value of the position where the target is located in the current video frame to the preset value, and setting other positions in the current video frame except the position where the target is located to other values, to obtain a digital matrix of the current video frame.
[0077] In an exemplary embodiment, the device is also used to determine the type of targets contained in the current digital matrix set when the digital matrix set currently being processed is the current digital matrix set, and obtain at least one type of the target; perform the following operations on the at least one type of the target, and the type of the operations performed is determined as the current type: determine the area containing the target of the current type in the current digital matrix set to obtain T areas, wherein T is an integer greater than or equal to 1 and less than or equal to N; when T is greater than 1, determine the current target area obtained by performing the merging process on the T areas as the area of the target of the current type in the current target digital matrix, wherein the current target digital matrix is the target digital matrix corresponding to the current digital matrix set, and at least one target area of the current target digital matrix includes the current target area; when T is equal to 1, determine a area as the area of the target of the current type in the current target digital matrix, wherein the current target digital matrix is the target digital matrix corresponding to the current digital matrix set.
[0078] It should be noted that the above modules can be implemented by software or hardware. For the latter, it can be implemented in the following ways, but not limited to: the above modules are all located in the same processor; or the above modules are located in different processors in any combination.
[0079] An embodiment of the present invention further provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the steps of any of the above methods are implemented.
[0080] In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to, various media that can store computer programs, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk.
[0081] An embodiment of the present invention further provides an electronic device, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.
[0082] In an exemplary embodiment, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.
[0083] An embodiment of the present invention further provides a computer program product, including a computer program, which implements the steps of the method described in each embodiment of the present application when executed by a processor.
[0084] For specific examples in this embodiment, reference may be made to the examples described in the above embodiments and exemplary implementation modes, and this embodiment will not be described in detail herein.
[0085] Obviously, those skilled in the art should understand that the above modules or steps of the present invention can be implemented by a general computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be executed in a different order than here, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. Thus, the present invention is not limited to any specific combination of hardware and software.
[0086] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A method for retrieving a video, characterized in that: include: Obtaining N video streams, wherein the N video streams are video clips captured by a video recording device in N time periods, N is an integer greater than or equal to 2, and each of the video streams includes multiple video frames; Performing target recognition on a plurality of video frames included in each of the video streams respectively, and obtaining N digital matrix sets corresponding to the N video streams, wherein performing target recognition on one of the video frames obtains a digital matrix for identifying an area where a target in the video frame is located, and the digital matrix set includes a digital matrix obtained by performing target recognition on the video frame of the video stream, and each position of the area where the target is located in the digital matrix is a preset value, and the digital matrix is used to identify an area where at least one type of target is located; Based on the regions where the targets of the same type identified by the multiple digital matrices included in each of the digital matrix sets are located, the digital matrix sets are merged to obtain N target digital matrices, wherein each of the target digital matrices is used to identify at least one target region, and each of the target regions is a region obtained by merging the regions where the targets of the same type identified by the multiple digital matrices included in the corresponding digital matrix set are located; Video retrieval is performed based on the N target digital matrices.
2. The method according to claim 1, characterized in that The video retrieval based on the N target digital matrices includes: Obtaining a target search request, wherein the target search request includes a type of target to be searched and a time period to be searched; Determine M first target digital matrices in the N target digital matrices according to the time period to be retrieved, wherein the time period to be retrieved is within M time periods of the M first target digital matrices, and M is an integer greater than or equal to 1 and less than or equal to N; Determine S second target digital matrices in the M first target digital matrices according to the type of the target to be retrieved, where S is an integer greater than or equal to 1 and less than or equal to M; A target video stream is determined according to the S second target digital matrices, wherein the target video stream is the retrieved video stream.
3. The method according to claim 2, characterized in that Determining S second target digital matrices in the M first target digital matrices according to the type of the target to be retrieved includes: The target digital matrix containing the target of the same type as the target to be retrieved in the M first target digital matrices is determined as the second target digital matrix.
4. The method according to claim 2, characterized in that: Determining a target video stream according to the S second target digital matrices includes: Determine the S video streams corresponding to the S second target digital matrices as the target video streams; or, In the case where S is greater than 1 and the target retrieval request also includes a to-be-retrieved area, S target areas where targets of the same type as the to-be-retrieved target are located are determined in the S second target digital matrices; a digital matrix where the target area whose intersection with the to-be-retrieved area among the S target areas is greater than or equal to a preset threshold is determined as a third target digital matrix; a video stream corresponding to the third target digital matrix is determined as the target video stream; or In the case where S is greater than 1 and the target search request also includes a region to be searched, S target regions where targets of the same type as the target to be searched are located are determined in the S second target digital matrices; the digital matrix where the target region having the largest intersection with the region to be searched among the S target regions is located is determined as the fourth target digital matrix; the video stream corresponding to the fourth target digital matrix is determined as the target video stream; or When S is greater than 1 and the target retrieval request also includes an area to be retrieved, determine S target areas where targets of the same type as the target to be retrieved are located in the S second target digital matrices; sort the intersection areas of the S target areas with the area to be retrieved, and determine the digital matrices where the Q target areas corresponding to the first Q intersection areas are located as the fifth target digital matrix; determine the video stream corresponding to the fifth target digital matrix as the target video stream, wherein Q is an integer greater than or equal to 1 and less than or equal to S.
5. The method according to claim 1, characterized in that Get N video streams, including: Capturing video frames through the video recording device; When the time interval between the video frame currently captured by the video recording device and the video frame last captured is less than or equal to a preset time threshold, determining the video frame currently captured and the video frame last captured as video frames in the same video stream; When the time interval between the video frame currently captured by the video recording device and the video frame captured last is greater than the preset time threshold, the video frame currently captured and the video frame captured last are determined as video frames in different video streams.
6. The method according to claim 1, characterized in that Target recognition is performed on the multiple video frames included in each of the video streams to obtain N digital matrix sets corresponding to the N video streams, including: The following operations are performed on the video frames in each of the video streams, where the video frame in which the operations are performed is the current video frame: The target is identified on the current video frame, the value of the position where the target is located in the current video frame is set to the preset value, and other positions in the current video frame except the position where the target is located are set to other values to obtain a digital matrix of the current video frame.
7. The method according to claim 1, characterized in that Based on the regions where the targets of the same type identified by the multiple digital matrices included in each of the digital matrix sets are located, merging the digital matrix sets, including: In a case where the currently processed digital matrix set is a current digital matrix set, determining types of targets included in the current digital matrix set to obtain at least one type of the target; The following operations are performed on the type of at least one of the targets, and the type of the following operations is determined as the current type: Determine in the current digital matrix set the region containing the target of the current type, and obtain T regions, where T is an integer greater than or equal to 1 and less than or equal to N; In the case where T is greater than 1, a current target region obtained by performing the merging process on the T regions is determined as a region of the target of the current type in the current target digital matrix, wherein the current target digital matrix is a target digital matrix corresponding to the current digital matrix set, and at least one target region of the current target digital matrix includes the current target region; When T is equal to 1, a region is determined as the region of the current type of target in the current target digital matrix, wherein the current target digital matrix is the target digital matrix corresponding to the current digital matrix set.
8. A device for retrieving a video, characterized in that: include: An acquisition module, used to acquire N video streams, wherein the N video streams are video clips captured by a video recording device in N time periods, N is an integer greater than or equal to 2, and each of the video streams includes multiple video frames; An identification module, used for performing target identification on a plurality of video frames included in each of the video streams, respectively, to obtain N digital matrix sets corresponding to the N video streams, wherein the target identification is performed on one of the video frames to obtain a digital matrix for identifying an area where a target in the video frame is located, and the digital matrix set includes a digital matrix obtained by performing target identification on the video frame of the video stream, and each position of the area where the target is located in the digital matrix is a preset value, and the digital matrix is used to identify an area where at least one type of target is located; A merging module, used for merging the digital matrix sets based on the regions where the targets of the same type identified by the multiple digital matrices included in each of the digital matrix sets are located, to obtain N target digital matrices, wherein each of the target digital matrixes is used to identify at least one target region, and each of the target regions is a region obtained by merging the regions where the targets of the same type identified by the multiple digital matrices included in the corresponding digital matrix set are located; The retrieval module is used to perform video retrieval based on the N target digital matrices.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program implements the steps of the method described in any one of claims 1 to 7 when executed by a processor.
10. An electronic device comprising a memory and a processor, characterized in that: A computer program is stored in the memory, and the processor is configured to run the computer program to perform the method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Video processing method, device and apparatus and video target tracking method
CN113468378A
Video target detection method and device
CN113971772A
